Skip to content

Commit 23760b4

Browse files
committed
working on unit test
1 parent 78bc1bf commit 23760b4

File tree

7 files changed

+24
-91
lines changed

7 files changed

+24
-91
lines changed

config/karma.conf.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ basePath = '../';
33
files = [
44
JASMINE,
55
JASMINE_ADAPTER,
6-
'app/lib/angular/angular.js',
7-
'app/lib/angular/angular-*.js',
6+
'angular/angular.js',
7+
'angular/angular-*.js',
88
'test/lib/angular/angular-mocks.js',
99
'app/js/**/*.js',
1010
'test/unit/**/*.js'

index.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8">
5-
<title>Angular Timer Directive, a simple AngularJS directive demonstrating its usefulness</title>
5+
<title>Angular Timer, a simple, inter-operable AngularJS directive</title>
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<meta name="description" content="">
88

@@ -72,6 +72,7 @@
7272
<li><a href="#formatted-timer">Formatted Timer</a></li>
7373
</ul>
7474
</li>
75+
<li><a href="#introduction">Markup Reference</a></li>
7576
<li class="dropdown">
7677
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Usage <b class="caret"></b></a>
7778
<ul class="dropdown-menu">
@@ -91,13 +92,13 @@
9192
<h1>Introduction</h1>
9293
<p>Directives in <a target="_new" href="http://angularjs.org">AngularJS</a> is a powerful way of building reusable <em>UI components</em>.
9394
This simple project will serve as a sample/reference implementation demonstrating its
94-
flexibilities by making it usable across runtime (AngularJS, plain simple JavaScript & jQuery)</p>
95-
95+
flexibilities by making it <em>inter-operable</em> across runtime (AngularJS, plain simple JavaScript & jQuery)</p>
9696
</section>
97+
9798
<section id="basic-example">
9899
<h3>Basic Example</h3>
99100
<div class="bs-docs-example">
100-
<p>This simple directive <code>&lt;timer /&gt;</code> markup code will start the timer with the default option of ticking every 1 millisecond</p>
101+
<p>This simple directive <code>&lt;timer /&gt;</code> will start the timer with the default option of ticking every 1 millisecond</p>
101102
<h3><timer id="timer1"/></h3>
102103
<button type="button" class="btn" onclick="startTimer('timer1', this)">Start</button>
103104
<button type="button" class="btn" onclick="stopTimer('timer1', this)">Stop</button>

test/lib/angular/version.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/unit/controllersSpec.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

test/unit/directivesSpec.js

Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,26 @@
22

33
/* jasmine specs for directives go here */
44

5-
describe('directives', function() {
6-
beforeEach(module('myApp.directives'));
5+
describe('timer directive', function() {
6+
beforeEach(module('timer'));
77

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();
1623
});
1724
});
1825
});
1926

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-
});
4527
});

test/unit/filtersSpec.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

test/unit/servicesSpec.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)