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

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: Added test file and null check to _formatCategory in config-set to fix failing test 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('unit test each function in common-behaviors.html', function() {
Sergey Berezin 2017/08/01 18:51:11 Suggestion: create a separate suite for each metho
cwpayton 2017/08/01 19:18:49 Done.
32 var common;
33 setup(function() {
34 common = fixture('common-behaviorsTestFixture');
Sergey Berezin 2017/08/01 18:51:11 Is it needed? The methods under test don't access
cwpayton 2017/08/01 19:18:49 This is needed because the CommonBehaviors are imp
35 });
36
37 test('formatDate returns the 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 test('formatRevision returns the first 7 characters of the revision numb er', function() {
45 expect(common._formatRevision('6c6d27675a369a7010f742aa456db0d3d0b7b09 4'))
46 .to.be.equal('6c6d276');
47 expect(common._formatRevision("Not Found")).to.be.equal("Not Found");
48 });
49
50 test('getExactTime formats timestamps into full dates', function() {
51 var date = common._getExactTime(1501507037000000);
52 var realDate = new Date(1501507037000);
53 assert.equal(date, realDate.toString());
54
55 expect(common._getExactTime(null)).to.be.equal("Not Found");
56 });
57
58 test('getTimestamp returns the correct timestamp when lastImportAttempt is successful', function() {
59 var lastImportAttempt = {
60 "success": true,
61 "revision": {
62 "timestamp": "09061997"
63 }
64 }
65 expect(common._getTimestamp(lastImportAttempt, null)).to.be.equal('090 61997');
66 });
67
68 test('getTimestamp returns the correct timestamp when lastImportAttempt is unsuccessful', function() {
69 var lastImportAttempt = {
70 "success": false
71 }
72 var revision = {
73 "timestamp": "12345"
74 }
75 expect(common._getTimestamp(lastImportAttempt, revision)).to.be.equal( '12345');
76 });
77
78 test('getTimestamp returns the correct timestamp when lastImportAttempt is unsuccessful' +
79 ' and revision is null', function() {
80 expect(common._getTimestamp(null, null)).to.be.null;
81 });
82 });
83 </script>
84 </body>
85 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698