<commit_before>/* global expect AuthServiceMock SettingsServiceMock ModalServiceMock
    NotificationsServiceMock AutoActionsServiceMock StringsServiceMock SanitizerMock */
var dirs = '../../../../',
    path = dirs + 'build/settings/auto-actions/',
    AutoActions = require(path + 'auto-actions.component.js').AutoActions;

describe('AutoActions', () => {
    var autoActions,
        modalService;

    beforeEach(() => {
        modalService = new ModalServiceMock();

        autoActions = new AutoActions(AuthServiceMock, modalService,
            new SettingsServiceMock(), new AutoActionsServiceMock(),
            new NotificationsServiceMock(), StringsServiceMock, SanitizerMock);
    });

    it('has a function to add an action', done => {
        autoActions.removeAutoAction();

        setTimeout(() => {
            expect(autoActions.autoActions.length).to.equal(1);
            done();
        }, 10);
    });

    it('has a function to remove an action', done => {
        autoActions.addNewAction();

        setTimeout(() => {
            expect(autoActions.newAction.id).to.equal(0);
            expect(autoActions.autoActions.length).to.equal(3);
            done();
        }, 10);

    });

    it('has a function to update the list of triggers', () => {
        autoActions.newAction.board_id = 1;

        autoActions.newAction.trigger = 1;
        autoActions.updateTriggerSources();

        expect(autoActions.triggerSources[1][1]).to.equal('Column 1');

        autoActions.newAction.trigger = 2;
        autoActions.updateTriggerSources();

        expect(autoActions.triggerSources[1][1]).to.equal('test');

        autoActions.newAction.trigger = 3;
        autoActions.updateTriggerSources();

        expect(autoActions.triggerSources[1][1]).to.equal('Category 1');

        autoActions.newAction.trigger = 4;
        autoActions.updateTriggerSources();

        expect(autoActions.triggerSources.length).to.equal(0);
    });

    it('has a function to update the list of action sources', () => {
        autoActions.newAction.type = 1;
        autoActions.updateActionSources();

        expect(autoActions.newAction.change_to).to.equal('#000000');

        autoActions.newAction.type = 2; // 2 and 3 are the same
        autoActions.updateActionSources();

        expect(autoActions.actionSources[0][1]).to.equal(undefined);

        autoActions.newAction.type = 4; // 4 and 5 are the same
        autoActions.updateActionSources();

        expect(autoActions.actionSources[0][1]).to.equal(undefined);
    });

    it('provides a description for a trigger', () => {
        var action = {
            id: 1,
            trigger: 1,
            source_id: 1,
            type: 1,
            change_to: 'test',
            board_id: 1
        };

        var desc = autoActions.getTriggerDescription(action);
        expect(desc).to.equal('undefined Column 1');

        action.trigger = 2;
        action.source_id = 2;

        desc = autoActions.getTriggerDescription(action);
        expect(desc).to.equal('undefined test');<commit_msg>Update app tests<commit_after>/* global expect AuthServiceMock SettingsServiceMock ModalServiceMock
    NotificationsServiceMock AutoActionsServiceMock StringsServiceMock SanitizerMock */
var dirs = '../../../../',
    path = dirs + 'build/settings/auto-actions/',
    AutoActions = require(path + 'auto-actions.component.js').AutoActions;

describe('AutoActions', () => {
    var autoActions,
        modalService;

    beforeEach(() => {
        modalService = new ModalServiceMock();

        autoActions = new AutoActions(AuthServiceMock, modalService,
            new SettingsServiceMock(), new AutoActionsServiceMock(),
            new NotificationsServiceMock(), StringsServiceMock, SanitizerMock);
    });

    it('has a function to add an action', done => {
        autoActions.removeAutoAction();

        setTimeout(() => {
            expect(autoActions.autoActions.length).to.equal(1);
            done();
        }, 10);
    });

    it('has a function to remove an action', done => {
        autoActions.addNewAction();

        setTimeout(() => {
            expect(autoActions.newAction.id).to.equal(0);
            expect(autoActions.autoActions.length).to.equal(3);
            done();
        }, 10);

    });

    it('has a function to update the list of triggers', () => {
        autoActions.newAction.board_id = 1;

        autoActions.newAction.trigger = 1;
        autoActions.updateTriggerSources();

        expect(autoActions.triggerSources[1][1]).to.equal('Column 1');

        autoActions.newAction.trigger = 2;
        autoActions.updateTriggerSources();

        expect(autoActions.triggerSources[1][1]).to.equal('test');

        autoActions.newAction.trigger = 3;
        autoActions.updateTriggerSources();

        expect(autoActions.triggerSources[1][1]).to.equal('Category 1');

        autoActions.newAction.trigger = 4;
        autoActions.updateTriggerSources();

        expect(autoActions.triggerSources.length).to.equal(0);
    });

    it('has a function to update the list of action sources', () => {
        var undef;

        autoActions.newAction.type = 1;
        autoActions.updateActionSources();

        expect(autoActions.newAction.change_to).to.equal('#000000');

        autoActions.newAction.type = 2; // 2 and 3 are the same
        autoActions.updateActionSources();

        expect(autoActions.actionSources[0][1]).to.equal(undef);

        autoActions.newAction.type = 4; // 4 and 5 are the same
        autoActions.updateActionSources();

        expect(autoActions.actionSources[0][1]).to.equal(undef);
    });

    it('provides a description for a trigger', () => {
        var action = {
            id: 1,
            trigger: 1,
            source_id: 1,
            type: 1,
            change_to: 'test',
            board_id: 1
        };

        var desc = autoActions.getTriggerDescription(action);
        expect(desc).to.equal('undefined Column 1');

        action.trigger = 2;
        action.source_id = 2;

        desc = autoActions.getTriggerDescription(action);
        expect(desc).to.equal('undefined test');
{'fraction_non_alphanumeric': 0.1294346346994978, 'fraction_numerical': 0.014903612506074842, 'mean_word_length': 2.540137614678899, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '6201216', 'n_tokens_mistral': 1742, 'n_tokens_neox': 1627, 'n_words': 327}