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