22
33import React , { Component } from 'react' ;
44import TestUtils from 'react-dom/test-utils' ;
5- import expect from 'expect ' ;
5+ import { expect } from 'chai ' ;
66import NotificationSystem from 'NotificationSystem' ;
77import { positions , levels } from 'constants' ;
88import 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 ( / n o t i f i c a t i o n - h i d d e n / ) ;
79- expect ( notification . className ) . not . toMatch ( / n o t i f i c a t i o n - v i s i b l e / ) ;
78+ expect ( notification . className ) . to . not . match ( / n o t i f i c a t i o n - h i d d e n / ) ;
79+ expect ( notification . className ) . to . not . match ( / n o t i f i c a t i o n - v i s i b l e / ) ;
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 ( / n o t i f i c a t i o n / ) ;
86+ expect ( notification . className ) . to . match ( / n o t i f i c a t i o n / ) ;
8787 clock . tick ( 400 ) ;
88- expect ( notification . className ) . toMatch ( / n o t i f i c a t i o n - v i s i b l e / ) ;
88+ expect ( notification . className ) . to . match ( / n o t i f i c a t i o n - v i s i b l e / ) ;
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 ( / n o t i f i c a t i o n l e v e l i s r e q u i r e d / ) ;
424+ expect ( ( ) => component . addNotification ( notificationObj ) ) . to . throw ( / n o t i f i c a t i o n l e v e l i s r e q u i r e d / ) ;
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 ( / i s n o t a v a l i d l e v e l / ) ;
430+ expect ( ( ) => component . addNotification ( notificationObj ) ) . to . throw ( / i s n o t a v a l i d l e v e l / ) ;
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 ( / i s n o t a v a l i d p o s i t i o n / ) ;
436+ expect ( ( ) => component . addNotification ( notificationObj ) ) . to . throw ( / i s n o t a v a l i d p o s i t i o n / ) ;
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 ( / \' a u t o D i s m i s s \' m u s t b e a n u m b e r ./ ) ;
442+ expect ( ( ) => component . addNotification ( notificationObj ) ) . to . throw ( / \' a u t o D i s m i s s \' m u s t b e a n u m b e r ./ ) ;
443443 done ( ) ;
444444 } ) ;
445445} ) ;
0 commit comments