Skip to content

Commit 2f927eb

Browse files
committed
Add e2e test for the end-time attribute feature.
1 parent 133a74d commit 2f927eb

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

index.html

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,20 @@ <h3>
7979
<button class="btn" onclick="stopResumeTimer('timer-with-start-time', this)" type="button">Stop</button>
8080
</div>
8181
</section>
82+
<section id="timer-with-end-time">
83+
<h3>
84+
Timer initialised with some predefined end time.</h3>
85+
86+
<div class="bs-docs-example">
87+
<p>
88+
Following is the countdown timer setting for the days, hours, minutes & seconds to <b>January 1, 2014 (GMT-6) </b>
89+
<p class="muted">(01 Jan 2014 06:00:00 GMT = 1388556000000 milliseconds)</p>
90+
<code ng-non-bindable="">&lt;timer end-time=&quot;1388556000000&quot; interval=&quot;1000&quot;&gt;{{days}} days, {{hours}} hours, {{minutes}} minutes, {{seconds}} seconds.&lt;/timer&gt;</code>
91+
<h3>
92+
<timer end-time="1388556000000" interval="1000">{{days}} days, {{hours}} hours, {{minutes}} minutes, {{seconds}} seconds.</timer>
93+
</h3>
94+
</div>
95+
</section>
8296
<section id="progressbar-timer">
8397
<h3>
8498
Progressbar Timer</h3>
@@ -315,4 +329,4 @@ <h3>
315329
<script src="docs/prettify.js"></script>
316330
<script src="docs/application.js"></script>
317331
</body>
318-
</html>
332+
</html>

test/e2e/scenarios.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ describe('Angular Timer E2E Tests', function () {
1111
};
1212
});
1313

14+
angular.scenario.matcher('toHaveMoreSecondsThan', function(future) {
15+
function extractTime(value){
16+
return value.match(/\b\d+\b/g);
17+
}
18+
function totalSeconds(value) {
19+
return value[0]*3600*24 + value[1]*3600 + value[2]*60 + value[3];
20+
}
21+
var actualValue = extractTime(this.actual)
22+
var futureValue = extractTime(future.value);
23+
return totalSeconds(actualValue) > totalSeconds(futureValue);
24+
});
25+
1426
beforeEach(function () {
1527
if (window.location.host.indexOf("github.io") > -1) {
1628
browser().navigateTo('/angular-timer/index.html');
@@ -60,4 +72,11 @@ describe('Angular Timer E2E Tests', function () {
6072
expect(element('#auto-start-false-timer timer span').html()).toBeGreaterThan(0);
6173
expect(element('#auto-start-false-timer timer span').html()).toBeLessThan(100);
6274
});
75+
76+
it('End Time Timer - Ends at beginning of 2014', function () {
77+
var beforeTime = element('#timer-with-end-time timer span').html();
78+
sleep(3);
79+
var afterTime = element('#timer-with-end-time timer span').html();
80+
expect(beforeTime).toHaveMoreSecondsThan(afterTime);
81+
});
6382
});

0 commit comments

Comments
 (0)