@@ -11,17 +11,15 @@ describe('tags-input', () => {
11
11
expect ( page . rootInstance ) . toBeInstanceOf ( TagsInput ) ;
12
12
} ) ;
13
13
14
- it ( 'default label' , async ( ) => {
14
+ it ( 'default no label' , async ( ) => {
15
15
const page = await newSpecPage ( {
16
16
components : [ TagsInput ] ,
17
17
html : '<tags-input></tags-input>' ,
18
18
} ) ;
19
- const expectedLabel = 'Tags' ;
20
19
const component = page . rootInstance as TagsInput ;
21
- expect ( component . label ) . toEqual ( expectedLabel ) ;
22
- const input = page . root . shadowRoot . querySelector ( 'ion-input' ) ;
23
- expect ( input ) . not . toBeNull ( ) ;
24
- expect ( input . getAttribute ( 'label' ) ) . toEqualText ( expectedLabel ) ;
20
+ expect ( component . label ) . toBeUndefined ( ) ;
21
+ const label = page . root . querySelector ( 'ion-label' ) ;
22
+ expect ( label ) . toBeNull ( ) ;
25
23
} ) ;
26
24
27
25
it ( 'label is used' , async ( ) => {
@@ -32,9 +30,21 @@ describe('tags-input', () => {
32
30
} ) ;
33
31
const component = page . rootInstance as TagsInput ;
34
32
expect ( component . label ) . toEqual ( expectedLabel ) ;
35
- const input = page . root . shadowRoot . querySelector ( 'ion-input' ) ;
36
- expect ( input ) . not . toBeNull ( ) ;
37
- expect ( input . getAttribute ( 'label' ) ) . toEqualText ( expectedLabel ) ;
33
+ const label = page . root . querySelector ( 'ion-label' ) ;
34
+ expect ( label ) . toEqualText ( expectedLabel ) ;
35
+ } ) ;
36
+
37
+ it ( 'label placement is used' , async ( ) => {
38
+ const expectedLabel = 'My Label' ;
39
+ const page = await newSpecPage ( {
40
+ components : [ TagsInput ] ,
41
+ template : ( ) => ( < tags-input label = { expectedLabel } label-placement = "fixed" > </ tags-input > ) ,
42
+ } ) ;
43
+ const component = page . rootInstance as TagsInput ;
44
+ expect ( component . label ) . toEqual ( expectedLabel ) ;
45
+ const label = page . root . querySelector ( 'ion-label' ) ;
46
+ expect ( label ) . toEqualText ( expectedLabel ) ;
47
+ expect ( label ) . toEqualAttribute ( 'position' , 'fixed' ) ;
38
48
} ) ;
39
49
40
50
it ( 'uses tags' , async ( ) => {
@@ -45,7 +55,7 @@ describe('tags-input', () => {
45
55
} ) ;
46
56
const component = page . rootInstance as TagsInput ;
47
57
expect ( component . value ) . toEqual ( expectedTags ) ;
48
- const chips = page . root . shadowRoot . querySelectorAll < HTMLIonChipElement > ( 'ion-chip:not(.suggested)' ) ;
58
+ const chips = page . root . querySelectorAll < HTMLIonChipElement > ( 'ion-chip:not(.suggested)' ) ;
49
59
expect ( chips ) . toHaveLength ( expectedTags . length ) ;
50
60
} ) ;
51
61
@@ -58,7 +68,7 @@ describe('tags-input', () => {
58
68
const component = page . rootInstance as TagsInput ;
59
69
expect ( component . value ) . toEqual ( [ ] ) ;
60
70
expect ( component . suggestions ) . toEqual ( expectedTags ) ;
61
- const chips = page . root . shadowRoot . querySelectorAll < HTMLIonChipElement > ( 'ion-chip.suggested' ) ;
71
+ const chips = page . root . querySelectorAll < HTMLIonChipElement > ( 'ion-chip.suggested' ) ;
62
72
expect ( chips ) . toHaveLength ( expectedTags . length ) ;
63
73
} ) ;
64
74
@@ -69,13 +79,13 @@ describe('tags-input', () => {
69
79
components : [ TagsInput ] ,
70
80
template : ( ) => ( < tags-input value = { initialTags } onValueChanged = { handleValueChanged } > </ tags-input > ) ,
71
81
} ) ;
72
- let chips = page . root . shadowRoot . querySelectorAll < HTMLIonChipElement > ( 'ion-chip:not(.suggested)' ) ;
82
+ let chips = page . root . querySelectorAll < HTMLIonChipElement > ( 'ion-chip:not(.suggested)' ) ;
73
83
expect ( chips ) . toHaveLength ( initialTags . length ) ;
74
84
chips . forEach ( chip => chip . click ( ) ) ;
75
85
await page . waitForChanges ( ) ;
76
86
const component = page . rootInstance as TagsInput ;
77
87
expect ( component . internalValue ) . toEqual ( [ ] ) ;
78
- chips = page . root . shadowRoot . querySelectorAll < HTMLIonChipElement > ( 'ion-chip:not(.suggested)' ) ;
88
+ chips = page . root . querySelectorAll < HTMLIonChipElement > ( 'ion-chip:not(.suggested)' ) ;
79
89
expect ( chips ) . toHaveLength ( 0 ) ;
80
90
expect ( handleValueChanged ) . toHaveBeenCalledTimes ( initialTags . length ) ;
81
91
} ) ;
@@ -89,15 +99,15 @@ describe('tags-input', () => {
89
99
} ) ;
90
100
const component = page . rootInstance as TagsInput ;
91
101
expect ( component . value ) . toEqual ( [ ] ) ;
92
- const input = page . root . shadowRoot . querySelector ( 'ion-input' ) ;
102
+ const input = page . root . querySelector ( 'ion-input' ) ;
93
103
expect ( input ) . not . toBeNull ( ) ;
94
104
for ( const tag of expectedTags ) {
95
105
input . value = tag ;
96
106
input . dispatchEvent ( new KeyboardEvent ( 'keydown' , { 'key' : 'Enter' } ) ) ;
97
107
await page . waitForChanges ( ) ;
98
108
expect ( input . value ) . toEqualText ( '' ) ;
99
109
}
100
- const addedChips = page . root . shadowRoot . querySelectorAll < HTMLIonChipElement > ( 'ion-chip:not(.suggested)' ) ;
110
+ const addedChips = page . root . querySelectorAll < HTMLIonChipElement > ( 'ion-chip:not(.suggested)' ) ;
101
111
expect ( addedChips ) . toHaveLength ( expectedTags . length ) ;
102
112
expect ( handleValueChanged ) . toHaveBeenCalledTimes ( expectedTags . length ) ;
103
113
expect ( component . internalValue ) . toEqual ( expectedTags ) ;
@@ -110,15 +120,15 @@ describe('tags-input', () => {
110
120
components : [ TagsInput ] ,
111
121
template : ( ) => ( < tags-input suggestions = { initialSuggestions } onValueChanged = { handleValueChanged } > </ tags-input > ) ,
112
122
} ) ;
113
- let suggestedChips = page . root . shadowRoot . querySelectorAll < HTMLIonChipElement > ( 'ion-chip.suggested' ) ;
123
+ let suggestedChips = page . root . querySelectorAll < HTMLIonChipElement > ( 'ion-chip.suggested' ) ;
114
124
expect ( suggestedChips ) . toHaveLength ( initialSuggestions . length ) ;
115
125
suggestedChips . forEach ( chip => chip . click ( ) ) ;
116
126
await page . waitForChanges ( ) ;
117
127
const component = page . rootInstance as TagsInput ;
118
128
expect ( component . internalValue ) . toEqual ( initialSuggestions ) ;
119
- suggestedChips = page . root . shadowRoot . querySelectorAll < HTMLIonChipElement > ( 'ion-chip.suggested' ) ;
129
+ suggestedChips = page . root . querySelectorAll < HTMLIonChipElement > ( 'ion-chip.suggested' ) ;
120
130
expect ( suggestedChips ) . toHaveLength ( 0 ) ;
121
- const addedChips = page . root . shadowRoot . querySelectorAll < HTMLIonChipElement > ( 'ion-chip:not(.suggested)' ) ;
131
+ const addedChips = page . root . querySelectorAll < HTMLIonChipElement > ( 'ion-chip:not(.suggested)' ) ;
122
132
expect ( addedChips ) . toHaveLength ( initialSuggestions . length ) ;
123
133
expect ( handleValueChanged ) . toHaveBeenCalledTimes ( initialSuggestions . length ) ;
124
134
} ) ;
0 commit comments