<commit_before>describe('The Query component', function() {

    beforeEach(module('app'));

    beforeEach(module(function($provide) {
        $provide.factory('config', function($q) {
            var get = function() {
                return $q.when({});
            }

            return {
                get: get
            }
        });

        $provide.factory('schema', function($q) {
            return {
                get: function() {
                    return $q.when({});
                }
            }
        });
    }));

    describe('The Controller', function() {
        var $componentController;
        var queryPage, query, loading, graph, settings;

        beforeEach(inject(function(_$componentController_, _queryPage_, _query_, _loading_, _graph_, _settings_, _navigation_) {
            $componentController = _$componentController_;
            queryPage = _queryPage_;
            query = _query_;
            loading = _loading_;
            graph = _graph_;
            settings = _settings_;
        }));

        it('should exist', function() {
            var ctrl = $componentController('query');
            expect(ctrl).toBeDefined();
        })

        it('should expose the getSelectedOperation of the queryPage service', function() {
            spyOn(queryPage, 'getSelectedOperation');

            var ctrl = $componentController('query');

            ctrl.getSelectedOp();

            expect(queryPage.getSelectedOperation).toHaveBeenCalledTimes(1);
        });

        describe('When validating the query', function() {

            it('should not allow execution if the selected operation is undefined', function() {
                var ctrl = $componentController('query');
                expect(ctrl.canExecute()).toBeFalsy();
            });

            it('should not allow execution if the selected operation is defined but results are loading', function() {
                var ctrl = $componentController('query');
                queryPage.setSelectedOperation('some operation');
                loading.load();

                expect(ctrl.canExecute()).toBeFalsy();
            });

            it('should allow execution if the selected operation is defined and the loading completes', function() {
                var ctrl = $componentController('query');
                queryPage.setSelectedOperation('some operation');

                loading.load();
                loading.finish();
                expect(ctrl.canExecute()).toBeTruthy();
            });

            it('should allow execution if the selected operation is defined and loading has not started', function() {
                var ctrl = $componentController('query');
                queryPage.setSelectedOperation('some operation');

                expect(ctrl.canExecute()).toBeTruthy();

            });
        });
<commit_msg>gh-340 updated unit tests<commit_after>describe('The Query component', function() {

    beforeEach(module('app'));

    beforeEach(module(function($provide) {
        $provide.factory('config', function($q) {
            var get = function() {
                return $q.when({});
            }

            return {
                get: get
            }
        });

        $provide.factory('schema', function($q) {
            return {
                get: function() {
                    return $q.when({});
                }
            }
        });
    }));

    describe('The Controller', function() {
        var $componentController;
        var queryPage, query, loading, graph, settings;

        beforeEach(inject(function(_$componentController_, _queryPage_, _query_, _loading_, _graph_, _settings_, _navigation_) {
            $componentController = _$componentController_;
            queryPage = _queryPage_;
            query = _query_;
            loading = _loading_;
            graph = _graph_;
            settings = _settings_;
        }));

        it('should exist', function() {
            var ctrl = $componentController('query');
            expect(ctrl).toBeDefined();
        })

        it('should expose the getSelectedOperation of the queryPage service', function() {
            spyOn(queryPage, 'getSelectedOperation');

            var ctrl = $componentController('query');

            ctrl.getSelectedOp();

            expect(queryPage.getSelectedOperation).toHaveBeenCalledTimes(1);
        });

        describe('When validating the query', function() {
            var ctrl;
            var valid;
            var selectedOperation;

            beforeEach(function() {
                ctrl = $componentController('query');
                ctrl.queryForm = {
                    $valid: valid
                };
            });

            beforeEach(function() {
                valid = true;
            });

            beforeEach(function() {
                spyOn(queryPage, 'getSelectedOperation').and.callFake(function() {
                    return selectedOperation;
                });
            });

            beforeEach(function() {
                selectedOperation = "some operation"
            });

            it('should not allow execution if the form is invalid', function() {
                valid = false
                expect(ctrl.canExecute()).toBeFalsy();
            });

            it('should not allow execution if the selected operation is defined but results are loading', function() {
                valid = true;
                loading.load();

                expect(ctrl.canExecute()).toBeFalsy();
            });

            it('should allow execution if the selected operation is defined and the loading completes', function() {
                valid = true;

                loading.load();
                loading.finish();
                expect(ctrl.canExecute()).toBeTruthy();
            });

            it('should allow execution if the selected operation is defined and loading has not started', function() {
                valid = true;
                expect(ctrl.canExecute()).toBeTruthy();

            });
        });

{'fraction_non_alphanumeric': 0.1113662456946039, 'fraction_numerical': 0.0008200754469411186, 'mean_word_length': 1.6922737306843267, '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': '7145682', 'n_tokens_mistral': 1421, 'n_tokens_neox': 1330, 'n_words': 338}