Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Side by Side Diff: remoting/webapp/crd/js/butter_bar_unittest.js

Issue 2887573002: Add deprecation messages. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 (function() {
6
7 'use strict';
8
9 QUnit.module('ButterBar', {
10 beforeEach: function() {
11 var fixture = document.getElementById('qunit-fixture');
12 fixture.innerHTML =
13 '<div id="butter-bar" hidden>' +
14 ' <p>' +
15 ' <span id="butter-bar-message"></span>' +
16 ' <a id="butter-bar-dismiss" href="#" tabindex="0">' +
17 ' <img src="icon_cross.webp" class="close-icon">' +
18 ' </a>' +
19 ' </p>' +
20 '</div>';
21 this.butterBar = new remoting.ButterBar();
22 chrome.storage = {
23 sync: {
24 get: sinon.stub(),
25 set: sinon.stub(),
26 }
27 };
28 },
29 afterEach: function() {
30 }
31 });
32
33 QUnit.test('should stay hidden if index==-1', function(assert) {
34 this.butterBar.currentMessage_ = -1;
35 return this.butterBar.init().then(() => {
36 assert.ok(this.butterBar.root_.hidden == true);
37 assert.ok(this.butterBar.dismiss_.hidden == false);
38 });
39 });
40
41 QUnit.test('should be shown if index>=0 for the first time', function(assert) {
42 this.butterBar.currentMessage_ = 0;
43 chrome.storage.sync.get.callsArgWith(1, {});
44 return this.butterBar.init().then(() => {
45 assert.ok(this.butterBar.root_.hidden == false);
46 assert.ok(this.butterBar.dismiss_.hidden == false);
47 });
48 });
49
50 QUnit.test('should update storage when shown', function(assert) {
51 this.butterBar.currentMessage_ = 0;
52 var clock = sinon.useFakeTimers(123);
53 chrome.storage.sync.get.callsArgWith(1, {});
54 return this.butterBar.init().then(() => {
55 assert.deepEqual(chrome.storage.sync.set.firstCall.args,
56 [{
57 "message-state": {
58 "hidden": false,
59 "index": 0,
60 "timestamp": 123,
61 }
62 }]);
63 });
64 });
65
66 QUnit.test(
67 'should be shown if the timeout has not elapsed and it has not been ' +
68 'dismissed',
69 function(assert) {
70 this.butterBar.currentMessage_ = 0;
71 chrome.storage.sync.get.callsArgWith(1, {
72 "message-state": {
73 "hidden": false,
74 "index": 0,
75 "timestamp": 0,
76 }
77 });
78 var clock = sinon.useFakeTimers(remoting.ButterBar.kTimeout_);
79 return this.butterBar.init().then(() => {
80 assert.ok(this.butterBar.root_.hidden == false);
81 assert.ok(this.butterBar.dismiss_.hidden == false);
82 });
83 });
84
85 QUnit.test('should stay hidden if the timeout has elapsed', function(assert) {
86 this.butterBar.currentMessage_ = 0;
87 chrome.storage.sync.get.callsArgWith(1, {
88 "message-state": {
89 "hidden": false,
90 "index": 0,
91 "timestamp": 0,
92 }
93 });
94 var clock = sinon.useFakeTimers(remoting.ButterBar.kTimeout_+ 1);
95 return this.butterBar.init().then(() => {
96 assert.ok(this.butterBar.root_.hidden == true);
97 assert.ok(this.butterBar.dismiss_.hidden == false);
98 });
99 });
100
101
102 QUnit.test('should stay hidden if it was previously dismissed',
103 function(assert) {
104 this.butterBar.currentMessage_ = 0;
105 chrome.storage.sync.get.callsArgWith(1, {
106 "message-state": {
107 "hidden": true,
108 "index": 0,
109 "timestamp": 0,
110 }
111 });
112 var clock = sinon.useFakeTimers(0);
113 return this.butterBar.init().then(() => {
114 assert.ok(this.butterBar.root_.hidden == true);
115 assert.ok(this.butterBar.dismiss_.hidden == false);
116 });
117 });
118
119
120 QUnit.test('should be shown if the index has increased', function(assert) {
121 this.butterBar.currentMessage_ = 1;
122 chrome.storage.sync.get.callsArgWith(1, {
123 "message-state": {
124 "hidden": true,
125 "index": 0,
126 "timestamp": 0,
127 }
128 });
129 var clock = sinon.useFakeTimers(remoting.ButterBar.kTimeout_ + 1);
130 return this.butterBar.init().then(() => {
131 assert.ok(this.butterBar.root_.hidden == false);
132 assert.ok(this.butterBar.dismiss_.hidden == false);
133 });
134 });
135
136 QUnit.test('should not be dismissable for the final message', function(assert) {
137 this.butterBar.currentMessage_ = 3;
138 chrome.storage.sync.get.callsArgWith(1, {});
139 return this.butterBar.init().then(() => {
140 assert.ok(this.butterBar.root_.hidden == false);
141 assert.ok(this.butterBar.dismiss_.hidden == true);
142 });
143 });
144
145 }());
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698