66import { Component , ElementRef , viewChild } from '@angular/core' ;
77import { ComponentFixture , TestBed } from '@angular/core/testing' ;
88
9- import { NzVariant } from 'ng-zorro-antd/core/types' ;
9+ import { NzSizeLDSType , NzVariant } from 'ng-zorro-antd/core/types' ;
1010
1111import { NzInputModule } from './input.module' ;
1212
13- describe ( 'input-wrapper with affixes or addons ' , ( ) => {
13+ describe ( 'input-wrapper' , ( ) => {
1414 let component : InputWithAffixesAndAddonsTestComponent ;
1515 let fixture : ComponentFixture < InputWithAffixesAndAddonsTestComponent > ;
1616
@@ -21,129 +21,168 @@ describe('input-wrapper with affixes or addons', () => {
2121 } ) ;
2222
2323 it ( 'should be apply affix classes' , ( ) => {
24- expect ( component . withAffixes ( ) . nativeElement . classList ) . toContain ( 'ant-input-affix-wrapper' ) ;
24+ expect ( component . withPropAffixes ( ) . nativeElement . classList ) . toContain ( 'ant-input-affix-wrapper' ) ;
25+ expect ( component . withContentAffixes ( ) . nativeElement . classList ) . toContain ( 'ant-input-affix-wrapper' ) ;
2526 } ) ;
2627
2728 it ( 'should be apply addon classes' , ( ) => {
28- expect ( component . withAddons ( ) . nativeElement . classList ) . toContain ( 'ant-input-group-wrapper' ) ;
29+ expect ( component . withPropAddons ( ) . nativeElement . classList ) . toContain ( 'ant-input-group-wrapper' ) ;
30+ expect ( component . withContentAddons ( ) . nativeElement . classList ) . toContain ( 'ant-input-group-wrapper' ) ;
2931 } ) ;
3032
3133 it ( 'should be apply mix classes' , ( ) => {
32- expect ( component . withMix ( ) . nativeElement . classList ) . toContain ( 'ant-input-group-wrapper' ) ;
33- expect ( component . withMix ( ) . nativeElement . querySelector ( '.ant-input-affix-wrapper' ) ) . toBeTruthy ( ) ;
34+ expect ( component . withPropMix ( ) . nativeElement . classList ) . toContain ( 'ant-input-group-wrapper' ) ;
35+ expect ( component . withPropMix ( ) . nativeElement . classList ) . toContain ( 'ant-input-group-wrapper' ) ;
36+ expect ( component . withContentMix ( ) . nativeElement . classList ) . toContain ( 'ant-input-group-wrapper' ) ;
37+ expect ( component . withContentMix ( ) . nativeElement . querySelector ( '.ant-input-affix-wrapper' ) ) . toBeTruthy ( ) ;
3438 } ) ;
3539
3640 it ( 'should be not apply affix or addon classes when only input is present' , ( ) => {
3741 expect ( component . onlyInput ( ) . nativeElement . classList ) . not . toContain ( 'ant-input-group-wrapper' ) ;
3842 expect ( component . onlyInput ( ) . nativeElement . classList ) . not . toContain ( 'ant-input-affix-wrapper' ) ;
3943 } ) ;
4044
45+ it ( 'should be apply size class' , ( ) => {
46+ component . size = 'large' ;
47+ fixture . detectChanges ( ) ;
48+ expect ( component . withPropAffixes ( ) . nativeElement . classList ) . toContain ( 'ant-input-affix-wrapper-lg' ) ;
49+ expect ( component . withPropAddons ( ) . nativeElement . classList ) . toContain ( 'ant-input-group-wrapper-lg' ) ;
50+ component . size = 'small' ;
51+ fixture . detectChanges ( ) ;
52+ expect ( component . withPropAffixes ( ) . nativeElement . classList ) . toContain ( 'ant-input-affix-wrapper-sm' ) ;
53+ expect ( component . withPropAddons ( ) . nativeElement . classList ) . toContain ( 'ant-input-group-wrapper-sm' ) ;
54+ } ) ;
55+
4156 it ( 'should be apply disabled class' , ( ) => {
4257 component . disabled = true ;
4358 fixture . detectChanges ( ) ;
44- expect ( component . withAffixes ( ) . nativeElement . classList ) . toContain ( 'ant-input-affix-wrapper-disabled' ) ;
59+ expect ( component . withContentAffixes ( ) . nativeElement . classList ) . toContain ( 'ant-input-affix-wrapper-disabled' ) ;
4560 } ) ;
4661
4762 it ( 'should be apply readonly class' , ( ) => {
4863 component . readonly = true ;
4964 fixture . detectChanges ( ) ;
50- expect ( component . withAffixes ( ) . nativeElement . classList ) . toContain ( 'ant-input-affix-wrapper-readonly' ) ;
65+ expect ( component . withContentAffixes ( ) . nativeElement . classList ) . toContain ( 'ant-input-affix-wrapper-readonly' ) ;
5166 } ) ;
5267
5368 describe ( 'should be apply variant class' , ( ) => {
5469 it ( 'filled' , ( ) => {
5570 fixture . detectChanges ( ) ;
56- expect ( component . withAffixes ( ) . nativeElement . classList ) . not . toContain ( 'ant-input-affix-wrapper-filled' ) ;
57- expect ( component . withAddons ( ) . nativeElement . classList ) . not . toContain ( 'ant-input-group-wrapper-filled' ) ;
58- expect ( component . withMix ( ) . nativeElement . classList ) . not . toContain ( 'ant-input-group-wrapper-filled' ) ;
59- expect ( component . withMix ( ) . nativeElement . querySelector ( '.ant-input-affix-wrapper-filled' ) ) . toBeFalsy ( ) ;
71+ expect ( component . withContentAffixes ( ) . nativeElement . classList ) . not . toContain ( 'ant-input-affix-wrapper-filled' ) ;
72+ expect ( component . withContentAddons ( ) . nativeElement . classList ) . not . toContain ( 'ant-input-group-wrapper-filled' ) ;
73+ expect ( component . withContentMix ( ) . nativeElement . classList ) . not . toContain ( 'ant-input-group-wrapper-filled' ) ;
74+ expect ( component . withContentMix ( ) . nativeElement . querySelector ( '.ant-input-affix-wrapper-filled' ) ) . toBeFalsy ( ) ;
6075 component . variant = 'filled' ;
6176 fixture . detectChanges ( ) ;
62- expect ( component . withAffixes ( ) . nativeElement . classList ) . toContain ( 'ant-input-affix-wrapper-filled' ) ;
63- expect ( component . withAddons ( ) . nativeElement . classList ) . toContain ( 'ant-input-group-wrapper-filled' ) ;
64- expect ( component . withMix ( ) . nativeElement . classList ) . toContain ( 'ant-input-group-wrapper-filled' ) ;
65- expect ( component . withMix ( ) . nativeElement . querySelector ( '.ant-input-affix-wrapper-filled' ) ) . toBeTruthy ( ) ;
77+ expect ( component . withContentAffixes ( ) . nativeElement . classList ) . toContain ( 'ant-input-affix-wrapper-filled' ) ;
78+ expect ( component . withContentAddons ( ) . nativeElement . classList ) . toContain ( 'ant-input-group-wrapper-filled' ) ;
79+ expect ( component . withContentMix ( ) . nativeElement . classList ) . toContain ( 'ant-input-group-wrapper-filled' ) ;
80+ expect ( component . withContentMix ( ) . nativeElement . querySelector ( '.ant-input-affix-wrapper-filled' ) ) . toBeTruthy ( ) ;
6681 } ) ;
6782
6883 it ( 'borderless' , ( ) => {
6984 fixture . detectChanges ( ) ;
70- expect ( component . withAffixes ( ) . nativeElement . classList ) . not . toContain ( 'ant-input-affix-wrapper-borderless' ) ;
71- expect ( component . withAddons ( ) . nativeElement . classList ) . not . toContain ( 'ant-input-group-wrapper-borderless' ) ;
72- expect ( component . withMix ( ) . nativeElement . classList ) . not . toContain ( 'ant-input-group-wrapper-borderless' ) ;
73- expect ( component . withMix ( ) . nativeElement . querySelector ( '.ant-input-affix-wrapper-borderless' ) ) . toBeFalsy ( ) ;
85+ expect ( component . withContentAffixes ( ) . nativeElement . classList ) . not . toContain (
86+ 'ant-input-affix-wrapper-borderless'
87+ ) ;
88+ expect ( component . withContentAddons ( ) . nativeElement . classList ) . not . toContain ( 'ant-input-group-wrapper-borderless' ) ;
89+ expect ( component . withContentMix ( ) . nativeElement . classList ) . not . toContain ( 'ant-input-group-wrapper-borderless' ) ;
90+ expect ( component . withContentMix ( ) . nativeElement . querySelector ( '.ant-input-affix-wrapper-borderless' ) ) . toBeFalsy ( ) ;
7491 component . variant = 'borderless' ;
7592 fixture . detectChanges ( ) ;
76- expect ( component . withAffixes ( ) . nativeElement . classList ) . toContain ( 'ant-input-affix-wrapper-borderless' ) ;
77- expect ( component . withAddons ( ) . nativeElement . classList ) . toContain ( 'ant-input-group-wrapper-borderless' ) ;
78- expect ( component . withMix ( ) . nativeElement . classList ) . toContain ( 'ant-input-group-wrapper-borderless' ) ;
79- expect ( component . withMix ( ) . nativeElement . querySelector ( '.ant-input-affix-wrapper-borderless' ) ) . toBeTruthy ( ) ;
93+ expect ( component . withContentAffixes ( ) . nativeElement . classList ) . toContain ( 'ant-input-affix-wrapper-borderless' ) ;
94+ expect ( component . withContentAddons ( ) . nativeElement . classList ) . toContain ( 'ant-input-group-wrapper-borderless' ) ;
95+ expect ( component . withContentMix ( ) . nativeElement . classList ) . toContain ( 'ant-input-group-wrapper-borderless' ) ;
96+ expect (
97+ component . withContentMix ( ) . nativeElement . querySelector ( '.ant-input-affix-wrapper-borderless' )
98+ ) . toBeTruthy ( ) ;
8099 } ) ;
81100
82101 it ( 'underlined' , ( ) => {
83102 fixture . detectChanges ( ) ;
84- expect ( component . withAffixes ( ) . nativeElement . classList ) . not . toContain ( 'ant-input-affix-wrapper-underlined' ) ;
85- expect ( component . withAddons ( ) . nativeElement . classList ) . not . toContain ( 'ant-input-group-wrapper-underlined' ) ;
86- expect ( component . withMix ( ) . nativeElement . classList ) . not . toContain ( 'ant-input-group-wrapper-underlined' ) ;
87- expect ( component . withMix ( ) . nativeElement . querySelector ( '.ant-input-affix-wrapper-underlined' ) ) . toBeFalsy ( ) ;
103+ expect ( component . withContentAffixes ( ) . nativeElement . classList ) . not . toContain (
104+ 'ant-input-affix-wrapper-underlined'
105+ ) ;
106+ expect ( component . withContentAddons ( ) . nativeElement . classList ) . not . toContain ( 'ant-input-group-wrapper-underlined' ) ;
107+ expect ( component . withContentMix ( ) . nativeElement . classList ) . not . toContain ( 'ant-input-group-wrapper-underlined' ) ;
108+ expect ( component . withContentMix ( ) . nativeElement . querySelector ( '.ant-input-affix-wrapper-underlined' ) ) . toBeFalsy ( ) ;
88109 component . variant = 'underlined' ;
89110 fixture . detectChanges ( ) ;
90- expect ( component . withAffixes ( ) . nativeElement . classList ) . toContain ( 'ant-input-affix-wrapper-underlined' ) ;
91- expect ( component . withAddons ( ) . nativeElement . classList ) . toContain ( 'ant-input-group-wrapper-underlined' ) ;
92- expect ( component . withMix ( ) . nativeElement . classList ) . toContain ( 'ant-input-group-wrapper-underlined' ) ;
93- expect ( component . withMix ( ) . nativeElement . querySelector ( '.ant-input-affix-wrapper-underlined' ) ) . toBeTruthy ( ) ;
111+ expect ( component . withContentAffixes ( ) . nativeElement . classList ) . toContain ( 'ant-input-affix-wrapper-underlined' ) ;
112+ expect ( component . withContentAddons ( ) . nativeElement . classList ) . toContain ( 'ant-input-group-wrapper-underlined' ) ;
113+ expect ( component . withContentMix ( ) . nativeElement . classList ) . toContain ( 'ant-input-group-wrapper-underlined' ) ;
114+ expect (
115+ component . withContentMix ( ) . nativeElement . querySelector ( '.ant-input-affix-wrapper-underlined' )
116+ ) . toBeTruthy ( ) ;
94117 } ) ;
95118 } ) ;
96119
97120 it ( 'should be handle focus / blur' , ( ) => {
98- let inputElement = component . withAffixes ( ) . nativeElement . querySelector ( 'input' ) ! ;
121+ let inputElement = component . withContentAffixes ( ) . nativeElement . querySelector ( 'input' ) ! ;
99122 inputElement . focus ( ) ;
100- expect ( component . withAffixes ( ) . nativeElement . classList ) . toContain ( 'ant-input-affix-wrapper-focused' ) ;
123+ expect ( component . withContentAffixes ( ) . nativeElement . classList ) . toContain ( 'ant-input-affix-wrapper-focused' ) ;
101124 inputElement . blur ( ) ;
102- expect ( component . withAffixes ( ) . nativeElement . classList ) . not . toContain ( 'ant-input-affix-wrapper-focused' ) ;
125+ expect ( component . withContentAffixes ( ) . nativeElement . classList ) . not . toContain ( 'ant-input-affix-wrapper-focused' ) ;
103126
104- inputElement = component . withMix ( ) . nativeElement . querySelector ( 'input' ) ! ;
127+ inputElement = component . withContentMix ( ) . nativeElement . querySelector ( 'input' ) ! ;
105128 inputElement . focus ( ) ;
106- expect ( component . withMix ( ) . nativeElement . querySelector ( '.ant-input-affix-wrapper-focused' ) ) . toBeTruthy ( ) ;
129+ expect ( component . withContentMix ( ) . nativeElement . querySelector ( '.ant-input-affix-wrapper-focused' ) ) . toBeTruthy ( ) ;
107130 inputElement . blur ( ) ;
108- expect ( component . withMix ( ) . nativeElement . querySelector ( '.ant-input-affix-wrapper-focused' ) ) . toBeFalsy ( ) ;
131+ expect ( component . withContentMix ( ) . nativeElement . querySelector ( '.ant-input-affix-wrapper-focused' ) ) . toBeFalsy ( ) ;
109132 } ) ;
110133} ) ;
111134
112135@Component ( {
113136 imports : [ NzInputModule ] ,
114137 template : `
115- <nz-input-wrapper #withAffixes>
138+ <nz-input-wrapper #withPropAffixes nzPrefix="Prefix" nzSuffix="Suffix">
139+ <input nz-input [nzSize]="size" [nzVariant]="variant" [disabled]="disabled" [readonly]="readonly" />
140+ </nz-input-wrapper>
141+
142+ <nz-input-wrapper #withContentAffixes>
116143 <span nzInputPrefix>Prefix</span>
117- <input nz-input [nzVariant]="variant" [disabled]="disabled" [readonly]="readonly" />
144+ <input nz-input [nzSize]="size" [ nzVariant]="variant" [disabled]="disabled" [readonly]="readonly" />
118145 <span nzInputSuffix>Suffix</span>
119146 </nz-input-wrapper>
120147
121- <nz-input-wrapper #withAddons>
148+ <nz-input-wrapper #withPropAddons nzAddonBefore="Before" nzAddonAfter="After">
149+ <input nz-input [nzSize]="size" [nzVariant]="variant" [disabled]="disabled" [readonly]="readonly" />
150+ </nz-input-wrapper>
151+
152+ <nz-input-wrapper #withContentAddons>
122153 <span nzInputAddonBefore>Before</span>
123- <input nz-input [nzVariant]="variant" [disabled]="disabled" [readonly]="readonly" />
154+ <input nz-input [nzSize]="size" [ nzVariant]="variant" [disabled]="disabled" [readonly]="readonly" />
124155 <span nzInputAddonAfter>After</span>
125156 </nz-input-wrapper>
126157
127- <nz-input-wrapper #withMix>
158+ <nz-input-wrapper #withPropMix nzAddonBefore="Before" nzAddonAfter="After" nzPrefix="Prefix" nzSuffix="Suffix">
159+ <input nz-input [nzSize]="size" [nzVariant]="variant" [disabled]="disabled" [readonly]="readonly" />
160+ </nz-input-wrapper>
161+
162+ <nz-input-wrapper #withContentMix>
128163 <span nzInputAddonBefore>Before</span>
129164 <span nzInputPrefix>Prefix</span>
130- <input nz-input [nzVariant]="variant" [disabled]="disabled" [readonly]="readonly" />
165+ <input nz-input [nzSize]="size" [ nzVariant]="variant" [disabled]="disabled" [readonly]="readonly" />
131166 <span nzInputSuffix>Suffix</span>
132167 <span nzInputAddonAfter>After</span>
133168 </nz-input-wrapper>
134169
135170 <nz-input-wrapper #onlyInput>
136- <input nz-input [nzVariant]="variant" [disabled]="disabled" [readonly]="readonly" />
171+ <input nz-input [nzSize]="size" [ nzVariant]="variant" [disabled]="disabled" [readonly]="readonly" />
137172 </nz-input-wrapper>
138173 `
139174} )
140175class InputWithAffixesAndAddonsTestComponent {
176+ size : NzSizeLDSType = 'default' ;
141177 disabled = false ;
142178 readonly = false ;
143179 variant : NzVariant = 'outlined' ;
144180
145- readonly withAffixes = viewChild . required ( 'withAffixes' , { read : ElementRef } ) ;
146- readonly withAddons = viewChild . required ( 'withAddons' , { read : ElementRef } ) ;
147- readonly withMix = viewChild . required ( 'withMix' , { read : ElementRef } ) ;
181+ readonly withPropAffixes = viewChild . required ( 'withPropAffixes' , { read : ElementRef } ) ;
182+ readonly withContentAffixes = viewChild . required ( 'withContentAffixes' , { read : ElementRef } ) ;
183+ readonly withPropAddons = viewChild . required ( 'withPropAddons' , { read : ElementRef } ) ;
184+ readonly withContentAddons = viewChild . required ( 'withContentAddons' , { read : ElementRef } ) ;
185+ readonly withPropMix = viewChild . required ( 'withPropMix' , { read : ElementRef } ) ;
186+ readonly withContentMix = viewChild . required ( 'withContentMix' , { read : ElementRef } ) ;
148187 readonly onlyInput = viewChild . required ( 'onlyInput' , { read : ElementRef } ) ;
149188}
0 commit comments