salix/front/core/components/spinner/spinner.spec.js

62 lines
2.2 KiB
JavaScript
Raw Normal View History

2017-10-13 15:35:47 +00:00
import './spinner.js';
describe('Component vnSpinner', () => {
let $scope;
let $element;
let controller;
2017-10-13 15:35:47 +00:00
2019-09-13 14:09:14 +00:00
beforeEach(angular.mock.module('vnCore', $translateProvider => {
$translateProvider.translations('en', {});
}));
2017-10-13 15:35:47 +00:00
beforeEach(angular.mock.inject(($componentController, $rootScope) => {
2017-10-13 15:35:47 +00:00
$scope = $rootScope.$new();
$element = angular.element('<div><div></div></div>');
controller = $componentController('vnSpinner', {$scope, $element});
2017-10-13 15:35:47 +00:00
}));
describe('enable()', () => {
it(`should call start() based on a boolean value passed as argument`, () => {
spyOn(controller, 'start');
spyOn(controller, 'stop');
controller.enable = true;
expect(controller.start).toHaveBeenCalledWith();
expect(controller.stop).not.toHaveBeenCalledWith();
});
it(`should call stop() based on a boolean value passed as argument`, () => {
spyOn(controller, 'start');
spyOn(controller, 'stop');
controller.enable = false;
expect(controller.start).not.toHaveBeenCalledWith();
expect(controller.stop).toHaveBeenCalledWith();
});
});
describe('start()', () => {
it(`should call start() on the controller.materialSpinner then set controllers._enable to be truthy`, () => {
controller.spinner = {MaterialSpinner: {start: () => {}}};
spyOn(controller.spinner.MaterialSpinner, 'start');
controller._enable = false;
controller.start();
expect(controller.spinner.MaterialSpinner.start).toHaveBeenCalledWith();
expect(controller._enable).toBeTruthy();
});
});
describe('stop()', () => {
it(`should call stop() on the controller.materialSpinner then set controllers._enable to be truthy`, () => {
controller.spinner = {MaterialSpinner: {stop: () => {}}};
spyOn(controller.spinner.MaterialSpinner, 'stop');
controller._enable = true;
controller.stop();
expect(controller.spinner.MaterialSpinner.stop).toHaveBeenCalledWith();
expect(controller._enable).toBeFalsy();
});
});
});