@@ -12,11 +12,63 @@ describe('id', () => {
12
12
} )
13
13
} )
14
14
15
+ describe ( 'mount' , ( ) => {
16
+ const data = {
17
+ id : 1 ,
18
+ steps : [
19
+ {
20
+ header : { content : 'Header' } ,
21
+ inputs : [ ] ,
22
+ button : { content : 'Button' } ,
23
+ footer : { content : 'Footer' } ,
24
+ } ,
25
+ ]
26
+ }
27
+
28
+ const form = new Form ( data )
29
+
30
+ beforeEach ( ( ) => {
31
+ Hellotext . business = {
32
+ locale : {
33
+ white_label : {
34
+ powered_by : 'Powered by Hellotext' ,
35
+ }
36
+ } ,
37
+ features : {
38
+ white_label : false ,
39
+ }
40
+ }
41
+
42
+ document . body . innerHTML = ''
43
+ } )
44
+
45
+ it ( 'mounts the form' , ( ) => {
46
+ form . mount ( )
47
+ expect ( document . body . querySelector ( 'form' ) ) . not . toBeNull ( )
48
+ } )
49
+
50
+ describe ( 'when form has been completed' , ( ) => {
51
+ beforeEach ( ( ) => {
52
+ localStorage . setItem ( 'hello-form-1' , 'true' )
53
+ } )
54
+
55
+ it ( 'does not mount the form automatically' , ( ) => {
56
+ form . mount ( )
57
+ expect ( document . body . querySelector ( 'form' ) ) . toBeNull ( )
58
+ } )
59
+
60
+ it ( 'mounts the form when ifCompleted is false' , ( ) => {
61
+ form . mount ( { ifCompleted : false } )
62
+ expect ( document . body . querySelector ( 'form' ) ) . not . toBeNull ( )
63
+ } )
64
+ } )
65
+ } )
66
+
15
67
describe ( 'markAsCompleted' , ( ) => {
16
68
it ( 'saves the form as completed in localStorage' , ( ) => {
17
69
const form = new Form ( { id : 1 } )
18
70
form . markAsCompleted ( )
19
- expect ( localStorage . getItem ( 'hello-form-1' ) ) . toEqual ( 'completed' )
71
+ expect ( localStorage . getItem ( 'hello-form-1' ) ) . not . toBeNull ( )
20
72
} )
21
73
22
74
it ( 'emits a form:completed event' , ( ) => {
0 commit comments