How to use angular-mocks - 10 common examples

To help you get started, we’ve selected a few angular-mocks examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bjaanes / ExtremeResults-WebApp / tests / unit / directive / userSettings.directive.spec.js View on Github external
describe('User Settings Directive', function () {

        var rootScope,
            httpBackend,
            compile;

        beforeEach(module('xr.settings'));
        beforeEach(inject(function ($rootScope, $compile, $httpBackend) {
            rootScope = $rootScope;
            compile = $compile;
            httpBackend = $httpBackend;

            $httpBackend.whenGET('settings/userSettings/userSettings.partial.html').respond(200, '');
        }));

        it('should compile', function () {
            var element = angular.element('');
            compile(element)(rootScope);
            rootScope.$digest();
            httpBackend.flush();
        });

    });
github bjaanes / ExtremeResults-WebApp / tests / unit / directive / createOutcome.directive.spec.js View on Github external
describe('Create Outcome Directive', function () {

        var rootScope,
            httpBackend,
            compile;

        beforeEach(function () {
            module('xr.outcomes', function ($controllerProvider) {
                $controllerProvider.register('CreateOutcomeController', function() {
                });
            });
        });
        beforeEach(inject(function ($rootScope, $compile, $httpBackend) {
            rootScope = $rootScope;
            compile = $compile;
            httpBackend = $httpBackend;

            $httpBackend.whenGET('outcomes/createOutcome/createOutcome.partial.html').respond(200, '');
        }));

        it('should compile', function () {
            var element = angular.element('');
            compile(element)(rootScope);
            rootScope.$digest();
            httpBackend.flush();
        });

    });
})();
github bjaanes / ExtremeResults-WebApp / tests / unit / service / editOutcomeEntry.service.spec.js View on Github external
describe('EditOutcomeEntryService', function(){

    var httpBackend,
        Urls,
        EditOutcomeEntryService;

    beforeEach(module('xr.entry'));
    beforeEach(inject(function($httpBackend, _EditOutcomeEntryService_, _Urls_) {
        httpBackend = $httpBackend;
        EditOutcomeEntryService = _EditOutcomeEntryService_;
        Urls = _Urls_;
    }));

    describe('editOutcome', function () {
        it('should return on success', function () {
            var objectId = '123';
            httpBackend.whenPUT(Urls.baseApi + 'outcomes/' + objectId).respond(201);

            var resolved = false;
            EditOutcomeEntryService.editOutcome(objectId)
                .then(function () {
                    resolved = true;
                });
github bjaanes / ExtremeResults-WebApp / tests / unit / controller / editOutcomeEntry.controller.spec.js View on Github external
confirm: function () {
                    return confirmMock;
                }
            };

            EditOutcomeEntryServiceMock = {
                editOutcome: function () {},
                deleteOutcome: function () {}
            };


            $provide.value('XrUtils', XrUtilsMock);
            $provide.value('$mdDialog', mdDialogMock);
            $provide.value('EditOutcomeEntryService', EditOutcomeEntryServiceMock);
        }));
        beforeEach(inject(function($controller, $q, $rootScope) {
            q = $q;
            rootScope = $rootScope;

            controller = $controller('EditOutcomeEntryController');
            controller.editCallback = function () {}
            controller.deleteCallback = function () {}
        }));

        describe('init', function () {

            it('should set up header', function() {
                expect(controller.header).toBe(headerMock + ' for ' + formattedDateMock);
            });

            it('should set saving to false', function () {
                expect(controller.saving).toBe(false);
github bjaanes / ExtremeResults-WebApp / tests / unit / controller / entryList.controller.spec.js View on Github external
describe('outcomes', function () {
            beforeEach(inject(function ($controller, $q, $rootScope) {
                q = $q;
                rootScope = $rootScope;

                initDeferred = q.defer();
                moreDeferred = q.defer();
                spyOn(EntryListServiceMock, 'getOutcomes').and.returnValues(initDeferred.promise, moreDeferred.promise);

                var data = {
                    className: 'Outcome'
                };
                controller = $controller('EntryListController', {}, data);
            }));

            describe('init', function () {

                it('should set set up with empty array of entries', function () {
github bjaanes / ExtremeResults-WebApp / tests / unit / directive / userInfo.directive.spec.js View on Github external
describe('UserInfo Directive', function () {

        var rootScope,
            httpBackend,
            compile;

        beforeEach(function () {
            module('xr.menuBar', function ($controllerProvider) {
                $controllerProvider.register('UserInfoController', function() {
                });
            });
        });
        beforeEach(inject(function ($rootScope, $compile, $httpBackend) {
            rootScope = $rootScope;
            compile = $compile;
            httpBackend = $httpBackend;

            $httpBackend.whenGET('menuBar/userInfo/userInfo.partial.html').respond(200, '');
        }));

        it('should compile', function () {
            var element = angular.element('');
            compile(element)(rootScope);
            rootScope.$digest();
            httpBackend.flush();
        });

    });
})();
github bjaanes / ExtremeResults-WebApp / tests / unit / service / entryList.service.spec.js View on Github external
describe('EntryList Service', function(){

    var httpBackend,
        Urls,
        EntryListService;

    beforeEach(module('xr.entryList'));
    beforeEach(inject(function($httpBackend, _EntryListService_, _Urls_) {
        httpBackend = $httpBackend;
        EntryListService = _EntryListService_;
        Urls = _Urls_;
    }));

    describe('getOutcomes', function () {
        it('should return data on success', function () {
            var response = {
                test: 'test'
            };
            httpBackend.whenGET(Urls.baseApi + 'outcomes?offset=0&limit=5').respond(200, response);

            var data;
            EntryListService.getOutcomes(0)
                .then(function (returnedData) {
                    data = returnedData;
github bjaanes / ExtremeResults-WebApp / tests / unit / controller / overview.controller.spec.js View on Github external
var controller,
            OverviewServiceMock,
            rootScope,
            initDeferred,
            q;

        beforeEach(module('xr.overview'));
        beforeEach(module(function ($provide) {

            OverviewServiceMock = {
                getActiveEntries: function () {}
            };

            $provide.value('OverviewService', OverviewServiceMock);
        }));
        beforeEach(inject(function($controller, $q, $rootScope) {
            q = $q;
            rootScope = $rootScope;

            initDeferred = q.defer();
            spyOn(OverviewServiceMock, 'getActiveEntries').and.returnValue(initDeferred.promise);

            controller = $controller('OverviewController');
        }));

        describe('init', function () {

            it('should set set up with empty array of active entries', function() {
                expect(controller.activeEntries).toBeDefined();
                expect(controller.activeEntries.length).toBe(0);
            });
github bjaanes / ExtremeResults-WebApp / tests / unit / controller / editReflectionEntry.controller.spec.js View on Github external
show: function () {},
                confirm: function () {
                    return confirmMock;
                }
            };

            EditReflectionEntryServiceMock = {
                editReflection: function () {},
                deleteReflection: function () {}
            };

            $provide.value('XrUtils', XrUtilsMock);
            $provide.value('$mdDialog', mdDialogMock);
            $provide.value('EditReflectionEntryService', EditReflectionEntryServiceMock);
        }));
        beforeEach(inject(function($controller, $q, $rootScope) {
            q = $q;
            rootScope = $rootScope;

            controller = $controller('EditReflectionEntryController');
            controller.editCallback = function () {};
            controller.deleteCallback = function () {};
        }));

        describe('init', function () {

            it('should set up header', function() {
                expect(controller.header).toBe(headerMock + ' for ' + formattedDateMock);
            });

            it('should set saving to false', function () {
                expect(controller.saving).toBe(false);
github bjaanes / ExtremeResults-WebApp / tests / unit / controller / reflectionEntry.controller.spec.js View on Github external
return formattedDateMock;
                }
            };

            deleteDelegate = {
                delete: function () {}
            };

            mdDialogMock = {
                show: function () {}
            };

            $provide.value('XrUtils', XrUtilsMock);
            $provide.value('$mdDialog', mdDialogMock);
        }));
        beforeEach(inject(function($controller, $q, $rootScope) {
            q = $q;
            rootScope = $rootScope;

            controller = $controller('ReflectionEntryController', {$scope: $rootScope});
            controller.deleteDelegate = deleteDelegate;
        }));

        describe('init', function () {

            it('should get and set header', function() {
                expect(controller.header).toBe(headerMock);
            });

            it('should get and set outcome time', function () {
                expect(controller.reflectionTime).toBe(formattedDateMock);
            });

angular-mocks

AngularJS mocks for testing

MIT
Latest version published 3 years ago

Package Health Score

67 / 100
Full package analysis