Index: Tools/GardeningServer/ui/ct-tree-status-tests.html |
diff --git a/Tools/GardeningServer/ui/ct-tree-status-tests.html b/Tools/GardeningServer/ui/ct-tree-status-tests.html |
index f14e34a99b590f9d0f06d93606a065d5c23e0a68..6cf56ce849132a32bb1833cb507ba28473f85a2c 100644 |
--- a/Tools/GardeningServer/ui/ct-tree-status-tests.html |
+++ b/Tools/GardeningServer/ui/ct-tree-status-tests.html |
@@ -11,70 +11,37 @@ found in the LICENSE file. |
module("ct-tree-status"); |
-openTreeJson = { |
- "username": "username@test.org", |
- "message": "Tree is open", |
- "can_commit_freely": true |
-} |
+asyncTest('basic', 5, function() { |
+ var openTree = document.createElement("ct-tree-status"); |
+ var openTreeStatus = new TreeStatus('open-tree-project'); |
+ openTreeStatus.status = 'open'; |
+ openTree.treeStatus = openTreeStatus; |
+ |
+ var throttledTree = document.createElement("ct-tree-status"); |
+ var throttledTreeStatus = new TreeStatus('throttled-tree-project'); |
+ throttledTreeStatus.status = 'throttled'; |
+ throttledTreeStatus.message = 'Tree is throttled just for fun'; |
+ throttledTree.treeStatus = throttledTreeStatus; |
+ |
+ var closedTree = document.createElement("ct-tree-status"); |
+ var closedTreeStatus = new TreeStatus('closed-tree-project'); |
+ closedTreeStatus.status = 'closed'; |
+ closedTreeStatus.message = 'Tree is closed'; |
+ closedTree.treeStatus = closedTreeStatus; |
-throttledTreeJson = { |
- "username": "username@test.org", |
- "message": "Tree is throttled just for fun", |
- "can_commit_freely": false |
-} |
- |
-closedTreeJson = { |
- "username": "username@test.org", |
- "message": "Tree is closed for maintenance", |
- "can_commit_freely": false |
-} |
- |
-asyncTest("basic", 10, function() { |
var simulator = new NetworkSimulator(); |
- simulator.json = function(url) { |
- if (url.indexOf('closed') != -1) |
- return Promise.resolve(closedTreeJson); |
- else if (url.indexOf('throttled') != -1) |
- return Promise.resolve(throttledTreeJson); |
- else |
- return Promise.resolve(openTreeJson); |
- }; |
- |
- var opentree = document.createElement("ct-tree-status"); |
- opentree.project = "open-tree-project"; |
- var throttledtree = document.createElement("ct-tree-status"); |
- throttledtree.project = "throttled-tree-project"; |
- var closedtree = document.createElement("ct-tree-status"); |
- closedtree.project = "closed-tree-project"; |
- |
simulator.runTest(function() { |
- var urlByName = treestatus.urlByName; |
- treestatus.urlByName = function(name) { |
- return "http://" + name + "-status.appspot.com/"; |
+ var url = TreeStatus.prototype.url; |
+ TreeStatus.prototype.url = function() { |
+ return "http://" + this.project + "-status.appspot.com/"; |
} |
- Promise.all([ |
- opentree.update().then(function() { |
- equal(opentree.status, "open"); |
- }), |
- throttledtree.update().then(function() { |
- equal(throttledtree.message, |
- "Tree is throttled just for fun by username@test.org"); |
- equal(throttledtree.status, "throttled"); |
- }), |
- closedtree.update().then(function() { |
- equal(closedtree.message, |
- "Tree is closed for maintenance by username@test.org"); |
- equal(closedtree.status, "closed"); |
- equal(closedtree.shadowRoot.querySelector('a').href, treestatus.urlByName('closed-tree-project')); |
- }) |
- ]).then(function() { |
- requestAnimationFrame(function() { |
- ok(!opentree.shadowRoot.textContent.has("open-tree-project")); |
- ok(throttledtree.shadowRoot.textContent.has("throttled-tree-project")); |
- ok(closedtree.shadowRoot.textContent.has("closed-tree-project")); |
- start(); |
- treestatus.urlByName = urlByName; |
- }); |
+ requestAnimationFrame(function() { |
+ ok(!openTree.shadowRoot.textContent.has("open-tree-project")); |
+ ok(throttledTree.shadowRoot.textContent.has("throttled-tree-project")); |
+ ok(closedTree.shadowRoot.textContent.has("closed-tree-project")); |
+ equal(closedTree.shadowRoot.querySelector('a').href, closedTreeStatus.url()); |
+ start(); |
+ TreeStatus.prototype.url = url; |
}); |
}); |
}); |