Skip to content

Commit 06d0507

Browse files
committed
working on unit test
1 parent 23760b4 commit 06d0507

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

test/unit/directivesSpec.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,18 @@ describe('timer directive', function() {
88
describe('default timer', function() {
99
it('should run timer with 1 millisecond interval', function() {
1010

11-
inject(function($compile, $rootScope, $browser, $timeout) {
11+
inject(function($compile, $rootScope, $browser, $timeout, $exceptionHandler) {
1212
var $scope = $rootScope.$new();
1313
var element = $compile('<timer/>')($scope);
14+
$scope.$digest();
1415
$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+
expect(element.html()).toMatch(/^<span class="ng-scope ng-binding">/);
17+
expect(element.html().indexOf('</span>')).toBeGreaterThan(-1);
18+
$rootScope.$broadcast('timer-stop');
19+
}, 300);
20+
$timeout.flush();
21+
expect($exceptionHandler.errors).toEqual(undefined);
2322
});
2423
});
2524
});
26-
2725
});

0 commit comments

Comments
 (0)