1
- /* eslint-disable prettier/prettier */
2
1
import { module , test } from 'qunit' ;
3
2
import { setupRenderingTest } from 'ember-qunit' ;
4
- import { render , fillIn , waitUntil , find } from '@ember/test-helpers' ;
3
+ import { click , render , fillIn , waitUntil , find } from '@ember/test-helpers' ;
5
4
import hbs from 'htmlbars-inline-precompile' ;
6
- import { clickTrigger , selectChoose } from 'ember-power-select/test-support/helpers' ;
5
+ import {
6
+ clickTrigger ,
7
+ selectChoose ,
8
+ } from 'ember-power-select/test-support/helpers' ;
7
9
8
- module ( 'Integration | Component | paper-select' , function ( hooks ) {
10
+ module ( 'Integration | Component | paper-select' , function ( hooks ) {
9
11
setupRenderingTest ( hooks ) ;
10
12
11
- hooks . beforeEach ( function ( ) {
12
- this . set ( 'sizes' , [ 'small (12-inch)' , 'medium (14-inch)' , 'large (16-inch)' , 'insane (42-inch)' ] ) ;
13
+ hooks . beforeEach ( function ( ) {
14
+ this . set ( 'sizes' , [
15
+ 'small (12-inch)' ,
16
+ 'medium (14-inch)' ,
17
+ 'large (16-inch)' ,
18
+ 'insane (42-inch)' ,
19
+ ] ) ;
13
20
} ) ;
14
21
15
- test ( 'opens on click' , async function ( assert ) {
22
+ test ( 'opens on click' , async function ( assert ) {
16
23
await render ( hbs `{{#paper-select
17
24
disabled=disableSelect
18
25
placeholder="Size"
@@ -29,7 +36,7 @@ module('Integration | Component | paper-select', function(hooks) {
29
36
assert . dom ( 'md-select-menu' ) . exists ( ) ;
30
37
} ) ;
31
38
32
- test ( 'backdrop removed if select closed' , async function ( assert ) {
39
+ test ( 'backdrop removed if select closed' , async function ( assert ) {
33
40
await render ( hbs `{{#paper-select
34
41
disabled=disableSelect
35
42
placeholder="Size"
@@ -54,7 +61,7 @@ module('Integration | Component | paper-select', function(hooks) {
54
61
assert . dom ( 'md-backdrop' ) . doesNotExist ( ) ;
55
62
} ) ;
56
63
57
- test ( 'it can select an option' , async function ( assert ) {
64
+ test ( 'it can select an option' , async function ( assert ) {
58
65
await render ( hbs `{{#paper-select
59
66
disabled=disableSelect
60
67
placeholder="Size"
@@ -73,7 +80,46 @@ module('Integration | Component | paper-select', function(hooks) {
73
80
assert . equal ( this . selectedSize , 'large (16-inch)' ) ;
74
81
} ) ;
75
82
76
- test ( 'header is rendered above content' , async function ( assert ) {
83
+ test ( 'it can be disabled' , async function ( assert ) {
84
+ await render ( hbs `{{#paper-select
85
+ disabled=true
86
+ placeholder="Size"
87
+ options=sizes
88
+ selected=selectedSize
89
+ onChange=(action (mut selectedSize))
90
+ as |size|
91
+ }}
92
+ {{size}}
93
+ {{/paper-select}}` ) ;
94
+
95
+ assert . dom ( 'md-select' ) . exists ( ) ;
96
+ assert . dom ( 'md-select' ) . hasProperty ( 'disabled' , undefined ) ;
97
+ } ) ;
98
+
99
+ test ( 'it can be validated' , async function ( assert ) {
100
+ await render ( hbs `{{#paper-select
101
+ required=true
102
+ placeholder="Size"
103
+ options=sizes
104
+ selected=selectedSize
105
+ onChange=(action (mut selectedSize))
106
+ as |size|}}
107
+ {{size}}
108
+ {{/paper-select}}
109
+ <div id="not-paper-select"></div>` ) ;
110
+
111
+ assert . dom ( 'md-select' ) . exists ( ) ;
112
+ assert . dom ( 'md-select' ) . doesNotHaveClass ( 'ng-dirty' ) ;
113
+ assert . dom ( 'md-select' ) . doesNotHaveClass ( 'ng-invalid' ) ;
114
+
115
+ await clickTrigger ( 'md-input-container' ) ;
116
+ await click ( '#not-paper-select' ) ;
117
+
118
+ assert . dom ( 'md-select' ) . hasClass ( 'ng-dirty' ) ;
119
+ assert . dom ( 'md-select' ) . hasClass ( 'ng-invalid' ) ;
120
+ } ) ;
121
+
122
+ test ( 'header is rendered above content' , async function ( assert ) {
77
123
await render ( hbs `{{#paper-select
78
124
disabled=disableSelect
79
125
placeholder="Size"
@@ -92,7 +138,7 @@ module('Integration | Component | paper-select', function(hooks) {
92
138
assert . dom ( 'md-select-menu > md-content' ) . exists ( ) ;
93
139
} ) ;
94
140
95
- test ( 'it can search a value' , async function ( assert ) {
141
+ test ( 'it can search a value' , async function ( assert ) {
96
142
await render ( hbs `{{#paper-select
97
143
disabled=disableSelect
98
144
placeholder="Size"
@@ -116,7 +162,7 @@ module('Integration | Component | paper-select', function(hooks) {
116
162
assert . dom ( 'md-select-menu md-option' ) . hasText ( 'small (12-inch)' ) ;
117
163
} ) ;
118
164
119
- test ( 'it shows search message before entering search string' , async function ( assert ) {
165
+ test ( 'it shows search message before entering search string' , async function ( assert ) {
120
166
this . search = ( value ) => this . sizes . filter ( ( size ) => size . includes ( value ) ) ;
121
167
122
168
await render ( hbs `{{#paper-select
0 commit comments