| 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 | |
| 36 setTimeout(done); | 21 setTimeout(done); |
| 37 }); | 22 }); |
| 38 | 23 |
| 39 describe('commit list UI', function() { | 24 describe('commit list UI', function() { |
| 40 before(function() { | 25 beforeEach(function(done) { |
| 41 numCommits = 2; | 26 var repos = [ |
| 27 { commits: [ new CTCommitMock(), new CTCommitMock() ], |
| 28 expanded: false }, |
| 29 { commits: [ new CTCommitMock(), new CTCommitMock() ], |
| 30 expanded: false } |
| 31 ]; |
| 32 |
| 33 var CommitList = Object.create(Object); |
| 34 CommitList.prototype.repositories = function() { |
| 35 return repos; |
| 36 }; |
| 37 list.commitList = CommitList; |
| 38 |
| 39 setTimeout(done); |
| 42 }); | 40 }); |
| 43 | 41 |
| 44 it('should show all commits in revision range', function() { | 42 it('should show no commits by default', function() { |
| 45 var commits = list.shadowRoot.querySelectorAll('ct-commit'); | 43 var commits = list.shadowRoot.querySelectorAll('ct-commit'); |
| 46 assert.lengthOf(commits, numCommits); | 44 assert.lengthOf(commits, 0); |
| 47 }); | |
| 48 }); | |
| 49 | |
| 50 describe('empty commit list UI', function() { | |
| 51 before(function() { | |
| 52 numCommits = 0; | |
| 53 }); | 45 }); |
| 54 | 46 |
| 55 it('should show no commits for backwards revision range', function() { | 47 describe('expanded test', function() { |
| 56 var commits = list.shadowRoot.querySelectorAll('ct-commit'); | 48 beforeEach(function(done) { |
| 57 assert.lengthOf(commits, numCommits); | 49 list.commitList.repositories().first().expanded = true; |
| 50 list.commitList.repositories().last().expanded = true; |
| 51 setTimeout(done); |
| 52 }); |
| 53 |
| 54 it('should show commits when expanded', function() { |
| 55 assert.lengthOf(list.shadowRoot.querySelectorAll('ct-commit'), 4); |
| 56 }); |
| 58 }); | 57 }); |
| 59 }); | 58 }); |
| 60 }); | 59 }); |
| 61 | 60 |
| 62 })() | 61 })() |
| 63 </script> | 62 </script> |
| OLD | NEW |