@@ -4,7 +4,7 @@ import Enzyme, { mount } from "enzyme";
44import React16Adapter from "enzyme-adapter-react-16" ;
55import sinon from "sinon" ;
66import notificationMock from "tests/mocks/notification.mock" ;
7- import { NOTIFICATION_STAGE } from "src/constants" ;
7+ import { NOTIFICATION_STAGE , BREAKPOINT } from "src/constants" ;
88
99Enzyme . configure ( {
1010 // use react-16 adapter
@@ -15,22 +15,20 @@ describe("Wrapper component", () => {
1515 let component ;
1616 let clock ;
1717
18- // arrow function helpers
18+ // helpers
1919 const state = ( ) => component . state ( ) ;
2020 const instance = ( ) => component . instance ( ) ;
21+
22+ const getTypesMock = ( ) => [ {
23+ name : "awesome" ,
24+ htmlClasses : [ "awesome" ]
25+ } ] ;
2126
22- const getTypesMock = function ( ) {
23- return [ {
24- name : "awesome" ,
25- htmlClasses : [ "awesome" ]
26- } ] ;
27- } ;
28-
29- const getNotificationMock = function ( edits = { } ) {
27+ const getNotificationMock = ( edits = { } ) => {
3028 return Object . assign ( { } , notificationMock , edits ) ;
3129 } ;
3230
33- const addNotification = function ( mock ) {
31+ const addNotification = ( mock ) => {
3432 return instance ( ) . addNotification ( mock ) ;
3533 } ;
3634
@@ -323,24 +321,30 @@ describe("Wrapper component", () => {
323321 expect ( notif . props . toggleTouchEnd ) . toBeDefined ( ) ;
324322 } ) ;
325323
326- it ( "renders mobile if `isMobile` is set " , ( ) => {
324+ it ( "renders mobile for 512px width if `isMobile` is true " , ( ) => {
327325 // width for mobile view
328326 global . window . innerWidth = 512 ;
329327
328+ // just in case we update breakpoint in near future
329+ expect ( global . window . innerWidth ) . toBeLessThan ( BREAKPOINT ) ;
330+
330331 // mount
331- component = mount ( < ReactNotificationComponent isMobile = { true } /> ) ;
332+ component = mount ( < ReactNotificationComponent /> ) ;
332333
333334 // all mobile containers rendered
334335 expect ( component . find ( ".notification-container-mobile-top" ) . length ) . toBe ( 1 ) ;
335336 expect ( component . find ( ".notification-container-mobile-bottom" ) . length ) . toBe ( 1 ) ;
336337 } ) ;
337338
338- it ( "renders desktop if `isMobile` is not set " , ( ) => {
339+ it ( "renders desktop for 512px width if `isMobile` is false " , ( ) => {
339340 // width for mobile view
340341 global . window . innerWidth = 512 ;
341342
343+ // just in case we update breakpoint in near future
344+ expect ( global . window . innerWidth ) . toBeLessThan ( BREAKPOINT ) ;
345+
342346 // mount
343- component = mount ( < ReactNotificationComponent /> ) ;
347+ component = mount ( < ReactNotificationComponent isMobile = { false } /> ) ;
344348
345349 // all desktop containers rendered
346350 expect ( component . find ( ".notification-container-top-left" ) . length ) . toBe ( 1 ) ;
0 commit comments