| 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-list.html"> | 7 <link rel="import" href="../ct-commit-list.html"> |
| 8 | 8 |
| 9 <link rel="import" href="../../model/ct-commit-log-mock.html"> | 9 <link rel="import" href="../../model/ct-commit-log-mock.html"> |
| 10 | 10 |
| 11 <script> | 11 <script> |
| 12 (function () { | 12 (function () { |
| 13 | 13 |
| 14 var assert = chai.assert; | 14 var assert = chai.assert; |
| 15 | 15 |
| 16 describe('ct-commit-list', function() { | 16 describe('ct-commit-list', function() { |
| 17 var list; | 17 var list; |
| 18 var numCommits; | |
| 19 | 18 |
| 20 beforeEach(function(done) { | 19 beforeEach(function(done) { |
| 21 list = document.createElement('ct-commit-list'); | 20 list = document.createElement('ct-commit-list'); |
| 22 list.commits = new CTCommitLogMock(); | |
| 23 | |
| 24 // FIXME: This test shouldn't rely on firstRevision being empty to pass. | |
| 25 if (numCommits > 0) | |
| 26 list.commits.firstRevision = {}; | |
| 27 | |
| 28 var blinkCommits = list.commits.commits.blink; | |
| 29 var revision; | |
| 30 for (revision in blinkCommits) | |
| 31 break; | |
| 32 | |
| 33 list.first = {blink: revision}; | |
| 34 list.last = {blink: Number(revision) + numCommits}; | |
| 35 | 21 |
| 36 setTimeout(done); | 22 setTimeout(done); |
| 37 }); | 23 }); |
| 38 | 24 |
| 39 describe('commit list UI', function() { | 25 describe('commit list UI', function() { |
| 40 before(function() { | 26 beforeEach(function(done) { |
| 41 numCommits = 2; | 27 var CommitList = Object.create(Object); |
| 28 CommitList.prototype.repositories = function() { |
| 29 return [ |
| 30 { commits: [ new CTCommitMock(), new CTCommitMock() ] }, |
| 31 { commits: [ new CTCommitMock(), new CTCommitMock() ] } |
| 32 ] |
| 33 }; |
| 34 list.commitList = CommitList; |
| 35 |
| 36 setTimeout(done); |
| 42 }); | 37 }); |
| 43 | 38 |
| 44 it('should show all commits in revision range', function() { | 39 it('should show all commits in revision range', function() { |
| 45 var commits = list.shadowRoot.querySelectorAll('ct-commit'); | 40 var commits = list.shadowRoot.querySelectorAll('ct-commit'); |
| 46 assert.lengthOf(commits, numCommits); | 41 assert.lengthOf(commits, 4); |
| 47 }); | |
| 48 }); | |
| 49 | |
| 50 describe('empty commit list UI', function() { | |
| 51 before(function() { | |
| 52 numCommits = 0; | |
| 53 }); | |
| 54 | |
| 55 it('should show no commits for backwards revision range', function() { | |
| 56 var commits = list.shadowRoot.querySelectorAll('ct-commit'); | |
| 57 assert.lengthOf(commits, numCommits); | |
| 58 }); | 42 }); |
| 59 }); | 43 }); |
| 60 }); | 44 }); |
| 61 | 45 |
| 62 })() | 46 })() |
| 63 </script> | 47 </script> |
| OLD | NEW |