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 <link rel="import" href="../../lib/network-simulator.html"> | |
10 | |
11 <script> | |
12 (function () { | |
13 | |
14 var assert = chai.assert; | |
15 | |
16 describe('tree status', function() { | |
17 var openTreeJson = { | |
18 'username': 'erg@chromium.org', | |
19 'date': '2013-10-14 20:22:00.887390', | |
20 'message': 'Tree is open', | |
21 'can_commit_freely': true, | |
22 'general_state': 'open' | |
23 }; | |
24 | |
25 var throttledTreeJson = { | |
26 'username': 'username@test.org', | |
27 'date': '2013-10-14 20:22:00.887390', | |
28 'message': 'Tree is throttled just for fun', | |
29 'can_commit_freely': false | |
30 }; | |
31 | |
32 var closedTreeJson = { | |
33 'username': 'ojan@chromium.org', | |
34 'date': '2013-10-14 20:32:09.642350', | |
35 'message': 'Tree is closed', | |
36 'can_commit_freely': false, | |
37 'general_state': 'closed' | |
38 }; | |
39 | |
40 var opentree = new TreeStatus("open-tree-project"); | |
41 var throttledtree = new TreeStatus("throttled-tree-project"); | |
42 var closedtree = new TreeStatus("closed-tree-project"); | |
43 | |
44 it('tree status', function(done) { | |
45 var simulator = new NetworkSimulator(assert, done); | |
46 simulator.json = function(url) { | |
47 if (url.indexOf('closed') != -1) | |
48 return Promise.resolve(closedTreeJson); | |
49 else if (url.indexOf('throttled') != -1) | |
50 return Promise.resolve(throttledTreeJson); | |
51 else | |
52 return Promise.resolve(openTreeJson); | |
53 }; | |
54 | |
55 simulator.runTest(function() { | |
56 return Promise.all([ | |
57 opentree.update().then(function() { | |
58 assert.equal(opentree.status, 'open'); | |
59 }), | |
60 throttledtree.update().then(function() { | |
61 assert.equal(throttledtree.message, | |
62 "Tree is throttled just for fun by username@test.org"); | |
63 assert.equal(throttledtree.status, "throttled"); | |
64 }), | |
65 closedtree.update().then(function() { | |
66 assert.equal(closedtree.message, | |
67 "Tree is closed by ojan@chromium.org"); | |
68 assert.equal(closedtree.status, "closed"); | |
69 }) | |
70 ]); | |
71 }); | |
72 }); | |
73 }); | |
74 | |
75 })(); | |
76 </script> | |
OLD | NEW |