OLD | NEW |
1 <!-- | 1 <!-- |
2 Copyright 2014 The Chromium Authors. All rights reserved. | 2 Copyright 2014 The Chromium Authors. All rights reserved. |
3 Use of this source code is governed by a BSD-style license that can be | 3 Use of this source code is governed by a BSD-style license that can be |
4 found in the LICENSE file. | 4 found in the LICENSE file. |
5 --> | 5 --> |
6 | 6 |
7 <link rel="import" href="ct-tree-status.html"> | 7 <link rel="import" href="tree-status.html"> |
8 | 8 |
9 <script> | 9 <script> |
| 10 |
10 (function () { | 11 (function () { |
11 | 12 |
12 module("ct-tree-status"); | 13 module("tree-status"); |
13 | 14 |
14 openTreeJson = { | 15 var openTreeJson = { |
| 16 "username": "erg@chromium.org", |
| 17 "date": "2013-10-14 20:22:00.887390", |
| 18 "message": "Tree is open", |
| 19 "can_commit_freely": true, |
| 20 "general_state": "open" |
| 21 }; |
| 22 |
| 23 var throttledTreeJson = { |
15 "username": "username@test.org", | 24 "username": "username@test.org", |
16 "message": "Tree is open", | 25 "date": "2013-10-14 20:22:00.887390", |
17 "can_commit_freely": true | |
18 } | |
19 | |
20 throttledTreeJson = { | |
21 "username": "username@test.org", | |
22 "message": "Tree is throttled just for fun", | 26 "message": "Tree is throttled just for fun", |
23 "can_commit_freely": false | 27 "can_commit_freely": false |
24 } | 28 }; |
25 | 29 |
26 closedTreeJson = { | 30 var closedTreeJson = { |
27 "username": "username@test.org", | 31 "username": "ojan@chromium.org", |
28 "message": "Tree is closed for maintenance", | 32 "date": "2013-10-14 20:32:09.642350", |
29 "can_commit_freely": false | 33 "message": "Tree is closed", |
30 } | 34 "can_commit_freely": false, |
| 35 "general_state": "closed" |
| 36 }; |
31 | 37 |
32 asyncTest("basic", 10, function() { | 38 asyncTest("basic", 6, function() { |
33 var simulator = new NetworkSimulator(); | 39 var simulator = new NetworkSimulator(); |
34 simulator.json = function(url) { | 40 simulator.json = function(url) { |
35 if (url.indexOf('closed') != -1) | 41 if (url.indexOf('closed') != -1) |
36 return Promise.resolve(closedTreeJson); | 42 return Promise.resolve(closedTreeJson); |
37 else if (url.indexOf('throttled') != -1) | 43 else if (url.indexOf('throttled') != -1) |
38 return Promise.resolve(throttledTreeJson); | 44 return Promise.resolve(throttledTreeJson); |
39 else | 45 else |
40 return Promise.resolve(openTreeJson); | 46 return Promise.resolve(openTreeJson); |
41 }; | 47 }; |
42 | 48 |
43 var opentree = document.createElement("ct-tree-status"); | 49 var opentree = new TreeStatus("open-tree-project"); |
44 opentree.project = "open-tree-project"; | 50 var throttledtree = new TreeStatus("throttled-tree-project"); |
45 var throttledtree = document.createElement("ct-tree-status"); | 51 var closedtree = new TreeStatus("closed-tree-project"); |
46 throttledtree.project = "throttled-tree-project"; | |
47 var closedtree = document.createElement("ct-tree-status"); | |
48 closedtree.project = "closed-tree-project"; | |
49 | 52 |
50 simulator.runTest(function() { | 53 simulator.runTest(function() { |
51 var urlByName = treestatus.urlByName; | |
52 treestatus.urlByName = function(name) { | |
53 return "http://" + name + "-status.appspot.com/"; | |
54 } | |
55 Promise.all([ | 54 Promise.all([ |
56 opentree.update().then(function() { | 55 opentree.update().then(function() { |
57 equal(opentree.status, "open"); | 56 equal(opentree.status, "open"); |
58 }), | 57 }), |
59 throttledtree.update().then(function() { | 58 throttledtree.update().then(function() { |
60 equal(throttledtree.message, | 59 equal(throttledtree.message, |
61 "Tree is throttled just for fun by username@test.org"); | 60 "Tree is throttled just for fun by username@test.org"); |
62 equal(throttledtree.status, "throttled"); | 61 equal(throttledtree.status, "throttled"); |
63 }), | 62 }), |
64 closedtree.update().then(function() { | 63 closedtree.update().then(function() { |
65 equal(closedtree.message, | 64 equal(closedtree.message, |
66 "Tree is closed for maintenance by username@test.org"); | 65 "Tree is closed by ojan@chromium.org"); |
67 equal(closedtree.status, "closed"); | 66 equal(closedtree.status, "closed"); |
68 equal(closedtree.shadowRoot.querySelector('a').href, treestatus.urlByNam
e('closed-tree-project')); | |
69 }) | 67 }) |
70 ]).then(function() { | 68 ]).then(function() { |
71 requestAnimationFrame(function() { | 69 requestAnimationFrame(function() { |
72 ok(!opentree.shadowRoot.textContent.has("open-tree-project")); | |
73 ok(throttledtree.shadowRoot.textContent.has("throttled-tree-project")); | |
74 ok(closedtree.shadowRoot.textContent.has("closed-tree-project")); | |
75 start(); | 70 start(); |
76 treestatus.urlByName = urlByName; | |
77 }); | 71 }); |
78 }); | 72 }); |
79 }); | 73 }); |
80 }); | 74 }); |
81 | 75 |
82 })(); | 76 })(); |
83 </script> | 77 </script> |
OLD | NEW |