@@ -10,14 +10,16 @@ module(
10
10
setupRenderingTest ( hooks ) ;
11
11
12
12
hooks . beforeEach ( function ( ) {
13
+ this . set ( 'model' , {
14
+ prop : [ 'foo' ] ,
15
+ } ) ;
13
16
this . set ( 'options' , [ 'foo' , 'bar' ] ) ;
14
- this . set ( 'prop' , [ 'foo' ] ) ;
15
17
} ) ;
16
18
17
19
test ( 'it renders as blockless element' , async function ( assert ) {
18
20
await render ( hbs `
19
- <BsForm @model={{this}} as |form|>
20
- <form.element @controlType="power-select-multiple" @property="prop" @options={{options}} />
21
+ <BsForm @model={{this.model }} as |form|>
22
+ <form.element @controlType="power-select-multiple" @property="prop" @options={{this. options}} />
21
23
</BsForm>` ) ;
22
24
assert . dom ( '.ember-power-select-trigger' ) . exists ( { count : 1 } ) ;
23
25
assert . equal (
@@ -31,13 +33,13 @@ module(
31
33
assert . dom ( findAll ( '.ember-power-select-option' ) [ 0 ] ) . hasText ( 'foo' ) ;
32
34
assert . dom ( findAll ( '.ember-power-select-option' ) [ 1 ] ) . hasText ( 'bar' ) ;
33
35
await click ( findAll ( '.ember-power-select-option' ) [ 1 ] ) ;
34
- assert . deepEqual ( this . prop , [ 'foo' , 'bar' ] ) ;
36
+ assert . deepEqual ( this . model . prop , [ 'foo' , 'bar' ] ) ;
35
37
} ) ;
36
38
37
39
test ( 'it renders as blockless control component' , async function ( assert ) {
38
40
await render ( hbs `
39
- <BsForm @model={{this}} as |form|>
40
- <form.element @controlType="power-select-multiple" @property="prop" @options={{options}} as |el|>
41
+ <BsForm @model={{this.model }} as |form|>
42
+ <form.element @controlType="power-select-multiple" @property="prop" @options={{this. options}} as |el|>
41
43
<el.control />
42
44
</form.element>
43
45
</BsForm>` ) ;
@@ -53,13 +55,13 @@ module(
53
55
assert . dom ( findAll ( '.ember-power-select-option' ) [ 0 ] ) . hasText ( 'foo' ) ;
54
56
assert . dom ( findAll ( '.ember-power-select-option' ) [ 1 ] ) . hasText ( 'bar' ) ;
55
57
await click ( findAll ( '.ember-power-select-option' ) [ 1 ] ) ;
56
- assert . deepEqual ( this . prop , [ 'foo' , 'bar' ] ) ;
58
+ assert . deepEqual ( this . model . prop , [ 'foo' , 'bar' ] ) ;
57
59
} ) ;
58
60
59
61
test ( 'it renders as block control component' , async function ( assert ) {
60
62
await render ( hbs `
61
- <BsForm @model={{this}} as |form|>
62
- <form.element @controlType="power-select-multiple" @property="prop" @options={{options}} as |el|>
63
+ <BsForm @model={{this.model }} as |form|>
64
+ <form.element @controlType="power-select-multiple" @property="prop" @options={{this. options}} as |el|>
63
65
<el.control as |val|>
64
66
{{val}}
65
67
</el.control>
@@ -77,21 +79,21 @@ module(
77
79
assert . dom ( findAll ( '.ember-power-select-option' ) [ 0 ] ) . hasText ( 'foo' ) ;
78
80
assert . dom ( findAll ( '.ember-power-select-option' ) [ 1 ] ) . hasText ( 'bar' ) ;
79
81
await click ( findAll ( '.ember-power-select-option' ) [ 1 ] ) ;
80
- assert . deepEqual ( this . prop , [ 'foo' , 'bar' ] ) ;
82
+ assert . deepEqual ( this . model . prop , [ 'foo' , 'bar' ] ) ;
81
83
} ) ;
82
84
83
85
test ( 'it can disable select' , async function ( assert ) {
84
86
await render ( hbs `
85
- <BsForm @model={{this}} @ disabled={{true}} as |form|>
86
- <form.element @controlType="power-select-multiple" @property="prop" @options={{options}} />
87
+ <BsForm @disabled={{true}} as |form|>
88
+ <form.element @controlType="power-select-multiple" @property="prop" @options={{this. options}} />
87
89
</BsForm>` ) ;
88
90
assert . ok (
89
91
find ( '.ember-power-select-trigger' ) . getAttribute ( 'aria-disabled' )
90
92
) ;
91
93
92
94
await render ( hbs `
93
- <BsForm @model={{this}} @ disabled={{true}} as |form|>
94
- <form.element @controlType="power-select-multiple" @property="prop" @options={{options}} as |el|>
95
+ <BsForm @disabled={{true}} as |form|>
96
+ <form.element @controlType="power-select-multiple" @property="prop" @options={{this. options}} as |el|>
95
97
<el.control as |val|>
96
98
{{val}}
97
99
</el.control>
@@ -107,10 +109,12 @@ module(
107
109
'options' ,
108
110
this . options . map ( ( title ) => ( { title } ) )
109
111
) ;
110
- this . set ( 'prop' , [ this . options [ 0 ] ] ) ;
112
+ this . set ( 'model' , {
113
+ prop : [ this . options [ 0 ] ] ,
114
+ } ) ;
111
115
await render ( hbs `
112
- <BsForm @model={{this}} as |form|>
113
- <form.element @controlType="power-select-multiple" @property="prop" @options={{options}} @optionLabelPath="title" />
116
+ <BsForm @model={{this.model }} as |form|>
117
+ <form.element @controlType="power-select-multiple" @property="prop" @options={{this. options}} @optionLabelPath="title" />
114
118
</BsForm>` ) ;
115
119
assert . dom ( '.ember-power-select-trigger' ) . exists ( { count : 1 } ) ;
116
120
assert . equal (
@@ -124,13 +128,13 @@ module(
124
128
assert . dom ( findAll ( '.ember-power-select-option' ) [ 0 ] ) . hasText ( 'foo' ) ;
125
129
assert . dom ( findAll ( '.ember-power-select-option' ) [ 1 ] ) . hasText ( 'bar' ) ;
126
130
await click ( findAll ( '.ember-power-select-option' ) [ 1 ] ) ;
127
- assert . deepEqual ( this . prop , this . options ) ;
131
+ assert . deepEqual ( this . model . prop , this . options ) ;
128
132
} ) ;
129
133
130
134
test ( 'it passes power-select @options' , async function ( assert ) {
131
135
await render ( hbs `
132
- <BsForm @model={{this}} as |form|>
133
- <form.element @controlType="power-select-multiple" @property="prop2" @options={{options}} @placeholder="something" as |el|>
136
+ <BsForm as |form|>
137
+ <form.element @controlType="power-select-multiple" @property="prop2" @options={{this. options}} @placeholder="something" as |el|>
134
138
<el.control @searchEnabled={{false}} @triggerClass="form-control" />
135
139
</form.element>
136
140
</BsForm>` ) ;
@@ -142,8 +146,8 @@ module(
142
146
test ( 'it passes HTML attributes' , async function ( assert ) {
143
147
// HTML attributes are not applied to any element if `renderInPlace` is `false`
144
148
await render ( hbs `
145
- <BsForm @model={{hash}} as |form|>
146
- <form.element @controlType="power-select-multiple" @property="prop" @options={{array}} as |el|>
149
+ <BsForm as |form|>
150
+ <form.element @controlType="power-select-multiple" @property="prop" as |el|>
147
151
<el.control @renderInPlace={{true}} data-test-foo />
148
152
</form.element>
149
153
</BsForm>` ) ;
0 commit comments