@@ -29,162 +29,120 @@ beforeEach(() => {
2929 </button>
3030</div>`
3131
32- $ ( ( ) => { // JQuery's callback for the DOM loading
33- notificationsElement = $ ( '#notifications' )
34- notifier = new Notifier ( notificationsElement )
35- } )
32+ notificationsElement = $ ( '#notifications' )
33+ notifier = new Notifier ( notificationsElement )
3634} )
3735
3836describe ( 'Notifier' , ( ) => {
3937 describe ( 'clicking the minify button' , ( ) => {
4038 let minimizeButton
4139
42- beforeEach ( ( ) => { // Create a notification so the minify button displays
43- $ ( ( ) => {
44- notifier . notify ( 'a notification' , 'info' )
45- minimizeButton = notificationsElement . find ( '#toggle-minimize-notifications' )
46- } )
40+ beforeEach ( ( ) => {
41+ notifier . notify ( 'a notification' , 'info' )
42+ minimizeButton = notificationsElement . find ( '#toggle-minimize-notifications' )
4743 } )
4844
49- test ( 'should toggle the notifier between the minified and expanded state' , ( done ) => {
50- $ ( ( ) => {
51- try {
52- const messageNotificationsContainer = notificationsElement . find ( '.messages' )
53- const minimizeButtonIcon = minimizeButton . children ( 'i' )
54- const minimizeButtonText = minimizeButton . children ( 'span' ) . first ( )
45+ test ( 'should toggle the notifier between the minified and expanded state' , ( ) => {
46+ const messageNotificationsContainer = notificationsElement . find ( '.messages' )
47+ const minimizeButtonIcon = minimizeButton . children ( 'i' )
48+ const minimizeButtonText = minimizeButton . children ( 'span' ) . first ( )
5549
56- expect ( minimizeButton . css ( 'display' ) ) . not . toBe ( 'none' )
57- expect ( messageNotificationsContainer . css ( 'display' ) ) . not . toBe ( 'none' )
58- expect ( minimizeButtonIcon . hasClass ( 'fa-minus' ) ) . toBeTruthy ( )
59- expect ( minimizeButtonIcon . hasClass ( 'fa-plus' ) ) . not . toBeTruthy ( )
60- expect ( minimizeButtonText . css ( 'display' ) ) . not . toBe ( 'none' )
50+ expect ( minimizeButton . css ( 'display' ) ) . not . toBe ( 'none' )
51+ expect ( messageNotificationsContainer . css ( 'display' ) ) . not . toBe ( 'none' )
52+ expect ( minimizeButtonIcon . hasClass ( 'fa-minus' ) ) . toBe ( true )
53+ expect ( minimizeButtonIcon . hasClass ( 'fa-plus' ) ) . toBe ( false )
54+ expect ( minimizeButtonText . css ( 'display' ) ) . not . toBe ( 'none' )
6155
62- minimizeButton . click ( )
56+ minimizeButton . click ( )
6357
64- expect ( messageNotificationsContainer . css ( 'display' ) ) . toBe ( 'none' )
65- expect ( minimizeButtonIcon . hasClass ( 'fa-minus' ) ) . not . toBeTruthy ( )
66- expect ( minimizeButtonIcon . hasClass ( 'fa-plus' ) ) . toBeTruthy ( )
67- expect ( minimizeButtonText . css ( 'display' ) ) . toBe ( 'none' )
58+ expect ( messageNotificationsContainer . css ( 'display' ) ) . toBe ( 'none' )
59+ expect ( minimizeButtonIcon . hasClass ( 'fa-minus' ) ) . toBe ( false )
60+ expect ( minimizeButtonIcon . hasClass ( 'fa-plus' ) ) . toBe ( true )
61+ expect ( minimizeButtonText . css ( 'display' ) ) . toBe ( 'none' )
6862
69- minimizeButton . click ( )
70-
71- expect ( messageNotificationsContainer . css ( 'display' ) ) . not . toBe ( 'none' )
72- expect ( minimizeButtonIcon . hasClass ( 'fa-minus' ) ) . toBeTruthy ( )
73- expect ( minimizeButtonIcon . hasClass ( 'fa-plus' ) ) . not . toBeTruthy ( )
74- expect ( minimizeButtonText . css ( 'display' ) ) . not . toBe ( 'none' )
63+ minimizeButton . click ( )
7564
76- done ( )
77- } catch ( error ) {
78- done ( error )
79- }
80- } )
65+ expect ( messageNotificationsContainer . css ( 'display' ) ) . not . toBe ( 'none' )
66+ expect ( minimizeButtonIcon . hasClass ( 'fa-minus' ) ) . toBe ( true )
67+ expect ( minimizeButtonIcon . hasClass ( 'fa-plus' ) ) . toBe ( false )
68+ expect ( minimizeButtonText . css ( 'display' ) ) . not . toBe ( 'none' )
8169 } )
8270
83- test ( 'should show only badges where there exists at least one notification matching the badge level when minimized' , ( done ) => {
84- $ ( ( ) => {
85- try {
86- const minimizeButtonBadgeError = minimizeButton . children ( '.bg-danger' )
87- const minimizeButtonBadgeInfo = minimizeButton . children ( '.bg-success' )
88- const minimizeButtonBadgeWarning = minimizeButton . children ( '.bg-warning' )
71+ test ( 'should show only badges where there exists at least one notification matching the badge level when minimized' , ( ) => {
72+ const minimizeButtonBadgeError = minimizeButton . children ( '.bg-danger' )
73+ const minimizeButtonBadgeInfo = minimizeButton . children ( '.bg-success' )
74+ const minimizeButtonBadgeWarning = minimizeButton . children ( '.bg-warning' )
8975
90- expect ( minimizeButton . css ( 'display' ) ) . not . toBe ( 'none' )
76+ expect ( minimizeButton . css ( 'display' ) ) . not . toBe ( 'none' )
9177
92- minimizeButton . click ( )
78+ minimizeButton . click ( )
9379
94- expect ( minimizeButtonBadgeInfo . css ( 'display' ) ) . not . toContain ( 'none' )
95- expect ( minimizeButtonBadgeInfo . text ( ) ) . toBe ( '1' )
96- expect ( minimizeButtonBadgeError . css ( 'display' ) ) . toContain ( 'none' )
97- expect ( minimizeButtonBadgeWarning . css ( 'display' ) ) . toContain ( 'none' )
80+ expect ( minimizeButtonBadgeInfo . css ( 'display' ) ) . not . toContain ( 'none' )
81+ expect ( minimizeButtonBadgeInfo . text ( ) ) . toBe ( '1' )
82+ expect ( minimizeButtonBadgeError . css ( 'display' ) ) . toContain ( 'none' )
83+ expect ( minimizeButtonBadgeWarning . css ( 'display' ) ) . toContain ( 'none' )
9884
99- minimizeButton . click ( )
100- const notification2 = notifier . notify ( 'msg' , 'error' )
101- notifier . notify ( 'msg' , 'warn' )
85+ minimizeButton . click ( )
86+ const notification2 = notifier . notify ( 'msg' , 'error' )
87+ notifier . notify ( 'msg' , 'warn' )
10288
103- minimizeButton . click ( )
104- expect ( minimizeButtonBadgeInfo . css ( 'display' ) ) . not . toContain ( 'none' )
105- expect ( minimizeButtonBadgeInfo . text ( ) ) . toBe ( '1' )
106- expect ( minimizeButtonBadgeError . css ( 'display' ) ) . not . toContain ( 'none' )
107- expect ( minimizeButtonBadgeError . text ( ) ) . toBe ( '1' )
108- expect ( minimizeButtonBadgeWarning . css ( 'display' ) ) . not . toContain ( 'none' )
109- expect ( minimizeButtonBadgeWarning . text ( ) ) . toBe ( '1' )
89+ minimizeButton . click ( )
90+ expect ( minimizeButtonBadgeInfo . css ( 'display' ) ) . not . toContain ( 'none' )
91+ expect ( minimizeButtonBadgeInfo . text ( ) ) . toBe ( '1' )
92+ expect ( minimizeButtonBadgeError . css ( 'display' ) ) . not . toContain ( 'none' )
93+ expect ( minimizeButtonBadgeError . text ( ) ) . toBe ( '1' )
94+ expect ( minimizeButtonBadgeWarning . css ( 'display' ) ) . not . toContain ( 'none' )
95+ expect ( minimizeButtonBadgeWarning . text ( ) ) . toBe ( '1' )
11096
111- minimizeButton . click ( )
112- notification2 . dismiss ( )
97+ minimizeButton . click ( )
98+ notification2 . dismiss ( )
11399
114- minimizeButton . click ( )
115- expect ( minimizeButtonBadgeInfo . css ( 'display' ) ) . not . toContain ( 'none' )
116- expect ( minimizeButtonBadgeInfo . text ( ) ) . toBe ( '1' )
117- expect ( minimizeButtonBadgeError . css ( 'display' ) ) . toContain ( 'none' )
118- expect ( minimizeButtonBadgeWarning . css ( 'display' ) ) . not . toContain ( 'none' )
119- expect ( minimizeButtonBadgeWarning . text ( ) ) . toBe ( '1' )
120-
121- done ( )
122- } catch ( error ) {
123- done ( error )
124- }
125- } )
100+ minimizeButton . click ( )
101+ expect ( minimizeButtonBadgeInfo . css ( 'display' ) ) . not . toContain ( 'none' )
102+ expect ( minimizeButtonBadgeInfo . text ( ) ) . toBe ( '1' )
103+ expect ( minimizeButtonBadgeError . css ( 'display' ) ) . toContain ( 'none' )
104+ expect ( minimizeButtonBadgeWarning . css ( 'display' ) ) . not . toContain ( 'none' )
105+ expect ( minimizeButtonBadgeWarning . text ( ) ) . toBe ( '1' )
126106 } )
127107 } )
128108
129109 describe ( 'notify' , ( ) => {
130- test ( "displays a green notification when passed a message and level='info'" , ( done ) => {
110+ test ( "displays a green notification when passed a message and level='info'" , ( ) => {
131111 const notificationMessage = "'Y$deH[|%ROii]jy"
132112
133- $ ( ( ) => {
134- try {
135- // Clear any existing notifications from previous tests
136- notificationsElement . find ( '.messages' ) . empty ( )
113+ // Clear any existing notifications from previous tests
114+ notificationsElement . find ( '.messages' ) . empty ( )
137115
138- notifier . notify ( notificationMessage , 'info' )
116+ notifier . notify ( notificationMessage , 'info' )
139117
140- const successMessages = notificationsElement . children ( '.messages' ) . find ( '.success-notification' )
118+ const successMessages = notificationsElement . children ( '.messages' ) . find ( '.success-notification' )
141119
142- expect ( successMessages . length ) . toBe ( 1 )
143- expect ( successMessages [ 0 ] . innerHTML ) . toContain ( notificationMessage )
144- done ( )
145- } catch ( error ) {
146- done ( error )
147- }
148- } )
120+ expect ( successMessages . length ) . toBe ( 1 )
121+ expect ( successMessages [ 0 ] . innerHTML ) . toContain ( notificationMessage )
149122 } )
150123
151- test ( "displays a red notification when passed a message and level='error'" , ( done ) => {
124+ test ( "displays a red notification when passed a message and level='error'" , ( ) => {
152125 const notificationMessage = '\\+!h0bbH"yN7dx9.'
153126
154- $ ( ( ) => {
155- try {
156- notifier . notify ( notificationMessage , 'error' )
127+ notifier . notify ( notificationMessage , 'error' )
157128
158- const failureMessages = notificationsElement . find ( '.danger-notification' )
129+ const failureMessages = notificationsElement . find ( '.danger-notification' )
159130
160- expect ( failureMessages . length ) . toBe ( 1 )
161- expect ( failureMessages [ 0 ] . innerHTML ) . toContain ( notificationMessage )
162- done ( )
163- } catch ( error ) {
164- done ( error )
165- }
166- } )
131+ expect ( failureMessages . length ) . toBe ( 1 )
132+ expect ( failureMessages [ 0 ] . innerHTML ) . toContain ( notificationMessage )
167133 } )
168134
169- test ( 'displays the minimize button after no notifications were present before' , ( done ) => {
170- $ ( ( ) => {
171- try {
172- const messageNotificationsContainer = notificationsElement . find ( '.messages' )
173- const minimizeButton = notificationsElement . find ( '#toggle-minimize-notifications' )
135+ test ( 'displays the minimize button after no notifications were present before' , ( ) => {
136+ const messageNotificationsContainer = notificationsElement . find ( '.messages' )
137+ const minimizeButton = notificationsElement . find ( '#toggle-minimize-notifications' )
174138
175- expect ( minimizeButton . css ( 'display' ) ) . toBe ( 'none' )
176- expect ( messageNotificationsContainer . children ( ) . length ) . toBe ( 0 )
139+ expect ( minimizeButton . css ( 'display' ) ) . toBe ( 'none' )
140+ expect ( messageNotificationsContainer . children ( ) . length ) . toBe ( 0 )
177141
178- notifier . notify ( 'msg' , 'info' )
142+ notifier . notify ( 'msg' , 'info' )
179143
180- expect ( minimizeButton . css ( 'display' ) ) . not . toBe ( 'none' )
181- expect ( messageNotificationsContainer . children ( ) . length ) . toBeGreaterThan ( 0 )
182-
183- done ( )
184- } catch ( error ) {
185- done ( error )
186- }
187- } )
144+ expect ( minimizeButton . css ( 'display' ) ) . not . toBe ( 'none' )
145+ expect ( messageNotificationsContainer . children ( ) . length ) . toBeGreaterThan ( 0 )
188146 } )
189147
190148 describe ( 'when the notifier is minimized' , ( ) => {
0 commit comments