| 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 module("ct-commit-list"); | 14 var assert = chai.assert; |
| 15 | 15 |
| 16 asyncTest("basic", 1, function() { | 16 describe('ct-commit-list', function() { |
| 17 var list = document.createElement('ct-commit-list'); | 17 var list; |
| 18 var numCommits; |
| 18 | 19 |
| 19 list.commits = new CTCommitLogMock(); | 20 beforeEach(function(done) { |
| 21 list = document.createElement('ct-commit-list'); |
| 22 list.commits = new CTCommitLogMock(); |
| 20 | 23 |
| 21 // FIXME: This test shouldn't rely on firstRevision being empty to pass. | 24 // FIXME: This test shouldn't rely on firstRevision being empty to pass. |
| 22 list.commits.firstRevision = {}; | 25 if (numCommits > 0) |
| 26 list.commits.firstRevision = {}; |
| 23 | 27 |
| 24 var blinkCommits = list.commits.commits.blink; | 28 var blinkCommits = list.commits.commits.blink; |
| 25 var revision; | 29 var revision; |
| 26 for (revision in blinkCommits) | 30 for (revision in blinkCommits) |
| 27 break; | 31 break; |
| 28 | 32 |
| 29 var numCommits = 2; | 33 list.first = {blink: revision}; |
| 34 list.last = {blink: Number(revision) + numCommits}; |
| 30 | 35 |
| 31 list.first = {blink: revision}; | 36 setTimeout(done); |
| 32 list.last = {blink: Number(revision) + numCommits}; | 37 }); |
| 33 | 38 |
| 34 requestAnimationFrame(function() { | 39 describe('commit list UI', function() { |
| 35 var commits = list.shadowRoot.querySelectorAll('ct-commit'); | 40 before(function() { |
| 36 equal(commits.length, numCommits); | 41 numCommits = 2; |
| 42 }); |
| 37 | 43 |
| 38 start(); | 44 it('should show all commits in revision range', function() { |
| 45 var commits = list.shadowRoot.querySelectorAll('ct-commit'); |
| 46 assert.lengthOf(commits, numCommits); |
| 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 }); |
| 39 }); | 59 }); |
| 40 }); | 60 }); |
| 41 | 61 |
| 42 asyncTest("backwards", 1, function() { | |
| 43 var list = document.createElement('ct-commit-list'); | |
| 44 | |
| 45 list.commits = new CTCommitLogMock(); | |
| 46 | |
| 47 var blinkCommits = list.commits.commits.blink; | |
| 48 var revision; | |
| 49 for (revision in blinkCommits) | |
| 50 break; | |
| 51 | |
| 52 list.first = {blink: revision}; | |
| 53 list.last = {blink: Number(revision) - 1}; | |
| 54 | |
| 55 requestAnimationFrame(function() { | |
| 56 var commits = list.shadowRoot.querySelectorAll('ct-commit'); | |
| 57 equal(commits.length, 0); | |
| 58 | |
| 59 start(); | |
| 60 }); | |
| 61 }); | |
| 62 | |
| 63 })() | 62 })() |
| 64 </script> | 63 </script> |
| OLD | NEW |