<commit_before>'use strict'

var path = require('path')
var fs = require('fs')
var rand = require('crypto-rand')
var request = require('request')

global.__base = path.join(__dirname, '..', '/')

var Config = require(path.join(__base, 'src/worker/config.js'))
var ConfigWorker = new Config()
global.__config = ConfigWorker.load(path.join(__base, 'configs/config.json'))
global.__config.server.port = process.env.PORT || global.__config.server.port

var assert = require('chai').assert

describe('Fontend', function () {})

describe('Backend', function () { 
  describe('Auth', function () {
    var username = 'foo' + rand.rand()
    var username2 = 'foo2' + rand.rand()

    var Auth = require(path.join(__base, 'src/worker/auth.js'))
    describe('createInvite()', function () {
      it('Invite key: ' + __config.server.invitationKey, function (done) {
        assert.typeOf(Auth.createInvite(__config.server.invitationKey), 'string')
        done()
      })
      it('Invite key: Unknown', function (done) {
        assert(!Auth.createInvite(''))
        done()
      })
    })
    describe('Register()', function () {
      it('User: foo, Pass: <PASSWORD>, Invite: Valid invitation', function (done) {
        var invite = Auth.createInvite(__config.server.invitationKey)
        assert.typeOf(Auth.register(username, 'bar', invite), 'string')
        done()
      })
      it('User: foo, Pass: <PASSWORD>, Invite: Valid invitation', function (done) {
        var invite = Auth.createInvite(__config.server.invitationKey)
        assert(!Auth.register(username, 'bar', invite))
        done()
      })
      it('User: foo, Pass: <PASSWORD>, Invite: Invalid invitation', function (done) {
        assert(!Auth.register(username2, 'bar', ''))
        done()
      })
    })<commit_msg>improve tests for Log worker<commit_after>'use strict'

var path = require('path')
var fs = require('fs')
var rand = require('crypto-rand')
var request = require('request')

global.__base = path.join(__dirname, '..', '/')

var Config = require(path.join(__base, 'src/worker/config.js'))
var ConfigWorker = new Config()
global.__config = ConfigWorker.load(path.join(__base, 'configs/config.json'))
global.__config.server.port = process.env.PORT || global.__config.server.port

var assert = require('chai').assert

describe('Fontend', function () {})

describe('Backend', function () { 
  describe('Log', function(){
    var Log = require(path.join(__base, 'src/worker/log.js'))
    var LogWorker = new Log()
    var LogWorker2 = new Log({})
    it('Log info', function(done){
      LogWorker.info('This is an info.')
      done()
    })
    it('Log warning', function(done){
      LogWorker.warning('This is a warning.')
      done()
    })
    it('Log error', function(done){
      LogWorker.error('This is an error.')
      done()
    })
  })
  describe('Auth', function () {
    var username = 'foo' + rand.rand()
    var username2 = 'foo2' + rand.rand()

    var Auth = require(path.join(__base, 'src/worker/auth.js'))
    describe('createInvite()', function () {
      it('Invite key: ' + __config.server.invitationKey, function (done) {
        assert.typeOf(Auth.createInvite(__config.server.invitationKey), 'string')
        done()
      })
      it('Invite key: Unknown', function (done) {
        assert(!Auth.createInvite(''))
        done()
      })
    })
    describe('Register()', function () {
      it('User: foo, Pass: <PASSWORD>, Invite: Valid invitation', function (done) {
        var invite = Auth.createInvite(__config.server.invitationKey)
        assert.typeOf(Auth.register(username, 'bar', invite), 'string')
        done()
      })
      it('User: foo, Pass: <PASSWORD>, Invite: Valid invitation', function (done) {
        var invite = Auth.createInvite(__config.server.invitationKey)
        assert(!Auth.register(username, 'bar', invite))
        done()
      })
      it('User: foo, Pass: <PASSWORD>, Invite: Invalid invitation', function (done) {
        assert(!Auth.register(username2, 'bar', ''))
        done()
      })
    })
{'fraction_non_alphanumeric': 0.1693827160493827, 'fraction_numerical': 0.0017283950617283952, 'mean_word_length': 3.327991452991453, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '5723759', 'n_tokens_mistral': 1223, 'n_tokens_neox': 1214, 'n_words': 272}