<commit_before>'use strict';
var RethinkDBStore = require('../');
var r = require('rethinkdb');
var TokenStore = require('passwordless-tokenstore');
var standardTests = require('passwordless-tokenstore-test');
var expect = require('chai').expect;
var uuid = require('node-uuid');
var TokenStoreFactory;
var connection;

var options = {
    host: 'localhost',
    port: 28015,
    db: 'test'
};

var beforeEachTest = function (done) {
    r.connect(options, function (err, connection) {
        r.table('pwdless').delete().run(connection, function (err) {
            done(err);
        });
    });
};

var afterEachTest = function (done) {
    return done();
};

TokenStoreFactory = function TokenStoreFactory() {
    return new RethinkDBStore(options);
};

standardTests(TokenStoreFactory, beforeEachTest, afterEachTest);

describe('RethinkDB Specific Tests', function() {
    beforeEach(function(done) {
        beforeEachTest(done);
    })

    afterEach(function(done) {
        afterEachTest(done);
    })
    
    it('should gracefully handle undefined originUrl values', function (done) {
        var store = TokenStoreFactory();
        var uid = "<EMAIL>";
        var token = uuid.v4();
        var ttl = 1000*60;
        var origin;
        
        store.storeOrUpdate(token, uid, 1000*60, origin, function() {
							expect(arguments.length).to.equal(0);
              done();
        });
    });
})
<commit_msg>fix: fix tests<commit_after>'use strict';
var RethinkDBStore = require('../');
var r = require('rethinkdb');
var TokenStore = require('passwordless-tokenstore');
var standardTests = require('passwordless-tokenstore-test');
var expect = require('chai').expect;
var uuid = require('node-uuid');
var TokenStoreFactory;
var connection;

var options = {
    host: 'localhost',
    port: 28015,
    db: 'test'
};

var beforeEachTest = function (done) {
    r.connect(options, function (err, connection) {
        r.db('test').tableList().run(connection, function(err, res) {
            if (res.indexOf('pwdless') == -1) {
                r.db('test').tableCreate('pwdless').run(connection, function (err) {
                    return done(err);
                });
            }
            else {
                return done(err);
            }
        });
    });
};

var afterEachTest = function (done) {
    return done();
};

TokenStoreFactory = function TokenStoreFactory() {
    return new RethinkDBStore(options);
};

standardTests(TokenStoreFactory, beforeEachTest, afterEachTest);

describe('RethinkDB Specific Tests', function() {
    beforeEach(function(done) {
        beforeEachTest(done);
    })

    afterEach(function(done) {
        afterEachTest(done);
    })
    
    it('should gracefully handle undefined originUrl values', function (done) {
        var store = TokenStoreFactory();
        var uid = "<EMAIL>";
        var token = uuid.v4();
        var ttl = 1000*60;
        var origin;
        
        store.storeOrUpdate(token, uid, 1000*60, origin, function() {
							expect(arguments.length).to.equal(0);
              done();
        });
    });
})

{'fraction_non_alphanumeric': 0.1438245727184779, 'fraction_numerical': 0.012576588197355692, 'mean_word_length': 2.806134969325153, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3164100', 'n_tokens_mistral': 943, 'n_tokens_neox': 898, 'n_words': 204}