malarkey.directive.spec.js
1.24 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
40
41
42
43
44
45
(function() {
'use strict';
/**
* @todo Complete the test
* This example is not perfect.
* The `link` function is not tested.
* (malarkey usage, addClass, $watch, $destroy)
*/
describe('directive malarkey', function() {
var $log;
var vm;
var el;
beforeEach(module('angular'));
beforeEach(inject(function($compile, $rootScope, githubContributor, $q, _$log_) {
$log = _$log_;
spyOn(githubContributor, 'getContributors').and.callFake(function() {
return $q.when([{}, {}, {}, {}, {}, {}]);
});
el = angular.element('<acme-malarkey extra-values="[\'Poney\', \'Monkey\']"></acme-malarkey>');
$compile(el)($rootScope.$new());
$rootScope.$digest();
vm = el.isolateScope().vm;
}));
it('should be compiled', function() {
expect(el.html()).not.toEqual(null);
});
it('should have isolate scope object with instanciate members', function() {
expect(vm).toEqual(jasmine.any(Object));
expect(vm.contributors).toEqual(jasmine.any(Array));
expect(vm.contributors.length).toEqual(6);
});
it('should log a info', function() {
expect($log.info.logs).toEqual(jasmine.stringMatching('Activated Contributors View'));
});
});
})();