<commit_before>/// <reference path="../../submodules/DefinitelyTyped/requirejs/require.d.ts"/>
/// <reference path="../../submodules/DefinitelyTyped/jquery/jquery.d.ts"/>
/// <reference path="../../submodules/DefinitelyTyped/mocha/mocha.d.ts"/>
/// <reference path="../../submodules/DefinitelyTyped/chai/chai.d.ts"/>

// for importing things in TypeScript, see
// http://www.codeproject.com/Articles/528295/ModularizationplusinplusTypeScript

// This is missing in mocha's d.ts, isn't it?
declare var mocha : Mocha; // Should not be called 'mocha', since that clashes
                           // with the (required) 'mocha'-div, but I didn't get
                           // that to work.
mocha = require('mocha');

chai = require('chai');
var expect = chai.expect;

import Adhocracy = require('Adhocracy');
import ProposalWorkbench = require('Adhocracy/Frames/ProposalWorkbench');
import Util = require('Adhocracy/Util');


mocha.setup({ui: 'bdd', slow: 30, timeout: 2000});

describe('something pure yet lame', function() {
    it('should half its input', function() {
        expect(ProposalWorkbench.something_pure(18)).to.equal(9);
    });
});

describe('some trivial DOM invariants', function() {
    it('must have three divs named appropriately', function() {
        expect($('#___probably_not_a_valid_dom_elem_id___')).to.have.length(0);
        expect($('#proposal_workbench_detail')).to.not.have.length(0);
        expect($('#proposal_workbench_directory')).to.not.have.length(0);
        expect($('#proposal_workbench_discussion')).to.not.have.length(0);
    });

    it('detail div must contain "..." after Adhocracy.init()', function() {
        Adhocracy.init();
        expect($('#proposal_workbench_detail')[0].innerText).to.equal('...');
    });

    describe('directory div must contain list of proposals as created by fixtures.js', function() {

        // FIXME: fixtures.js does not exist.  the following
        // should be slightly out of order, but the idea should be
        // valid.

        var expected_names;
        var directory_div;

        beforeEach(function(done) {
            ProposalWorkbench.open_proposals('/adhocracy/', function() {
                expected_names = ['proposal DAG 1', 'proposal DAG 2'];
                directory_div = $.makeArray($('#proposal_workbench_directory'))[0]
                done();
            });
        });

        it('list_items should contain the right proposal names.', function() {
            expected_names.forEach(function (name) {
//                     expect(directory_div.innerText).to.match(
//                         new RegEx('/' + name + '/'),
//                         "wef");
                expect(Util.isInfixOf(name, directory_div.innerText)).to.equal(true, name);
            });
        });
    });
});

export function run_tests() {
    mocha.run(function() {});
};<commit_msg>test suite: substring matching using RegExp<commit_after>/// <reference path="../../submodules/DefinitelyTyped/requirejs/require.d.ts"/>
/// <reference path="../../submodules/DefinitelyTyped/jquery/jquery.d.ts"/>
/// <reference path="../../submodules/DefinitelyTyped/mocha/mocha.d.ts"/>
/// <reference path="../../submodules/DefinitelyTyped/chai/chai.d.ts"/>

// for importing things in TypeScript, see
// http://www.codeproject.com/Articles/528295/ModularizationplusinplusTypeScript

// This is missing in mocha's d.ts, isn't it?
declare var mocha : Mocha; // Should not be called 'mocha', since that clashes
                           // with the (required) 'mocha'-div, but I didn't get
                           // that to work.
mocha = require('mocha');

chai = require('chai');
var expect = chai.expect;

import Adhocracy = require('Adhocracy');
import ProposalWorkbench = require('Adhocracy/Frames/ProposalWorkbench');
import Util = require('Adhocracy/Util');


mocha.setup({ui: 'bdd', slow: 30, timeout: 2000});

describe('something pure yet lame', function() {
    it('should half its input', function() {
        expect(ProposalWorkbench.something_pure(18)).to.equal(9);
    });
});

describe('some trivial DOM invariants', function() {
    it('must have three divs named appropriately', function() {
        expect($('#___probably_not_a_valid_dom_elem_id___')).to.have.length(0);
        expect($('#proposal_workbench_detail')).to.not.have.length(0);
        expect($('#proposal_workbench_directory')).to.not.have.length(0);
        expect($('#proposal_workbench_discussion')).to.not.have.length(0);
    });

    it('detail div must contain "..." after Adhocracy.init()', function() {
        Adhocracy.init();
        expect($('#proposal_workbench_detail')[0].innerText).to.equal('...');
    });

    describe('directory div must contain list of proposals as created by fixtures.js', function() {

        // FIXME: fixtures.js does not exist.  the following
        // should be slightly out of order, but the idea should be
        // valid.

        var expected_names;
        var directory_div;

        beforeEach(function(done) {
            ProposalWorkbench.open_proposals('/adhocracy/', function() {
                expected_names = ['proposal DAG 1', 'proposal DAG 2'];
                directory_div = $.makeArray($('#proposal_workbench_directory'))[0]
                done();
            });
        });

        it('list_items should contain the right proposal names.', function() {
            expected_names.forEach(function (name) {
                expect(directory_div.innerText).to.match(new RegExp(name));
            });
        });
    });
});

export function run_tests() {
    mocha.run(function() {});
};
{'fraction_non_alphanumeric': 0.15985064011379801, 'fraction_numerical': 0.008179231863442389, 'mean_word_length': 2.780241935483871, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7483817', 'n_tokens_mistral': 1697, 'n_tokens_neox': 1601, 'n_words': 349}