Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: appengine/config_service/ui/test/common/common-behaviors_test.html

Issue 2991013002: config_service: Added revision and timestamp to config-set-cards and config-set pages (Closed)
Patch Set: Refactored test to give each function its own suite Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!--
2 Copyright 2017 The LUCI Authors. All rights reserved.
3 Use of this source code is governed under the Apache License, Version 2.0
4 that can be found in the LICENSE file.
5 -->
6
7 <!doctype html>
8 <html lang="en">
9 <head>
10 <meta charset="utf-8">
11 <meta name="viewport" content="width=device-width, minimum-scale=1, initial- scale=1, user-scalable=yes">
12
13 <title>auth-signin test</title>
14
15 <script src="../../bower_components/webcomponentsjs/webcomponents-lite.js">< /script>
16 <script src="../../bower_components/web-component-tester/browser.js"></scrip t>
17
18 <link rel="import" href="../../src/config-ui/front-page.html">
19 </head>
20 <body>
21
22 <test-fixture id="common-behaviorsTestFixture">
23 <template>
24 <!-- The front-page element imports common-behaviors.html and has access to all methods -->
25 <front-page></front-page>
26 </template>
27 </test-fixture>
28
29 <script>
30
31 suite('_formatDate', function() {
32 var common;
33 setup(function() {
34 common = fixture('common-behaviorsTestFixture');
35 });
36
37 test('returns proper amount of time passed', function () {
38 // LUCI Config API formats timestamps in microseconds, so we multiply by 1000
39 var date = (new Date() - 5000) * 1000;
40 expect(common._formatDate(date)).to.be.equal("5 seconds ago");
41 expect(common._formatDate(null)).to.be.equal("Not Found");
42 });
43 });
44
45 suite('_formatRevision', function() {
46 var common;
47 setup(function() {
48 common = fixture('common-behaviorsTestFixture');
49 });
50
51 test('returns the first 7 characters of the revision number', function() {
52 expect(common._formatRevision('6c6d27675a369a7010f742aa456db0d3d0b7b09 4'))
53 .to.be.equal('6c6d276');
54 expect(common._formatRevision("Not Found")).to.be.equal("Not Found");
55 });
56 });
57
58 suite('_getExactTime', function() {
59 var common;
60 setup(function() {
61 common = fixture('common-behaviorsTestFixture');
62 });
63
64 test('formats timestamps into full dates', function() {
65 var date = common._getExactTime(1501507037000000);
66 var realDate = new Date(1501507037000);
67 assert.equal(date, realDate.toString());
68
69 expect(common._getExactTime(null)).to.be.equal("Not Found");
70 });
71 }),
72
73 suite('_getTimestamp', function() {
74 var common;
75 setup(function() {
76 common = fixture('common-behaviorsTestFixture');
77 });
78
79 test('returns the correct timestamp when lastImportAttempt is successful ', function() {
80 var lastImportAttempt = {
81 "success": true,
82 "revision": {
83 "timestamp": "09061997"
84 }
85 }
86 expect(common._getTimestamp(lastImportAttempt, null)).to.be.equal('090 61997');
87 });
88
89 test('returns the correct timestamp when lastImportAttempt is unsuccessf ul', function() {
90 var lastImportAttempt = {
91 "success": false
92 }
93 var revision = {
94 "timestamp": "12345"
95 }
96 expect(common._getTimestamp(lastImportAttempt, revision)).to.be.equal( '12345');
97 });
98
99 test('returns the correct timestamp when lastImportAttempt is unsuccessf ul' +
100 ' and revision is null', function() {
101 expect(common._getTimestamp(null, null)).to.be.null;
102 });
103 });
104 </script>
105 </body>
106 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698