<commit_before>'use strict';

let app = require('../../src/app'),
    assert = require('assert'),
    HttpStatus = require('http-status'),
    connection = require('../db_common'),
    co = require('co');

import User from '../../src/models/user';

describe('app', function () {
    it('should have the port set to 3000', function () {
        assert.strictEqual(app.get('port'), 3000);
    });

    describe('parseAccessToken', function () {
        let db, req, res, next;

        before(() => {
            db = connection();
        });

        beforeEach(() => {
            req = { query: { token: null } };
            res = {
                status: function (status) {
                    if (!this.statusExpected) {
                        throw new Error('No statusExpected set!');
                    }
                    assert.strictEqual(status, this.statusExpected);
                    return this;
                },
                send: function (data) {
                    if (!this.sendDataExpected) {
                        throw new Error('No sendDataExpected set!');
                    }
                    assert.strictEqual(data, this.sendDataExpected);
                    if (this.sendCb) {
                        this.sendCb();
                    }
                }
            };
            next = () => {
                throw new Error('next() not initialized!');
            };
        });

        after(() => {
            db.close();
        });

        it('should return FORBIDDEN for a given but invalid accessToken', done => {
            req.query.token = '<PASSWORD>';
            res.statusExpected = HttpStatus.FORBIDDEN;
            res.sendDataExpected = 'Forbidden';
            res.sendCb = done;<commit_msg>fixed app_test for the latest changes<commit_after>'use strict';

let app = require('../../src/app'),
    assert = require('assert'),
    HttpStatus = require('http-status'),
    connection = require('../db_common'),
    co = require('co');

import User from '../../src/models/user';

describe('app', function () {
    it('should have the port set to 3000', function () {
        assert.strictEqual(app.get('port'), 3000);
    });

    describe('parseAccessToken', function () {
        let db, req, res, next;

        before(() => {
            db = connection();
        });

        beforeEach(() => {
            req = { query: { token: null } };
            res = {
                status: function (status) {
                    if (!this.statusExpected) {
                        throw new Error('No statusExpected set!');
                    }
                    assert.strictEqual(status, this.statusExpected);
                    return this;
                },
                send: function (data) {
                    if (!this.sendDataExpected) {
                        throw new Error('No sendDataExpected set!');
                    }
                    assert.strictEqual(data, this.sendDataExpected);
                    if (this.sendCb) {
                        this.sendCb();
                    }
                },
                json: function (data) {
                    if (!this.jsonDataExpected) {
                        throw new Error('No jsonDataExpected set!');
                    }
                    assert.deepEqual(data, this.jsonDataExpected);
                    if (this.jsonCb) {
                        this.jsonCb();
                    }
                }
            };
            next = () => {
                throw new Error('next() not initialized!');
            };
        });

        after(() => {
            db.close();
        });

        it('should return FORBIDDEN for a given but invalid accessToken', done => {
            req.query.token = '<PASSWORD>';
            res.statusExpected = HttpStatus.FORBIDDEN;
            res.jsonDataExpected = {};
            res.jsonCb = done;
{'fraction_non_alphanumeric': 0.1324655436447167, 'fraction_numerical': 0.00408371618172537, 'mean_word_length': 1.2679398148148149, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '4298001', 'n_tokens_mistral': 1000, 'n_tokens_neox': 926, 'n_words': 218}