|
2 | 2 |
|
3 | 3 | /* jasmine specs for directives go here */ |
4 | 4 |
|
5 | | -describe('directives', function() { |
6 | | - beforeEach(module('myApp.directives')); |
| 5 | +describe('timer directive', function() { |
| 6 | + beforeEach(module('timer')); |
7 | 7 |
|
8 | | - describe('app-version', function() { |
9 | | - it('should print current version', function() { |
10 | | - module(function($provide) { |
11 | | - $provide.value('version', 'TEST_VER'); |
12 | | - }); |
13 | | - inject(function($compile, $rootScope) { |
14 | | - var element = $compile('<span app-version></span>')($rootScope); |
15 | | - expect(element.text()).toEqual('TEST_VER'); |
| 8 | + describe('default timer', function() { |
| 9 | + it('should run timer with 1 millisecond interval', function() { |
| 10 | + |
| 11 | + inject(function($compile, $rootScope, $browser, $timeout) { |
| 12 | + var $scope = $rootScope.$new(); |
| 13 | + var element = $compile('<timer/>')($scope); |
| 14 | + $timeout(function() { |
| 15 | + console.log('######### $scope = ', element.html()); |
| 16 | + console.log('########## $scope.startTime = ', $scope.startTime); |
| 17 | + }, 100); |
| 18 | + $timeout(function() { |
| 19 | + console.log('######### $scope = ', element.html()); |
| 20 | + console.log('########## $scope.startTime = ', $scope.startTime); |
| 21 | + }, 200); |
| 22 | + $browser.defer.flush(); |
16 | 23 | }); |
17 | 24 | }); |
18 | 25 | }); |
19 | 26 |
|
20 | | - describe('Unit testing great quotes', function() { |
21 | | - var $compile; |
22 | | - var $rootScope; |
23 | | - |
24 | | - // Load the myApp module, which contains the directive |
25 | | - beforeEach(module('myApp')); |
26 | | - |
27 | | - // Store references to $rootScope and $compile |
28 | | - // so they are available to all tests in this describe block |
29 | | - beforeEach(inject(function(_$compile_, _$rootScope_){ |
30 | | - // The injector unwraps the underscores (_) from around the parameter names when matching |
31 | | - $compile = _$compile_; |
32 | | - $rootScope = _$rootScope_; |
33 | | - })); |
34 | | - |
35 | | - it('Replaces the element with the appropriate content', function() { |
36 | | - // Compile a piece of HTML containing the directive |
37 | | - var element = $compile("<a-great-eye></a-great-eye>")($rootScope); |
38 | | - // fire all the watches, so the scope expression {{1 + 1}} will be evaluated |
39 | | - $rootScope.$digest(); |
40 | | - // Check that the compiled element contains the templated content |
41 | | - console.log('####### require = ', require); |
42 | | - expect(element.html()).toContain("lidless, wreathed in flame, 2 times"); |
43 | | - }); |
44 | | - }); |
45 | 27 | }); |
0 commit comments