<commit_before>'use strict';
/*jshint -W079 */

var _, describe, beforeEach, afterEach, it, inject, expect, sinon;

describe('rgiQuestionAdminCtrl', function () {
    beforeEach(module('app'));

    var $scope, ngDialog, rgiQuestionSrvc, questionQueryStub, questionQuerySpy,
        questionsData = [
            {
                question_order: 'QUESTION ORDER',
                question_text: 'QUESTION TEXT',
                component_text: 'COMPONENT TEXT',
                indicator_name: 'INDICATOR NAME',
                sub_indicator_name: 'SUBINDICATOR NAME',
                minstry_if_applicable: 'MINISTRY IF APPLICABLE',
                section_name: 'SECTION NAME',
                child_question: 'CHILD QUESTION',
                nrc_precept: 'NRC PRECEPT',
                question_choices: [
                    {name: 'Yes', criteria: 'yes'},
                    {name: 'No', criteria: 'no'}
                ]
            }
        ];

    beforeEach(inject(
        function ($rootScope, $controller, _ngDialog_, _rgiQuestionSrvc_) {
            ngDialog = _ngDialog_;
            rgiQuestionSrvc = _rgiQuestionSrvc_;
            $scope = $rootScope.$new();
            /*jshint unused: true*/
            /*jslint unparam: true*/
            questionQuerySpy = sinon.spy(function (uselessObject, callback) {
                callback(questionsData);
            });
            /*jshint unused: false*/
            /*jslint unparam: false*/
            questionQueryStub = sinon.stub(rgiQuestionSrvc, 'query', questionQuerySpy);

            $controller('rgiQuestionAdminCtrl', {$scope: $scope});
        }
    ));

    it('initializes sorting options', function () {
        _.isEqual($scope.sort_options, [
            {value: "question_order", text: "Sort by Question Order"},
            {value: "component_text", text: "Sort by Component"},
            {value: "status", text: "Sort by Status"}
        ]).should.be.equal(true);
    });

    it('initializes sorting order', function () {
        $scope.sort_order.should.be.equal('question_order');
    });

    it('sets the header', function () {
        _.isEqual([
            'Question Order',
            'Question Text',
            'Component Text',
            'Indicator Name',
            'Subindicator Name',
            'Ministry', 'Section',
            'Child Question',
            'NRC Precept'
        ], $scope.header).should.be.equal(true);
    });

    it('loads the question data', function () {
        _.isEqual($scope.questions, questionsData).should.be.equal(true);
    });

    it('transforms the loaded question data', function () {
        _.isEqual([
            {
                question_order: 'QUESTION ORDER',
                question_text: 'QUESTION TEXT',
                component_text: 'COMPONENT TEXT',
                indicator_name: 'INDICATOR NAME',
                sub_indicator_name: 'SUBINDICATOR NAME',
                minstry_if_applicable: 'MINISTRY IF APPLICABLE',
                section_name: 'SECTION NAME',
                child_question: 'CHILD QUESTION',
                nrc_precept: 'NRC PRECEPT',
                choice_0: 'Yes',
                choice_0_criteria: 'yes',
                choice_1: 'No',
                choice_1_criteria: 'no'
            }
        ], $scope.getArray).should.be.equal(true);
    });

    describe('#newQuestionDialog', function () {
        it('sets the value to TRUE', function () {
            $scope.newQuestionDialog();
            $scope.value.should.be.equal(true);
        });

        it('opens a dialog', function () {
            var ngDialogMock = sinon.mock(ngDialog);
            ngDialogMock.expects('open').withArgs({
                template: 'partials/dialogs/new-question-dialog',
                controller: 'rgiNewQuestionDialogCtrl',
                className: 'ngdialog-theme-plain dialogwidth800',
                scope: $scope
            });

            $scope.newQuestionDialog();

            ngDialogMock.verify();
            ngDialogMock.restore();
        });

    });

    afterEach(function () {
        questionQueryStub.restore();
    });
});
<commit_msg>fix the test suite on question admin controller<commit_after>'use strict';

describe('rgiQuestionAdminCtrl', function () {
    beforeEach(module('app'));

    var $scope, ngDialog, rgiDialogFactory, rgiQuestionSrvc, questionQueryStub, questionQuerySpy,
        questionsData = [
            {
                question_order: 'QUESTION ORDER',
                question_text: 'QUESTION TEXT',
                component_text: 'COMPONENT TEXT',
                indicator_name: 'INDICATOR NAME',
                sub_indicator_name: 'SUBINDICATOR NAME',
                minstry_if_applicable: 'MINISTRY IF APPLICABLE',
                section_name: 'SECTION NAME',
                child_question: 'CHILD QUESTION',
                nrc_precept: 'NRC PRECEPT',
                question_choices: [
                    {name: 'Yes', criteria: 'yes'},
                    {name: 'No', criteria: 'no'}
                ]
            }
        ];

    beforeEach(inject(
        function ($rootScope, $controller, _ngDialog_, _rgiDialogFactory_, _rgiQuestionSrvc_) {
            ngDialog = _ngDialog_;
            rgiDialogFactory = _rgiDialogFactory_;
            rgiQuestionSrvc = _rgiQuestionSrvc_;
            $scope = $rootScope.$new();
            /*jshint unused: true*/
            /*jslint unparam: true*/
            questionQuerySpy = sinon.spy(function (uselessObject, callback) {
                callback(questionsData);
            });
            /*jshint unused: false*/
            /*jslint unparam: false*/
            questionQueryStub = sinon.stub(rgiQuestionSrvc, 'query', questionQuerySpy);

            $controller('rgiQuestionAdminCtrl', {$scope: $scope});
        }
    ));

    it('initializes sorting options', function () {
        $scope.sort_options.should.deep.equal([
            {value: 'question_order', text: 'Sort by Question Order'},
            {value: 'component_text', text: 'Sort by Component'},
            {value: 'question_text', text: 'Sort by Question Text'}
        ]);
    });

    it('initializes sorting order', function () {
        $scope.sort_order.should.be.equal('question_order');
    });

    it('sets the header', function () {
        $scope.header.should.deep.equal([
            'Question Order',
            'Question Text',
            'Component Text',
            'Indicator Name',
            'Subindicator Name',
            'Ministry', 'Section',
            'Child Question',
            'NRC Precept'
        ]);
    });

    it('loads the question data', function () {
        $scope.questions.should.deep.equal(questionsData);
    });

    it('transforms the loaded question data', function () {
        $scope.getArray.should.deep.equal([
            {
                question_order: 'QUESTION ORDER',
                question_text: 'QUESTION TEXT',
                component_text: 'COMPONENT TEXT',
                indicator_name: 'INDICATOR NAME',
                sub_indicator_name: 'SUBINDICATOR NAME',
                minstry_if_applicable: 'MINISTRY IF APPLICABLE',
                section_name: 'SECTION NAME',
                child_question: 'CHILD QUESTION',
                nrc_precept: 'NRC PRECEPT',
                choice_0: 'Yes',
                choice_0_criteria: 'yes',
                choice_1: 'No',
                choice_1_criteria: 'no'
            }
        ]);
    });

    describe('#newQuestionDialog', function () {
        it('opens a dialog', function () {
            var ngDialogMock = sinon.mock(rgiDialogFactory);
            ngDialogMock.expects('questionNew').withArgs($scope);

            $scope.newQuestionDialog();

            ngDialogMock.verify();
            ngDialogMock.restore();
        });

    });

    afterEach(function () {
        questionQueryStub.restore();
    });
});

{'fraction_non_alphanumeric': 0.12023165050988291, 'fraction_numerical': 0.0017625582273700113, 'mean_word_length': 1.828052687789249, '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': '2495663', 'n_tokens_mistral': 2245, 'n_tokens_neox': 2109, 'n_words': 441}