| 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-failure-group.html"> | 7 <link rel="import" href="../ct-failure-group.html"> |
| 8 | 8 |
| 9 <script> | 9 <script> |
| 10 (function () { | 10 (function () { |
| 11 | 11 |
| 12 var assert = chai.assert; | 12 var assert = chai.assert; |
| 13 | 13 |
| 14 describe('ct-failure-group', function() { | 14 describe('ct-failure-group', function() { |
| 15 | 15 |
| 16 beforeEach(function() { | 16 beforeEach(function() { |
| 17 localStorage.removeItem('CTFailureGroupAnnotations'); | 17 localStorage.removeItem('CTFailureGroupAnnotations'); |
| 18 }); | 18 }); |
| 19 | 19 |
| 20 describe('category', function() { | 20 describe('category', function() { |
| 21 it('should be "default" by default', function() { | 21 it('should be "default" by default', function() { |
| 22 var group = new CTFailureGroup('key', []); | 22 var group = new CTFailureGroup('key', [], []); |
| 23 assert.equal(group.category, 'default'); | 23 assert.equal(group.category, 'default'); |
| 24 }); | 24 }); |
| 25 | 25 |
| 26 it('should be "snoozed" when snoozed', function() { | 26 it('should be "snoozed" when snoozed', function() { |
| 27 var group = new CTFailureGroup('key', [], {snoozeTime: Date.now() + 1000 *
1000}); | 27 var group = new CTFailureGroup('key', [], [], {snoozeTime: Date.now() + 10
00 * 1000}); |
| 28 assert.equal(group.category, 'snoozed'); | 28 assert.equal(group.category, 'snoozed'); |
| 29 }); | 29 }); |
| 30 }); | 30 }); |
| 31 | 31 |
| 32 describe('snooze', function() { | 32 describe('snooze', function() { |
| 33 it('should set isSnoozed', function(done) { | 33 it('should set isSnoozed', function(done) { |
| 34 var group = new CTFailureGroup('key', []); | 34 var group = new CTFailureGroup('key', [], []); |
| 35 group.snoozeUntil(Date.now() + 1000 * 1000).then(function() { | 35 group.snoozeUntil(Date.now() + 1000 * 1000).then(function() { |
| 36 assert.isTrue(group.isSnoozed); | 36 assert.isTrue(group.isSnoozed); |
| 37 done(); | 37 done(); |
| 38 }); | 38 }); |
| 39 }); | 39 }); |
| 40 }); | 40 }); |
| 41 | 41 |
| 42 describe('unsnooze', function() { | 42 describe('unsnooze', function() { |
| 43 it('should clear isSnoozed', function(done) { | 43 it('should clear isSnoozed', function(done) { |
| 44 var group = new CTFailureGroup('key', []); | 44 var group = new CTFailureGroup('key', [], []); |
| 45 group.snoozeUntil(Date.now() + 1000 * 1000).then(function() { | 45 group.snoozeUntil(Date.now() + 1000 * 1000).then(function() { |
| 46 group.unsnooze().then(function() { | 46 group.unsnooze().then(function() { |
| 47 assert.isFalse(group.isSnoozed); | 47 assert.isFalse(group.isSnoozed); |
| 48 done(); | 48 done(); |
| 49 }); | 49 }); |
| 50 }); | 50 }); |
| 51 }); | 51 }); |
| 52 }); | 52 }); |
| 53 | 53 |
| 54 describe('setBug', function() { | 54 describe('setBug', function() { |
| 55 it('should store the bug', function(done) { | 55 it('should store the bug', function(done) { |
| 56 var group = new CTFailureGroup('key', []); | 56 var group = new CTFailureGroup('key', [], []); |
| 57 group.setBug('123').then(function() { | 57 group.setBug('123').then(function() { |
| 58 assert.equal(group.bug, 'http://crbug.com/123'); | 58 assert.equal(group.bug, 'http://crbug.com/123'); |
| 59 assert.equal(group._annotation.bug, 'http://crbug.com/123'); | 59 assert.equal(group._annotation.bug, 'http://crbug.com/123'); |
| 60 assert.equal(group.bugLabel, 'Bug 123'); | 60 assert.equal(group.bugLabel, 'Bug 123'); |
| 61 done(); | 61 done(); |
| 62 }); | 62 }); |
| 63 }); | 63 }); |
| 64 | 64 |
| 65 it('should support URLs', function(done) { | 65 it('should support URLs', function(done) { |
| 66 var group = new CTFailureGroup('key', []); | 66 var group = new CTFailureGroup('key', [], []); |
| 67 group.setBug('http://foobar.com/?id=876&x=y').then(function() { | 67 group.setBug('http://foobar.com/?id=876&x=y').then(function() { |
| 68 assert.equal(group.bug, 'http://foobar.com/?id=876&x=y'); | 68 assert.equal(group.bug, 'http://foobar.com/?id=876&x=y'); |
| 69 assert.equal(group._annotation.bug, 'http://foobar.com/?id=876&x=y'); | 69 assert.equal(group._annotation.bug, 'http://foobar.com/?id=876&x=y'); |
| 70 assert.equal(group.bugLabel, 'Bug 876'); | 70 assert.equal(group.bugLabel, 'Bug 876'); |
| 71 done(); | 71 done(); |
| 72 }); | 72 }); |
| 73 }); | 73 }); |
| 74 }); | 74 }); |
| 75 | 75 |
| 76 describe('clearBug', function() { | 76 describe('clearBug', function() { |
| 77 it('should work', function(done) { | 77 it('should work', function(done) { |
| 78 var group = new CTFailureGroup('key', []); | 78 var group = new CTFailureGroup('key', [], []); |
| 79 group.setBug('123').then(function() { | 79 group.setBug('123').then(function() { |
| 80 group.clearBug().then(function() { | 80 group.clearBug().then(function() { |
| 81 assert.isUndefined(group.bug); | 81 assert.isUndefined(group.bug); |
| 82 assert.isUndefined(group.bugLabel); | 82 assert.isUndefined(group.bugLabel); |
| 83 assert.notProperty(group._annotation, 'bug'); | 83 assert.notProperty(group._annotation, 'bug'); |
| 84 done(); | 84 done(); |
| 85 }); | 85 }); |
| 86 }); | 86 }); |
| 87 }); | 87 }); |
| 88 }); | 88 }); |
| 89 | 89 |
| 90 describe('annotations', function() { | 90 describe('annotations', function() { |
| 91 it('should have sensible defaults', function() { | 91 it('should have sensible defaults', function() { |
| 92 var group = new CTFailureGroup('key', []); | 92 var group = new CTFailureGroup('key', [], []); |
| 93 assert.deepEqual(group._annotation, {}); | 93 assert.deepEqual(group._annotation, {}); |
| 94 assert.isFalse(group.isSnoozed); | 94 assert.isFalse(group.isSnoozed); |
| 95 assert.isUndefined(group.bug); | 95 assert.isUndefined(group.bug); |
| 96 assert.isUndefined(group.bugLabel); | 96 assert.isUndefined(group.bugLabel); |
| 97 }); | 97 }); |
| 98 | 98 |
| 99 it('should compute properties', function() { | 99 it('should compute properties', function() { |
| 100 var group = new CTFailureGroup('key', [], {snoozeTime: Date.now() + 1000 *
1000, bug: 'http://crbug.com/123'}); | 100 var group = new CTFailureGroup('key', [], [], {snoozeTime: Date.now() + 10
00 * 1000, bug: 'http://crbug.com/123'}); |
| 101 assert.isTrue(group.isSnoozed); | 101 assert.isTrue(group.isSnoozed); |
| 102 assert.equal(group.bug, 'http://crbug.com/123'); | 102 assert.equal(group.bug, 'http://crbug.com/123'); |
| 103 }); | 103 }); |
| 104 | 104 |
| 105 it('should be persisted', function(done) { | 105 it('should be persisted', function(done) { |
| 106 var group = new CTFailureGroup('key', []); | 106 var group = new CTFailureGroup('key', [], []); |
| 107 group.snoozeUntil(123).then(function() { | 107 group.snoozeUntil(123).then(function() { |
| 108 group.setBug('456').then(function() { | 108 group.setBug('456').then(function() { |
| 109 CTFailureGroup.fetchAnnotations().then(function(annotations) { | 109 CTFailureGroup.fetchAnnotations().then(function(annotations) { |
| 110 assert.deepEqual(annotations['key'], {snoozeTime: 123, bug: 'http://
crbug.com/456'}); | 110 assert.deepEqual(annotations['key'], {snoozeTime: 123, bug: 'http://
crbug.com/456'}); |
| 111 done(); | 111 done(); |
| 112 }); | 112 }); |
| 113 }); | 113 }); |
| 114 }); | 114 }); |
| 115 }); | 115 }); |
| 116 }); | 116 }); |
| 117 }); | 117 }); |
| 118 | 118 |
| 119 })() | 119 })() |
| 120 </script> | 120 </script> |
| OLD | NEW |