| OLD | NEW |
| (Empty) | |
| 1 <!-- |
| 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 |
| 4 found in the LICENSE file. |
| 5 --> |
| 6 |
| 7 <link rel="import" href="tree-status.html"> |
| 8 |
| 9 <script> |
| 10 |
| 11 (function () { |
| 12 |
| 13 module("tree-status"); |
| 14 |
| 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 closedTreeJson = { |
| 24 "username": "ojan@chromium.org", |
| 25 "date": "2013-10-14 20:32:09.642350", |
| 26 "message": "Tree is closed", |
| 27 "can_commit_freely": false, |
| 28 "general_state": "closed" |
| 29 }; |
| 30 |
| 31 test('urlByName', 3, function() { |
| 32 var treeStatus = new TreeStatus(); |
| 33 equal(treeStatus.urlByName('blink'), 'http://blink-status.appspot.com/'); |
| 34 equal(treeStatus.urlByName('chromium'), 'http://chromium-status.appspot.com/
'); |
| 35 equal(treeStatus.urlByName('foo'), null); |
| 36 }); |
| 37 |
| 38 asyncTest('fetchTreeStatus', 3, function() { |
| 39 var simulator = new NetworkSimulator(); |
| 40 |
| 41 simulator.json = function(url) |
| 42 { |
| 43 if (url.indexOf('closed') != -1) |
| 44 return Promise.resolve(closedTreeJson); |
| 45 else |
| 46 return Promise.resolve(openTreeJson); |
| 47 }; |
| 48 |
| 49 var span = document.createElement('span'); |
| 50 simulator.runTest(function() { |
| 51 var treeStatus = new TreeStatus(); |
| 52 treeStatus.fetchTreeStatus('http://opentree', span) |
| 53 .then(function(result) { |
| 54 equal(span.textContent, 'OPEN'); |
| 55 |
| 56 span = document.createElement('span'); |
| 57 treeStatus.fetchTreeStatus('http://closedtree', span) |
| 58 .then(function() { |
| 59 equal(span.textContent, 'Tree is closed by ojan@chromium
.org'); |
| 60 start(); |
| 61 }); |
| 62 }); |
| 63 }); |
| 64 }); |
| 65 |
| 66 })(); |
| 67 </script> |
| OLD | NEW |