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-commit-log.html"> | 7 <link rel="import" href="ct-commit-log.html"> |
8 | 8 |
9 <link rel='import' href='ct-commit-mock.html'> | 9 <link rel='import' href='ct-commit-mock.html'> |
10 | 10 |
11 <script> | 11 <script> |
12 (function () { | 12 (function () { |
13 | 13 |
14 module("ct-commit-log"); | 14 module("ct-commit-log"); |
15 | 15 |
16 test("basic", 1, function() { | 16 test("basic", 4, function() { |
17 var commit = new CTCommitMock(); | 17 var commit = new CTCommitMock(); |
18 var kExampleCommitDataXML = | 18 var exampleCommitData = ')]}\n' + |
19 "<feed xmlns='http://www.w3.org/2005/Atom'>\n" + | 19 JSON.stringify({ |
20 "<title>blink, branch master</title>\n" + | 20 "log": [ |
21 "<subtitle>Mirror of the Chromium Blink repository.</subtitle>\n" + | 21 { |
22 "<link rel='alternate' type='text/html' href='http://blink.lc/blink/'/>\n"
+ | 22 "commit": "068885c2c5fda617e634bb73a107a0285af470ff", |
23 "<entry>\n" + | 23 "tree": "750c92f0fe1294bdddbf00cc14378d0d440290cb", |
24 "<title>Throw SecurityError when setting 'Replaceable' properties cross-or
igin.</title>\n" + | 24 "parents": [ |
25 "<updated>2013-09-30T20:22:01Z</updated>\n" + | 25 "e6ba81e00ae835946e069e5bd80bd533b11d8442" |
26 "<author>\n" + | 26 ], |
27 "<name>" + commit.author + "</name>\n" + | 27 "author": { |
28 "</author>\n" + | 28 "name": commit.author, |
29 "<published>2013-09-30T20:22:01Z</published>\n" + | 29 "email": commit.author + "@0039d316-1c4b-4281-b951-d872f2087c98", |
30 "<link rel='alternate' type='text/html' href='http://blink.lc/blink/commit
/?id=723e62a4a4e093435b4772b4839aa3fd7cf6b991'/>\n" + | 30 "time": "Tue Jul 17 17:10:47 2012" |
31 "<id>723e62a4a4e093435b4772b4839aa3fd7cf6b991</id>\n" + | 31 }, |
32 "<content type='text'>\n" + commit.message + "</content>\n"; | 32 "committer": { |
| 33 "name": commit.author, |
| 34 "email": commit.author + "@0039d316-1c4b-4281-b951-d872f2087c98", |
| 35 "time": "Tue Jul 17 17:10:47 2012" |
| 36 }, |
| 37 "message": commit.message, |
| 38 } |
| 39 ] |
| 40 }); |
33 | 41 |
34 var xml = new DOMParser().parseFromString(kExampleCommitDataXML, "text/xml"); | 42 var repositoryUrl = 'http://mockurl/?{revision}'; |
| 43 var repository = 'blink'; |
| 44 |
35 var log = new CTCommitLog(); | 45 var log = new CTCommitLog(); |
36 log._processXml(xml); | 46 log._handleResponse(repositoryUrl, repository, exampleCommitData); |
37 | 47 |
38 var expectedCommits = {}; | 48 var expectedCommits = {}; |
39 expectedCommits[commit.revision] = commit; | 49 expectedCommits[repository] = {}; |
| 50 expectedCommits[repository][commit.revision] = commit; |
40 deepEqual(log.commits, expectedCommits); | 51 deepEqual(log.commits, expectedCommits); |
| 52 |
| 53 deepEqual(log.range(repository, commit.revision, commit.revision), [commit]); |
| 54 deepEqual(log.range(repository, commit.revision, commit.revision + 1), [commit
]); |
| 55 // This url is different than the one obove because CTCommitLog gets the url |
| 56 // from CTRepositories. |
| 57 var incompleteRepositoryUrl = log._repositories.repositories[repository].repos
itoryUrl; |
| 58 var incompleteCommit = CTCommit.createIncomplete(incompleteRepositoryUrl, comm
it.revision - 1, repository); |
| 59 deepEqual(log.range(repository, commit.revision - 1, commit.revision + 1), [in
completeCommit, commit]); |
41 }); | 60 }); |
42 | 61 |
43 })(); | 62 })(); |
44 </script> | 63 </script> |
OLD | NEW |