Skip to content

Commit

Permalink
chore: test-app is zoneless!
Browse files Browse the repository at this point in the history
  • Loading branch information
nartc committed Jun 10, 2024
1 parent f466a58 commit 2ee3f70
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 12 deletions.
4 changes: 2 additions & 2 deletions apps/test-app-e2e/src/e2e/resize.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ describe('resize', () => {

it('should react to viewport resize', () => {
cy.viewport(500, 500);
cy.get('pre').should('contain.text', '"width": 485');
cy.get('pre').should('contain.text', '"width": 500');

cy.viewport(800, 800);
cy.get('pre').should('contain.text', '"width": 785');
cy.get('pre').should('contain.text', '"width": 800');
});
});
1 change: 0 additions & 1 deletion apps/test-app/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"outputPath": "dist/apps/test-app",
"index": "apps/test-app/src/index.html",
"browser": "apps/test-app/src/main.ts",
"polyfills": ["zone.js"],
"tsConfig": "apps/test-app/tsconfig.app.json",
"assets": ["apps/test-app/src/favicon.ico", "apps/test-app/src/assets"],
"styles": ["apps/test-app/src/styles.css"],
Expand Down
4 changes: 3 additions & 1 deletion apps/test-app/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ import { RouterLink, RouterOutlet } from '@angular/router';
<a routerLink="/active-element">Active Element</a>
</li>
<li>
<a routerLink="/document-visibility-state">Document Visibility State</a>
<a routerLink="/inject-document-visibility">
Document Visibility State
</a>
</li>
<li>
Expand Down
6 changes: 5 additions & 1 deletion apps/test-app/src/app/app.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { type ApplicationConfig } from '@angular/core';
import {
provideExperimentalZonelessChangeDetection,
type ApplicationConfig,
} from '@angular/core';
import { provideRouter } from '@angular/router';
import { provideSvgSprites } from 'ngxtension/svg-sprite';

export const appConfig: ApplicationConfig = {
providers: [
provideExperimentalZonelessChangeDetection(),
provideRouter([
{
path: 'resize',
Expand Down
4 changes: 2 additions & 2 deletions apps/test-app/src/app/intl/intl.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ import {
=> {{ 'en' | displayNames: 'language' }}
</p>
<p>
<strong ngNonBindable>{{ 'en' | displayNames: 'script' }}</strong>
=> {{ 'en' | displayNames: 'script' }}
<strong ngNonBindable>{{ 'Hang' | displayNames: 'script' }}</strong>
=> {{ 'Hang' | displayNames: 'script' }}
</p>
<p>
<strong ngNonBindable>{{ 'en' | displayNames: 'region' }}</strong>
Expand Down
15 changes: 10 additions & 5 deletions apps/test-app/src/app/track-by/track-by.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
ElementRef,
ViewChild,
inject,
signal,
} from '@angular/core';
import { TrackById, TrackByProp } from 'ngxtension/trackby-id-prop';

Expand All @@ -30,13 +31,13 @@ import { TrackById, TrackByProp } from 'ngxtension/trackby-id-prop';
<button (click)="add()">add</button>
<hr />
<p id="without-track-by">
Without TrackBy mutations: {{ mutationsLength.withoutTrackBy }}
Without TrackBy mutations: {{ mutationsLength.withoutTrackBy() }}
</p>
<p id="with-track-by">
With TrackBy mutations: {{ mutationsLength.withTrackBy }}
With TrackBy mutations: {{ mutationsLength.withTrackBy() }}
</p>
<p id="with-track-by-prop">
With TrackBy prop mutations: {{ mutationsLength.withTrackByProp }}
With TrackBy prop mutations: {{ mutationsLength.withTrackByProp() }}
</p>
`,
imports: [NgFor, TrackById, TrackByProp],
Expand All @@ -47,13 +48,17 @@ export default class TrackByTest {
{ id: 2, firstName: 'Enea', lastName: 'Jahollari' },
{ id: 3, firstName: 'Daniele', lastName: 'Morosinotto' },
];
mutationsLength = { withTrackBy: 0, withTrackByProp: 0, withoutTrackBy: 0 };
mutationsLength = {
withTrackBy: signal(0),
withTrackByProp: signal(0),
withoutTrackBy: signal(0),
};

private destroyRef = inject(DestroyRef);
private mutationCallback =
(type: keyof typeof this.mutationsLength): MutationCallback =>
(mutations) => {
this.mutationsLength[type] += mutations.length;
this.mutationsLength[type].update((prev) => prev + mutations.length);
};

@ViewChild('parentNoTrackBy', { static: true }) set parentNoTrackBy({
Expand Down

0 comments on commit 2ee3f70

Please sign in to comment.