<commit_before>/*jshint multistr: true */
require([
    'tests/options',
    'tests/utils',
    'chai',
    'jquery',
    'underscore',
    'vellum/itemset',
    'vellum/form'
], function (
    options,
    util,
    chai,
    $,
    _,
    itemset,
    form
) {

    // see note about controlling time in formdesigner.lock.js
    var assert = chai.assert,
        clickQuestion = util.clickQuestion,
        plugins = _.union(util.options.options.plugins || [], ["itemset"]),
        NUM_FIXTURE_OPTIONS = 3, // Will need to change as tests/options is updated
        NUM_OPTIONS = NUM_FIXTURE_OPTIONS; 

    describe("The data source widget", function () {
        function beforeFn(done) {
            util.init({
                plugins: plugins,
                javaRosa: {langs: ['en']},
                core: {onReady: done}
            });
        }
        before(beforeFn);

        it("displays nested structures", function() {
            util.loadXML("");
            util.addQuestion("SelectDynamic", "select1");
            clickQuestion('select1/itemset');
            assert.equal($('[name=property-itemsetData] option').size(), NUM_OPTIONS);
        });

        it("does not show options with no_option specified", function() {
            util.loadXML("");
            util.addQuestion("SelectDynamic", "select1");
            clickQuestion('select1/itemset');
            assert.equal($('[name=property-itemsetData] option').size(), NUM_OPTIONS);
        });

        it("displays pretty names specified with name attribute", function() {
            util.loadXML("");
            util.addQuestion("SelectDynamic", "select1");
            clickQuestion('select1/itemset');
            assert.equal($('[name=property-itemsetData] option').first().text(), 'some-fixture-name');
        });


        describe("", function() {
            before(function(done) {
                util.init({
                    plugins: plugins,
                    javaRosa: {langs: ['en']},
                    core: {
                        dataSources: [{
                            key: 'fixture',<commit_msg>Clean up data source tests<commit_after>/*jshint multistr: true */
require([
    'tests/options',
    'tests/utils',
    'chai',
    'jquery',
    'underscore',
    'vellum/itemset',
    'vellum/form'
], function (
    options,
    util,
    chai,
    $,
    _,
    itemset,
    form
) {
    var assert = chai.assert,
        clickQuestion = util.clickQuestion,
        plugins = _.union(util.options.options.plugins || [], ["itemset"]),
        FIXTURE_DATA = [{
            sourceUri: "jr://fixture/item-list:some-fixture",
            defaultId: "some-fixture",
            initialQuery: "instance('some-fixture')/some-fixture_list/some-fixture",
            name: 'some-fixture-name',
            structure: {
                "inner-attribute": {
                    structure: {
                        "extra-inner-attribute": {}
                    }
                },
                "@id": {no_option: true},
                name: {no_option: true}
            }
        }];

    describe("The data source widget", function () {
        function beforeFn(done) {
            util.init({
                plugins: plugins,
                javaRosa: {langs: ['en']},
                core: {
                    dataSources: [{
                        key: "fixture",
                        name: "Lookup Table",
                        endpoint: function () { return FIXTURE_DATA; }
                    }],
                    onReady: done
                }
            });
        }
        before(beforeFn);

        it("displays nested structures", function() {
            util.loadXML("");
            util.addQuestion("SelectDynamic", "select1");
            clickQuestion('select1/itemset');
            var opts = $('[name=property-itemsetData] option'),
                text = function (opt) { return opt.text; };
            assert.equal(_.map(opts, text).join("\n"), [
                "some-fixture-name",
                "some-fixture-name - inner-attribute",
                "some-fixture-name - inner-attribute - extra-inner-attribute",
            ].join("\n"));
        });

        describe("", function() {
            before(function(done) {
                util.init({
                    plugins: plugins,
                    javaRosa: {langs: ['en']},
                    core: {
                        dataSources: [{
                            key: 'fixture',
{'fraction_non_alphanumeric': 0.13877189093327422, 'fraction_numerical': 0.0019951230325870096, 'mean_word_length': 1.5206703910614525, 'pattern_counts': {'":': 3, '<': 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': '7421129', 'n_tokens_mistral': 1240, 'n_tokens_neox': 1185, 'n_words': 228}