Skip to content

Commit 3a81150

Browse files
committed
feat: be zoneless!
1 parent 386d005 commit 3a81150

File tree

5 files changed

+37
-31
lines changed

5 files changed

+37
-31
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Changelog
22

3-
## v0.16.0
3+
## v0.17.0
4+
- Be Zoneless compatible before angular 20.
5+
6+
- ## v0.16.0
47

58
- Drop `model()` in favor of `input()`.
69

angular.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@
3232
"builder": "@angular-builders/jest:run",
3333
"options": {
3434
"configPath": "./jest.config.ts",
35-
"polyfills": [
36-
"zone.js",
37-
"zone.js/testing"
38-
],
3935
"tsConfig": "./tsconfig.spec.json",
4036
"watch": false
4137
}

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
"ng-packagr": "^19.0.0",
6161
"rxjs": "^7.8.0",
6262
"typescript": "~5.7.2",
63-
"typescript-eslint": "^8.18.0",
64-
"zone.js": "~0.15.0"
63+
"typescript-eslint": "^8.18.0"
6564
}
6665
}

src/lib/components/intl-tel-input.component.spec.ts

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
1111
import { FormsModule, NgForm } from '@angular/forms';
1212
import { By } from '@angular/platform-browser';
1313
import { IntlTelInputComponent } from './intl-tel-input.component';
14+
import { provideExperimentalZonelessChangeDetection } from "@angular/core";
1415

1516
describe('IntlTelInputComponent', () => {
1617
let component: IntlTelInputComponent;
@@ -24,6 +25,7 @@ describe('IntlTelInputComponent', () => {
2425
],
2526
providers: [
2627
NgForm,
28+
provideExperimentalZonelessChangeDetection(),
2729
]
2830
})
2931
.compileComponents();
@@ -32,30 +34,31 @@ describe('IntlTelInputComponent', () => {
3234
beforeEach(() => {
3335
fixture = TestBed.createComponent(IntlTelInputComponent);
3436
component = fixture.componentInstance;
35-
fixture.detectChanges();
3637
});
3738

3839
it('should create', () => {
3940
expect(component).toBeTruthy();
4041
});
4142

42-
it('should convert phone number to E164 format', () => {
43+
it('should convert phone number to E164 format', async () => {
4344
fixture.componentRef.setInput('options', {
4445
preferredCountries: ['ch'],
4546
onlyCountries: ['ch', 'fr']
4647
});
48+
await fixture.whenStable();
4749
component.ngAfterViewInit();
4850

4951
component.phoneNumber = '0797703808';
5052

5153
expect(component.E164PhoneNumber()).toBe('+41797703808');
5254
});
5355

54-
it('should re-set E164 phone number on countryChange', () => {
56+
it('should re-set E164 phone number on countryChange', async () => {
5557
fixture.componentRef.setInput('options', {
5658
preferredCountries: ['ch'],
5759
onlyCountries: ['ch', 'fr']
5860
});
61+
await fixture.whenStable();
5962
component.ngAfterViewInit();
6063

6164
component.phoneNumber = '0797703808';
@@ -68,10 +71,10 @@ describe('IntlTelInputComponent', () => {
6871
expect(component.E164PhoneNumber()).toBe('+33681215656');
6972
});
7073

71-
it('should add a label tag if label attribute is set', () => {
74+
it('should add a label tag if label attribute is set', async () => {
7275
const labelText = 'label text';
7376
fixture.componentRef.setInput('label', labelText);
74-
fixture.detectChanges();
77+
await fixture.whenStable();
7578

7679
const element = fixture
7780
.debugElement
@@ -90,9 +93,9 @@ describe('IntlTelInputComponent', () => {
9093
expect(element).toBeNull();
9194
});
9295

93-
it('should not have a css class by default for the label', () => {
96+
it('should not have a css class by default for the label', async () => {
9497
fixture.componentRef.setInput('label', 'label');
95-
fixture.detectChanges();
98+
await fixture.whenStable();
9699

97100
const element = fixture
98101
.debugElement
@@ -102,10 +105,10 @@ describe('IntlTelInputComponent', () => {
102105
expect(element.className).toBeFalsy();
103106
});
104107

105-
it('should be possible to specify a css class for the label', () => {
108+
it('should be possible to specify a css class for the label', async () => {
106109
fixture.componentRef.setInput('label', 'label');
107110
fixture.componentRef.setInput('labelCssClass', 'labelCssClass');
108-
fixture.detectChanges();
111+
await fixture.whenStable();
109112

110113
const element = fixture
111114
.debugElement
@@ -115,10 +118,10 @@ describe('IntlTelInputComponent', () => {
115118
expect(element.className).toContain(component.labelCssClass());
116119
});
117120

118-
it('should set both required and aria-required if specified', () => {
121+
it('should set both required and aria-required if specified', async () => {
119122
fixture.componentRef.setInput('required', true);
120123

121-
fixture.detectChanges();
124+
await fixture.whenStable();
122125

123126
const element: HTMLElement = fixture
124127
.debugElement
@@ -129,7 +132,9 @@ describe('IntlTelInputComponent', () => {
129132
expect(element.getAttribute('aria-required')).toBe('true');
130133
});
131134

132-
it('should set a default name attribute if not specified', () => {
135+
it('should set a default name attribute if not specified', async () => {
136+
await fixture.whenStable();
137+
133138
const element: HTMLElement = fixture
134139
.debugElement
135140
.query(By.css('input'))
@@ -139,9 +144,9 @@ describe('IntlTelInputComponent', () => {
139144
expect(element.getAttribute('name')).toBe(element.getAttribute('id'));
140145
});
141146

142-
it('should set name and id to the same value', () => {
147+
it('should set name and id to the same value', async () => {
143148
fixture.componentRef.setInput('name', 'custom-name');
144-
fixture.detectChanges();
149+
await fixture.whenStable();
145150

146151
const element: HTMLElement = fixture
147152
.debugElement
@@ -152,11 +157,11 @@ describe('IntlTelInputComponent', () => {
152157
expect(element.getAttribute('name')).toBe(element.getAttribute('id'));
153158
});
154159

155-
it('should allow specifying a css class', () => {
160+
it('should allow specifying a css class', async () => {
156161
const cssClass = 'my-css-class';
157162
fixture.componentRef.setInput('cssClass', cssClass);
158163

159-
fixture.detectChanges();
164+
await fixture.whenStable();
160165

161166
const element: HTMLElement = fixture
162167
.debugElement
@@ -166,14 +171,16 @@ describe('IntlTelInputComponent', () => {
166171
expect(element.className).toContain(cssClass);
167172
});
168173

169-
it('should be possible to set preferredCountries option', () => {
174+
it('should be possible to set preferredCountries option', async () => {
170175
fixture.componentRef.setInput('options', {
171176
countrySearch: false,
172177
preferredCountries: ['ch'],
173178
onlyCountries: ['ch']
174179
});
180+
181+
await fixture.whenStable();
182+
175183
component.ngAfterViewInit();
176-
fixture.detectChanges();
177184

178185
const element = fixture
179186
.debugElement
@@ -185,16 +192,17 @@ describe('IntlTelInputComponent', () => {
185192
expect(element.getAttribute('data-country-code')).toBe(component.options().onlyCountries?.[0]);
186193
});
187194

188-
it('should be possible to set i18n option', () => {
195+
it('should be possible to set i18n option', async () => {
189196
const localizedCountryName = 'Suisse';
190197
fixture.componentRef.setInput('options', {
191198
preferredCountries: ['ch'],
192199
i18n: { ch: localizedCountryName },
193200
onlyCountries: ['ch']
194201
});
195-
component.ngAfterViewInit();
196202

197-
fixture.detectChanges();
203+
await fixture.whenStable();
204+
205+
component.ngAfterViewInit();
198206

199207
const element = fixture
200208
.debugElement

0 commit comments

Comments
 (0)