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="../../lib/log.html"> | |
8 <link rel="import" href="../../lib/network-simulator.html"> | |
9 <link rel="import" href="../cqstats-ratio-graph-data.html"> | |
10 | |
11 <script> | |
12 (function() { | |
13 | |
14 var assert = chai.assert; | |
15 | |
16 var testCQStats = { | |
17 results: [{ | |
18 key: '2002', | |
19 begin: 1500, | |
20 end: 1500 + 500 * 60, | |
21 interval_minutes: 500, | |
22 stats: [{ | |
23 name: 'test-stat-a', | |
24 count: 50, | |
25 }, { | |
26 name: 'test-stat-b', | |
27 count: 100, | |
28 }], | |
29 }, { | |
30 key: '1001', | |
31 begin: 1000, | |
32 end: 1000 + 500 * 60, | |
33 interval_minutes: 500, | |
34 stats: [{ | |
35 name: 'test-stat-a', | |
36 count: 25, | |
37 }, { | |
38 name: 'test-stat-b', | |
39 count: 200, | |
40 }], | |
41 }], | |
42 }; | |
43 | |
44 describe('CQStatsRatioGraphData', function() { | |
45 it('should create a CQStatsRatioGraphData combines two CQStats', function(done
) { | |
46 var simulator = new NetworkSimulator(assert); | |
47 simulator.json = function(options) { | |
48 if (options.url === 'https://chromium-cq-status.appspot.com/stats/query?pr
oject=testProject&interval_minutes=500&names=test-stat-a%2Ctest-stat-b&count=100
0') { | |
49 return Promise.resolve(testCQStats); | |
50 } | |
51 console.log('Unexpected url: ' + options.url); | |
52 } | |
53 | |
54 var ratioData; | |
55 simulator.runTest(function() { | |
56 ratioData = new CQStatsRatioGraphData( | |
57 'testColumn', 'testProject', 500, 'test-stat-a', 'test-stat-b', 1000); | |
58 }).then(function() { | |
59 assert.ok(ratioData); | |
60 assert.ok(ratioData.rowItemsAvailable); | |
61 return ratioData.get().then(function(data) { | |
62 assert.deepEqual(data, { | |
63 cols: ['timestamp', 'testColumn'], | |
64 rows: [ | |
65 [new Date((1000 + 500 * 60) * 1000), 12.5], | |
66 [new Date((1500 + 500 * 60) * 1000), 50], | |
67 ], | |
68 }); | |
69 }); | |
70 }).then(function() { | |
71 done(); | |
72 }).catch(log); | |
73 }); | |
74 }); | |
75 | |
76 })(); | |
77 </script> | |
OLD | NEW |