<commit_before>var app = require('../server'),
    request = require('supertest');

describe('Valid app', function() {
    const agent = request.agent(app);
    let id;
    it('connects to server', function(){
        agent.post('/users/register/toto/').end(function(err, res) {
            expect(err).toBeNull();
            id = res.body.id;
            expect(id).not.toBeUndefined();
        })
    })
    
    it('joins a channel', function() {
        agent.put('/user/' + id + '/channels/channel-1/join/')
            .end(function(err, res) {
                done()
                expect(err).toBeNull();
                const user = res.body.user;
                expect(user).not.toBeNull();
                expect(user.id).toEqual(id);
            })
    })
    
    it('talks in channel', function() {
        agent.put('/user/' + id + '/channels/channel-1/say/')
            .send({ message: 'Hello, world!' })
            .end(function(err, res) {
                done()
                expect(err).toBeNull()
                const user = res.body.user;
                expect(user).not.toBeNull();
                expect(user.id).toEqual(id);
            })
    })
    
    it('checks for notices', function() {
        agent.put('/user/' + id + '/notices/')
            .end(function(err, res) {
                done()
                expect(err).toBeNull()
                const notices = res.body.notices
                expect(notices).not.toBeNull()
                expect(notices.length).toEqual(2)
                expect(notices[0]['type']).toEqual('channelJoin');
                expect(notices[0]['nick']).toEqual('toto');
                expect(notices[0]['channel']).toEqual('channel-1');
                
                expect(notices[1]['type']).toEqual('channelMessage');
                expect(notices[1]['nick']).toEqual('toto');
                expect(notices[1]['channel']).toEqual('channel-1');
            })
    })
    
    it('disconnects', function() {
        agent.put('/user/' + id + '/disconnect/')
            .end(function(err, res) {
                done()
                expect(err).toBeNull()
                const version = res.body.version
                expect(version).not.toBeNull()
            })
    })
});

describe('Invalid app', function() {
    // TODO Invalid actions<commit_msg>Put done() at the end<commit_after>var app = require('../server'),
    request = require('supertest');

describe('Valid app', function() {
    const agent = request.agent(app);
    let id;
    it('connects to server', function(){
        agent.post('/users/register/toto/').end(function(err, res) {
			expect(true).toBe(false);
            expect(err).toBeNull();
            id = res.body.id;
            expect(id).not.toBeUndefined();
			done()
        })
    })
    
    it('joins a channel', function() {
        agent.put('/user/' + id + '/channels/channel-1/join/')
            .end(function(err, res) {
                expect(err).toBeNull();
                const user = res.body.user;
                expect(user).not.toBeNull();
                expect(user.id).toEqual(id);
				done()
            })
    })
    
    it('talks in channel', function() {
        agent.put('/user/' + id + '/channels/channel-1/say/')
            .send({ message: 'Hello, world!' })
            .end(function(err, res) {
                expect(err).toBeNull()
                const user = res.body.user;
                expect(user).not.toBeNull();
                expect(user.id).toEqual(id);
				done()
            })
    })
    
    it('checks for notices', function() {
        agent.put('/user/' + id + '/notices/')
            .end(function(err, res) {
                expect(err).toBeNull()
                const notices = res.body.notices
                expect(notices).not.toBeNull()
                expect(notices.length).toEqual(2)
                expect(notices[0]['type']).toEqual('channelJoin');
                expect(notices[0]['nick']).toEqual('toto');
                expect(notices[0]['channel']).toEqual('channel-1');
                
                expect(notices[1]['type']).toEqual('channelMessage');
                expect(notices[1]['nick']).toEqual('toto');
                expect(notices[1]['channel']).toEqual('channel-1');
				done()
            })
    })
    
    it('disconnects', function() {
        agent.put('/user/' + id + '/disconnect/')
            .end(function(err, res) {
                expect(err).toBeNull()
                const version = res.body.version
                expect(version).not.toBeNull()
				done()
            })
    })
});

describe('Invalid app', function() {
    // TODO Invalid actions
{'fraction_non_alphanumeric': 0.17161152614727854, 'fraction_numerical': 0.004695837780149413, 'mean_word_length': 1.6296296296296295, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '766563', 'n_tokens_mistral': 1364, 'n_tokens_neox': 1309, 'n_words': 205}