Skip to content

Commit 3ee0655

Browse files
committed
Replaced expect for chai.expect
1 parent 708635b commit 3ee0655

2 files changed

Lines changed: 49 additions & 49 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@
4848
"babel-plugin-react-class-display-name": "^0.1.0",
4949
"babel-plugin-react-transform": "^2.0.2",
5050
"babel-preset-airbnb": "^2.0.0",
51+
"chai": "^4.1.2",
5152
"css-loader": "^0.24.0",
5253
"eslint": "4.9.0",
5354
"eslint-config-airbnb": "^16.0.0",
5455
"eslint-plugin-import": "^2.7.0",
5556
"eslint-plugin-jsx-a11y": "^6.0.2",
5657
"eslint-plugin-react": "^7.4.0",
57-
"expect": "^21.2.1",
5858
"express": "^4.13.3",
5959
"extract-text-webpack-plugin": "^0.8.2",
6060
"file-loader": "^0.8.4",

test/notification-system.test.js

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import React, { Component } from 'react';
44
import TestUtils from 'react-dom/test-utils';
5-
import expect from 'expect';
5+
import { expect } from 'chai';
66
import NotificationSystem from 'NotificationSystem';
77
import { positions, levels } from 'constants';
88
import merge from 'object-assign';
@@ -56,36 +56,36 @@ describe('Notification Component', function() {
5656

5757
it('should be rendered', done => {
5858
component = TestUtils.findRenderedDOMComponentWithClass(instance, 'notifications-wrapper');
59-
expect(component).not.toBeNull();
59+
expect(component).to.not.be.null;
6060
done();
6161
});
6262

6363
it('should hold the component ref', done => {
64-
expect(component).not.toBeNull();
64+
expect(component).to.not.be.null;
6565
done();
6666
});
6767

6868
it('should render a single notification', done => {
6969
component.addNotification(defaultNotification);
7070
let notification = TestUtils.scryRenderedDOMComponentsWithClass(instance, 'notification');
71-
expect(notification.length).toEqual(1);
71+
expect(notification.length).to.equal(1);
7272
done();
7373
});
7474

7575
it('should not set a notification visibility class when the notification is initially added', done => {
7676
component.addNotification(defaultNotification);
7777
let notification = TestUtils.findRenderedDOMComponentWithClass(instance, 'notification');
78-
expect(notification.className).not.toMatch(/notification-hidden/);
79-
expect(notification.className).not.toMatch(/notification-visible/);
78+
expect(notification.className).to.not.match(/notification-hidden/);
79+
expect(notification.className).to.not.match(/notification-visible/);
8080
done();
8181
});
8282

8383
it('should set the notification class to visible after added', done => {
8484
component.addNotification(defaultNotification);
8585
let notification = TestUtils.findRenderedDOMComponentWithClass(instance, 'notification');
86-
expect(notification.className).toMatch(/notification/);
86+
expect(notification.className).to.match(/notification/);
8787
clock.tick(400);
88-
expect(notification.className).toMatch(/notification-visible/);
88+
expect(notification.className).to.match(/notification-visible/);
8989
done();
9090
});
9191

@@ -109,12 +109,12 @@ describe('Notification Component', function() {
109109
containers.forEach(function(container) {
110110
for (let level of Object.keys(levels)) {
111111
let notification = container.getElementsByClassName('notification-' + levels[level]);
112-
expect(notification).not.toBeNull();
112+
expect(notification).to.not.be.null;
113113
}
114114
});
115115

116116
let notifications = TestUtils.scryRenderedDOMComponentsWithClass(instance, 'notification');
117-
expect(notifications.length).toEqual(count);
117+
expect(notifications.length).to.equal(count);
118118
done();
119119
});
120120

@@ -126,7 +126,7 @@ describe('Notification Component', function() {
126126
}
127127

128128
let notifications = TestUtils.scryRenderedDOMComponentsWithClass(instance, 'notification');
129-
expect(notifications.length).toEqual(randomNumber);
129+
expect(notifications.length).to.equal(randomNumber);
130130
done();
131131
});
132132

@@ -135,7 +135,7 @@ describe('Notification Component', function() {
135135
component.addNotification(notificationObj);
136136
component.addNotification(notificationObj);
137137
let notification = TestUtils.scryRenderedDOMComponentsWithClass(instance, 'notification');
138-
expect(notification.length).toEqual(1);
138+
expect(notification.length).to.equal(1);
139139
done();
140140
});
141141

@@ -144,63 +144,63 @@ describe('Notification Component', function() {
144144
component.addNotification(notificationObj);
145145
clock.tick(3000);
146146
let notification = TestUtils.scryRenderedDOMComponentsWithClass(instance, 'notification');
147-
expect(notification.length).toEqual(0);
147+
expect(notification.length).to.equal(0);
148148
done();
149149
});
150150

151151
it('should remove a notification using returned object', done => {
152152
let notificationCreated = component.addNotification(defaultNotification);
153153
let notification = TestUtils.scryRenderedDOMComponentsWithClass(instance, 'notification');
154-
expect(notification.length).toEqual(1);
154+
expect(notification.length).to.equal(1);
155155

156156
component.removeNotification(notificationCreated);
157157
clock.tick(1000);
158158
let notificationRemoved = TestUtils.scryRenderedDOMComponentsWithClass(instance, 'notification');
159-
expect(notificationRemoved.length).toEqual(0);
159+
expect(notificationRemoved.length).to.equal(0);
160160
done();
161161
});
162162

163163
it('should remove a notification using uid', done => {
164164
let notificationCreated = component.addNotification(defaultNotification);
165165
let notification = TestUtils.scryRenderedDOMComponentsWithClass(instance, 'notification');
166-
expect(notification.length).toEqual(1);
166+
expect(notification.length).to.equal(1);
167167

168168
component.removeNotification(notificationCreated.uid);
169169
clock.tick(200);
170170
let notificationRemoved = TestUtils.scryRenderedDOMComponentsWithClass(instance, 'notification');
171-
expect(notificationRemoved.length).toEqual(0);
171+
expect(notificationRemoved.length).to.equal(0);
172172
done();
173173
});
174174

175175
it('should edit an existing notification using returned object', (done) => {
176176
const notificationCreated = component.addNotification(defaultNotification);
177177
const notification = TestUtils.scryRenderedDOMComponentsWithClass(instance, 'notification');
178-
expect(notification.length).toEqual(1);
178+
expect(notification.length).to.equal(1);
179179

180180
const newTitle = 'foo';
181181
const newContent = 'foobar';
182182

183183
component.editNotification(notificationCreated, { title: newTitle, message: newContent });
184184
clock.tick(1000);
185185
const notificationEdited = TestUtils.findRenderedDOMComponentWithClass(instance, 'notification');
186-
expect(notificationEdited.getElementsByClassName('notification-title')[0].textContent).toEqual(newTitle);
187-
expect(notificationEdited.getElementsByClassName('notification-message')[0].textContent).toEqual(newContent);
186+
expect(notificationEdited.getElementsByClassName('notification-title')[0].textContent).to.equal(newTitle);
187+
expect(notificationEdited.getElementsByClassName('notification-message')[0].textContent).to.equal(newContent);
188188
done();
189189
});
190190

191191
it('should edit an existing notification using uid', (done) => {
192192
const notificationCreated = component.addNotification(defaultNotification);
193193
const notification = TestUtils.scryRenderedDOMComponentsWithClass(instance, 'notification');
194-
expect(notification.length).toEqual(1);
194+
expect(notification.length).to.equal(1);
195195

196196
const newTitle = 'foo';
197197
const newContent = 'foobar';
198198

199199
component.editNotification(notificationCreated.uid, { title: newTitle, message: newContent });
200200
clock.tick(1000);
201201
const notificationEdited = TestUtils.findRenderedDOMComponentWithClass(instance, 'notification');
202-
expect(notificationEdited.getElementsByClassName('notification-title')[0].textContent).toEqual(newTitle);
203-
expect(notificationEdited.getElementsByClassName('notification-message')[0].textContent).toEqual(newContent);
202+
expect(notificationEdited.getElementsByClassName('notification-title')[0].textContent).to.equal(newTitle);
203+
expect(notificationEdited.getElementsByClassName('notification-message')[0].textContent).to.equal(newContent);
204204
done();
205205
});
206206

@@ -209,11 +209,11 @@ describe('Notification Component', function() {
209209
component.addNotification(defaultNotification);
210210
component.addNotification(defaultNotification);
211211
let notification = TestUtils.scryRenderedDOMComponentsWithClass(instance, 'notification');
212-
expect(notification.length).toEqual(3);
212+
expect(notification.length).to.equal(3);
213213
component.clearNotifications();
214214
clock.tick(200);
215215
let notificationRemoved = TestUtils.scryRenderedDOMComponentsWithClass(instance, 'notification');
216-
expect(notificationRemoved.length).toEqual(0);
216+
expect(notificationRemoved.length).to.equal(0);
217217
done();
218218
});
219219

@@ -223,7 +223,7 @@ describe('Notification Component', function() {
223223
TestUtils.Simulate.click(notification);
224224
clock.tick(1000);
225225
let notificationRemoved = TestUtils.scryRenderedDOMComponentsWithClass(instance, 'notification');
226-
expect(notificationRemoved.length).toEqual(0);
226+
expect(notificationRemoved.length).to.equal(0);
227227
done();
228228
});
229229

@@ -233,23 +233,23 @@ describe('Notification Component', function() {
233233
TestUtils.Simulate.click(dismissButton);
234234
clock.tick(1000);
235235
let notificationRemoved = TestUtils.scryRenderedDOMComponentsWithClass(instance, 'notification');
236-
expect(notificationRemoved.length).toEqual(0);
236+
expect(notificationRemoved.length).to.equal(0);
237237
done();
238238
});
239239

240240
it('should not render title if not provided', done => {
241241
delete notificationObj.title;
242242
component.addNotification(notificationObj);
243243
let notification = TestUtils.scryRenderedDOMComponentsWithClass(instance, 'notification-title');
244-
expect(notification.length).toEqual(0);
244+
expect(notification.length).to.equal(0);
245245
done();
246246
});
247247

248248
it('should not render message if not provided', done => {
249249
delete notificationObj.message;
250250
component.addNotification(notificationObj);
251251
let notification = TestUtils.scryRenderedDOMComponentsWithClass(instance, 'notification-message');
252-
expect(notification.length).toEqual(0);
252+
expect(notification.length).to.equal(0);
253253
done();
254254
});
255255

@@ -259,7 +259,7 @@ describe('Notification Component', function() {
259259
let notification = TestUtils.findRenderedDOMComponentWithClass(instance, 'notification');
260260
TestUtils.Simulate.click(notification);
261261
let notificationAfterClicked = TestUtils.findRenderedDOMComponentWithClass(instance, 'notification');
262-
expect(notificationAfterClicked).not.toBeNull();
262+
expect(notificationAfterClicked).to.not.be.null;
263263
done();
264264
});
265265

@@ -269,7 +269,7 @@ describe('Notification Component', function() {
269269
let notification = TestUtils.findRenderedDOMComponentWithClass(instance, 'notification');
270270
TestUtils.Simulate.click(notification);
271271
let notificationAfterClicked = TestUtils.findRenderedDOMComponentWithClass(instance, 'notification');
272-
expect(notificationAfterClicked).toExist();
272+
expect(notificationAfterClicked).to.exist;
273273
done();
274274
});
275275

@@ -279,7 +279,7 @@ describe('Notification Component', function() {
279279
let notification = TestUtils.findRenderedDOMComponentWithClass(instance, 'notification');
280280
TestUtils.Simulate.click(notification);
281281
let notificationAfterClicked = TestUtils.findRenderedDOMComponentWithClass(instance, 'notification');
282-
expect(notificationAfterClicked).toExist();
282+
expect(notificationAfterClicked).to.exist;
283283
done();
284284
});
285285

@@ -291,7 +291,7 @@ describe('Notification Component', function() {
291291

292292
component.addNotification(defaultNotification);
293293
let button = TestUtils.findRenderedDOMComponentWithClass(instance, 'notification-action-button');
294-
expect(button).not.toBeNull();
294+
expect(button).to.not.be.null;
295295
done();
296296
});
297297

@@ -307,7 +307,7 @@ describe('Notification Component', function() {
307307
component.addNotification(notificationObj);
308308
let button = TestUtils.findRenderedDOMComponentWithClass(instance, 'notification-action-button');
309309
TestUtils.Simulate.click(button);
310-
expect(testThis).toEqual(true);
310+
expect(testThis).to.equal(true);
311311
done();
312312
});
313313

@@ -320,7 +320,7 @@ describe('Notification Component', function() {
320320
let button = TestUtils.findRenderedDOMComponentWithClass(instance, 'notification-action-button');
321321
TestUtils.Simulate.click(button);
322322
let notification = TestUtils.scryRenderedDOMComponentsWithClass(instance, 'notification');
323-
expect(notification.length).toEqual(0);
323+
expect(notification.length).to.equal(0);
324324
done();
325325
});
326326

@@ -331,7 +331,7 @@ describe('Notification Component', function() {
331331
};
332332

333333
component.addNotification(notificationObj);
334-
expect(testThis).toEqual(true);
334+
expect(testThis).to.equal(true);
335335
done();
336336
});
337337

@@ -344,7 +344,7 @@ describe('Notification Component', function() {
344344
component.addNotification(notificationObj);
345345
let notification = TestUtils.findRenderedDOMComponentWithClass(instance, 'notification');
346346
TestUtils.Simulate.click(notification);
347-
expect(testThis).toEqual(true);
347+
expect(testThis).to.equal(true);
348348
done();
349349
});
350350

@@ -355,7 +355,7 @@ describe('Notification Component', function() {
355355

356356
component.addNotification(defaultNotification);
357357
let customContainer = TestUtils.findRenderedDOMComponentWithClass(instance, 'custom-container');
358-
expect(customContainer).not.toBeNull();
358+
expect(customContainer).to.not.be.null;
359359
done();
360360
});
361361

@@ -366,7 +366,7 @@ describe('Notification Component', function() {
366366
TestUtils.Simulate.mouseEnter(notification);
367367
clock.tick(4000);
368368
let _notification = TestUtils.findRenderedDOMComponentWithClass(instance, 'notification');
369-
expect(_notification).not.toBeNull();
369+
expect(_notification).to.not.be.null;
370370
done();
371371
});
372372

@@ -379,7 +379,7 @@ describe('Notification Component', function() {
379379
TestUtils.Simulate.mouseLeave(notification);
380380
clock.tick(2000);
381381
let _notification = TestUtils.scryRenderedDOMComponentsWithClass(instance, 'notification');
382-
expect(_notification.length).toEqual(0);
382+
expect(_notification.length).to.equal(0);
383383
done();
384384
});
385385

@@ -388,7 +388,7 @@ describe('Notification Component', function() {
388388
component.addNotification(defaultNotification);
389389
let notification = TestUtils.findRenderedDOMComponentWithClass(instance, 'notification-message');
390390
let htmlElement = notification.getElementsByClassName('allow-html-strong');
391-
expect(htmlElement.length).toEqual(1);
391+
expect(htmlElement.length).to.equal(1);
392392
done();
393393
});
394394

@@ -397,7 +397,7 @@ describe('Notification Component', function() {
397397
component.addNotification(notificationObj);
398398
let notification = TestUtils.findRenderedDOMComponentWithClass(instance, 'notifications-tc');
399399
let width = notification.style.width;
400-
expect(width).toEqual('600px');
400+
expect(width).to.equal('600px');
401401
done();
402402
});
403403

@@ -406,7 +406,7 @@ describe('Notification Component', function() {
406406
component.addNotification(notificationObj);
407407
let notification = TestUtils.findRenderedDOMComponentWithClass(instance, 'notification');
408408
let bottomPosition = notification.style.bottom;
409-
expect(bottomPosition).toEqual('-100px');
409+
expect(bottomPosition).to.equal('-100px');
410410
done();
411411
});
412412

@@ -415,31 +415,31 @@ describe('Notification Component', function() {
415415
component.addNotification(notificationObj);
416416
let notification = TestUtils.findRenderedDOMComponentWithClass(instance, 'notifications-tl');
417417
let width = notification.style.width;
418-
expect(width).toEqual('800px');
418+
expect(width).to.equal('800px');
419419
done();
420420
});
421421

422422
it('should throw an error if no level is defined', done => {
423423
delete notificationObj.level;
424-
expect(() => component.addNotification(notificationObj)).toThrow(/notification level is required/);
424+
expect(() => component.addNotification(notificationObj)).to.throw(/notification level is required/);
425425
done();
426426
});
427427

428428
it('should throw an error if a invalid level is defined', done => {
429429
notificationObj.level = 'invalid';
430-
expect(() => component.addNotification(notificationObj)).toThrow(/is not a valid level/);
430+
expect(() => component.addNotification(notificationObj)).to.throw(/is not a valid level/);
431431
done();
432432
});
433433

434434
it('should throw an error if a invalid position is defined', done => {
435435
notificationObj.position = 'invalid';
436-
expect(() => component.addNotification(notificationObj)).toThrow(/is not a valid position/);
436+
expect(() => component.addNotification(notificationObj)).to.throw(/is not a valid position/);
437437
done();
438438
});
439439

440440
it('should throw an error if autoDismiss is not a number', done => {
441441
notificationObj.autoDismiss = 'string';
442-
expect(() => component.addNotification(notificationObj)).toThrow(/\'autoDismiss\' must be a number./);
442+
expect(() => component.addNotification(notificationObj)).to.throw(/\'autoDismiss\' must be a number./);
443443
done();
444444
});
445445
});

0 commit comments

Comments
 (0)