main.controller.spec.js
1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
(function() {
'use strict';
describe('controllers', function(){
var vm;
var $timeout;
var toastr;
beforeEach(module('angular'));
beforeEach(inject(function(_$controller_, _$timeout_, _webDevTec_, _toastr_) {
spyOn(_webDevTec_, 'getTec').and.returnValue([{}, {}, {}, {}, {}]);
spyOn(_toastr_, 'info').and.callThrough();
vm = _$controller_('MainController');
$timeout = _$timeout_;
toastr = _toastr_;
}));
it('should have a timestamp creation date', function() {
expect(vm.creationDate).toEqual(jasmine.any(Number));
});
it('should define animate class after delaying timeout ', function() {
$timeout.flush();
expect(vm.classAnimation).toEqual('rubberBand');
});
it('should show a Toastr info and stop animation when invoke showToastr()', function() {
vm.showToastr();
expect(toastr.info).toHaveBeenCalled();
expect(vm.classAnimation).toEqual('');
});
it('should define more than 5 awesome things', function() {
expect(angular.isArray(vm.awesomeThings)).toBeTruthy();
expect(vm.awesomeThings.length === 5).toBeTruthy();
});
});
})();