@@ -11,13 +11,24 @@ define([
11
11
12
12
describe ( 'ui/js/modal/modal' , function ( ) {
13
13
14
- var element = $ ( '<div>Element</div>' ) ,
14
+ var element ,
15
+ modal ;
16
+
17
+ beforeEach ( function ( ) {
18
+ element = $ ( '<div id="element">Element</div>' ) ;
15
19
modal = element . modal ( { } ) . data ( 'mage-modal' ) ;
16
20
17
- $ ( element ) . append ( '<h1 class="modal-title"' +
18
- ' data-role="title">Title</h1>' +
19
- '<span class="modal-subtitle"' +
20
- ' data-role="subTitle"></span>' ) ;
21
+ $ ( element ) . append ( '<h1 class="modal-title"' +
22
+ ' data-role="title">Title</h1>' +
23
+ '<span class="modal-subtitle"' +
24
+ ' data-role="subTitle"></span>' ) ;
25
+ } ) ;
26
+
27
+ afterEach ( function ( ) {
28
+ $ ( '.modal-title' ) . remove ( ) ;
29
+ $ ( '#element' ) . remove ( ) ;
30
+
31
+ } ) ;
21
32
22
33
it ( 'Check for modal definition' , function ( ) {
23
34
expect ( modal ) . toBeDefined ( ) ;
@@ -32,12 +43,12 @@ define([
32
43
expect ( $ ( modal ) . length ) . toEqual ( 1 ) ;
33
44
} ) ;
34
45
35
- it ( 'Verify setTitle() method set title' , function ( ) {
46
+ it ( 'Verify set title' , function ( ) {
36
47
var newTitle = 'New modal title' ;
37
48
38
49
modal . setTitle ( newTitle ) ;
39
50
expect ( $ ( modal . options . modalTitle ) . text ( ) ) . toContain ( newTitle ) ;
40
- expect ( $ ( modal . options . modalTitle ) . find ( modal . options . modalSubTitle ) . length ) . toBe ( 2 ) ;
51
+ expect ( $ ( modal . options . modalTitle ) . find ( modal . options . modalSubTitle ) . length ) . toBe ( 1 ) ;
41
52
} ) ;
42
53
} ) ;
43
54
} ) ;
0 commit comments