2017-10-13 15:35:47 +00:00
|
|
|
import './spinner.js';
|
|
|
|
|
|
|
|
describe('Component vnSpinner', () => {
|
|
|
|
let $scope;
|
|
|
|
let $element;
|
2017-10-17 12:24:40 +00:00
|
|
|
let controller;
|
2017-10-13 15:35:47 +00:00
|
|
|
|
2018-12-22 10:59:26 +00:00
|
|
|
beforeEach(ngModule('vnCore'));
|
2017-10-13 15:35:47 +00:00
|
|
|
|
2018-12-22 10:59:26 +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>');
|
2017-10-17 12:24:40 +00:00
|
|
|
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();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|