From b166fdcbd893a32168f2a8a515ac08aef05ece89 Mon Sep 17 00:00:00 2001 From: Jesse Attas Date: Thu, 3 Oct 2024 12:59:31 -0500 Subject: [PATCH 01/11] Use RouterTestingHarness in one test --- ...or-router-link-with-href.directive.spec.ts | 36 ++++++++----------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/packages/angular-workspace/nimble-angular/src/directives/anchor/tests/nimble-anchor-router-link-with-href.directive.spec.ts b/packages/angular-workspace/nimble-angular/src/directives/anchor/tests/nimble-anchor-router-link-with-href.directive.spec.ts index 6895081b77..8063e13998 100644 --- a/packages/angular-workspace/nimble-angular/src/directives/anchor/tests/nimble-anchor-router-link-with-href.directive.spec.ts +++ b/packages/angular-workspace/nimble-angular/src/directives/anchor/tests/nimble-anchor-router-link-with-href.directive.spec.ts @@ -1,8 +1,9 @@ import { Component, ElementRef, Sanitizer, SecurityContext, ViewChild } from '@angular/core'; -import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; -import { Router } from '@angular/router'; +import { fakeAsync, TestBed, tick } from '@angular/core/testing'; +import { By } from '@angular/platform-browser'; +import { provideRouter, Router } from '@angular/router'; import { CommonModule, Location } from '@angular/common'; -import { RouterTestingModule } from '@angular/router/testing'; +import { RouterTestingHarness } from '@angular/router/testing'; import { parameterizeSpec } from '@ni/jasmine-parameterized'; import { processUpdates } from '../../../testing/async-helpers'; import { NimbleAnchorModule } from '../nimble-anchor.module'; @@ -14,7 +15,6 @@ describe('Nimble anchor RouterLinkWithHrefDirective', () => { Anchor text - ` }) class TestHostComponent { @@ -25,16 +25,15 @@ describe('Nimble anchor RouterLinkWithHrefDirective', () => { class BlankComponent { } let anchor: Anchor; - let fixture: ComponentFixture; - let testHostComponent: TestHostComponent; let router: Router; let location: Location; let innerAnchor: HTMLAnchorElement; let routerNavigateByUrlSpy: jasmine.Spy; let anchorClickHandlerSpy: jasmine.Spy; let sanitizer: jasmine.SpyObj; + let harness: RouterTestingHarness; - beforeEach(() => { + beforeEach(async () => { sanitizer = jasmine.createSpyObj('Sanitizer', ['sanitize']); sanitizer.sanitize.and.callFake((_, value: string) => value); @@ -42,32 +41,27 @@ describe('Nimble anchor RouterLinkWithHrefDirective', () => { declarations: [TestHostComponent, BlankComponent], imports: [NimbleAnchorModule, CommonModule, - RouterTestingModule.withRoutes([ - { path: '', redirectTo: '/start', pathMatch: 'full' }, - { path: 'page1', component: BlankComponent }, - { path: 'start', component: TestHostComponent } - ], { useHash: true }) ], providers: [ - { provide: Sanitizer, useValue: sanitizer } + { provide: Sanitizer, useValue: sanitizer }, + provideRouter([ + { path: 'page1', component: BlankComponent }, + { path: '', component: TestHostComponent } + ]), ] }); + harness = await RouterTestingHarness.create(''); }); - beforeEach(fakeAsync(() => { + beforeEach(() => { router = TestBed.inject(Router); location = TestBed.inject(Location); - fixture = TestBed.createComponent(TestHostComponent); - testHostComponent = fixture.componentInstance; - anchor = testHostComponent.anchor.nativeElement; - fixture.detectChanges(); - tick(); - processUpdates(); + anchor = harness.fixture.debugElement.query(By.css('nimble-anchor')).nativeElement as Anchor; innerAnchor = anchor!.shadowRoot!.querySelector('a')!; routerNavigateByUrlSpy = spyOn(router, 'navigateByUrl').and.callThrough(); anchorClickHandlerSpy = jasmine.createSpy('click'); innerAnchor!.addEventListener('click', anchorClickHandlerSpy); - })); + }); afterEach(() => { processUpdates(); From 95e83c9ea81f88e2c1a1e95bd46da9f8a25dade3 Mon Sep 17 00:00:00 2001 From: Jesse Attas Date: Thu, 3 Oct 2024 13:43:35 -0500 Subject: [PATCH 02/11] Change files --- ...imble-angular-16d68d67-9ecc-41b3-b7aa-cb52dbd66da4.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 change/@ni-nimble-angular-16d68d67-9ecc-41b3-b7aa-cb52dbd66da4.json diff --git a/change/@ni-nimble-angular-16d68d67-9ecc-41b3-b7aa-cb52dbd66da4.json b/change/@ni-nimble-angular-16d68d67-9ecc-41b3-b7aa-cb52dbd66da4.json new file mode 100644 index 0000000000..c19e126405 --- /dev/null +++ b/change/@ni-nimble-angular-16d68d67-9ecc-41b3-b7aa-cb52dbd66da4.json @@ -0,0 +1,7 @@ +{ + "type": "none", + "comment": "Angular router link test improvements", + "packageName": "@ni/nimble-angular", + "email": "jattasNI@users.noreply.github.com", + "dependentChangeType": "none" +} From 670a628a4c6276f555c705978cbfa26ac38b1d64 Mon Sep 17 00:00:00 2001 From: Jesse Attas Date: Mon, 7 Oct 2024 10:03:49 -0500 Subject: [PATCH 03/11] Error tests passing --- .../nimble-anchor-button-router-link.directive.spec.ts | 4 +--- ...mble-anchor-menu-item-router-link.directive.spec.ts | 10 ++++------ .../nimble-anchor-tab-router-link.directive.spec.ts | 9 +++------ ...mble-anchor-tree-item-router-link.directive.spec.ts | 4 +--- .../tests/nimble-anchor-router-link.directive.spec.ts | 6 ++---- ...imble-breadcrumb-item-router-link.directive.spec.ts | 9 ++++----- 6 files changed, 15 insertions(+), 27 deletions(-) diff --git a/packages/angular-workspace/nimble-angular/src/directives/anchor-button/tests/nimble-anchor-button-router-link.directive.spec.ts b/packages/angular-workspace/nimble-angular/src/directives/anchor-button/tests/nimble-anchor-button-router-link.directive.spec.ts index d64bb909d2..06d8232b2e 100644 --- a/packages/angular-workspace/nimble-angular/src/directives/anchor-button/tests/nimble-anchor-button-router-link.directive.spec.ts +++ b/packages/angular-workspace/nimble-angular/src/directives/anchor-button/tests/nimble-anchor-button-router-link.directive.spec.ts @@ -1,7 +1,6 @@ import { Component } from '@angular/core'; import { TestBed } from '@angular/core/testing'; import { CommonModule } from '@angular/common'; -import { RouterTestingModule } from '@angular/router/testing'; import { processUpdates } from '../../../testing/async-helpers'; import { NimbleAnchorButtonModule } from '../nimble-anchor-button.module'; @@ -23,8 +22,7 @@ describe('Nimble anchor button RouterLinkDirective', () => { imports: [ NimbleAnchorButtonModule, CommonModule, - RouterTestingModule.withRoutes([{ path: '', component: TestHostComponent, pathMatch: 'full' }], { useHash: true }) - ] + ], }); }); diff --git a/packages/angular-workspace/nimble-angular/src/directives/anchor-menu-item/tests/nimble-anchor-menu-item-router-link.directive.spec.ts b/packages/angular-workspace/nimble-angular/src/directives/anchor-menu-item/tests/nimble-anchor-menu-item-router-link.directive.spec.ts index 0c2b345e36..9cf045a924 100644 --- a/packages/angular-workspace/nimble-angular/src/directives/anchor-menu-item/tests/nimble-anchor-menu-item-router-link.directive.spec.ts +++ b/packages/angular-workspace/nimble-angular/src/directives/anchor-menu-item/tests/nimble-anchor-menu-item-router-link.directive.spec.ts @@ -1,7 +1,6 @@ import { Component } from '@angular/core'; import { TestBed } from '@angular/core/testing'; import { CommonModule } from '@angular/common'; -import { RouterTestingModule } from '@angular/router/testing'; import { processUpdates } from '../../../testing/async-helpers'; import { NimbleAnchorMenuItemModule } from '../nimble-anchor-menu-item.module'; @@ -20,11 +19,10 @@ describe('Nimble anchor menu item RouterLinkDirective', () => { beforeEach(() => { TestBed.configureTestingModule({ declarations: [TestHostComponent], - imports: [NimbleAnchorMenuItemModule, - CommonModule, - RouterTestingModule.withRoutes([{ path: '', component: TestHostComponent, pathMatch: 'full' } - ], { useHash: true }) - ] + imports: [ + NimbleAnchorMenuItemModule, + CommonModule + ], }); }); diff --git a/packages/angular-workspace/nimble-angular/src/directives/anchor-tab/tests/nimble-anchor-tab-router-link.directive.spec.ts b/packages/angular-workspace/nimble-angular/src/directives/anchor-tab/tests/nimble-anchor-tab-router-link.directive.spec.ts index 85576f3d97..e4a25a5bd8 100644 --- a/packages/angular-workspace/nimble-angular/src/directives/anchor-tab/tests/nimble-anchor-tab-router-link.directive.spec.ts +++ b/packages/angular-workspace/nimble-angular/src/directives/anchor-tab/tests/nimble-anchor-tab-router-link.directive.spec.ts @@ -1,7 +1,6 @@ import { Component } from '@angular/core'; import { TestBed } from '@angular/core/testing'; import { CommonModule } from '@angular/common'; -import { RouterTestingModule } from '@angular/router/testing'; import { processUpdates } from '../../../testing/async-helpers'; import { NimbleAnchorTabModule } from '../nimble-anchor-tab.module'; @@ -20,12 +19,10 @@ describe('Nimble anchor tab RouterLinkDirective', () => { beforeEach(() => { TestBed.configureTestingModule({ declarations: [TestHostComponent], - imports: [NimbleAnchorTabModule, + imports: [ + NimbleAnchorTabModule, CommonModule, - RouterTestingModule.withRoutes([ - { path: '', component: TestHostComponent, pathMatch: 'full' } - ], { useHash: true }) - ] + ], }); }); diff --git a/packages/angular-workspace/nimble-angular/src/directives/anchor-tree-item/tests/nimble-anchor-tree-item-router-link.directive.spec.ts b/packages/angular-workspace/nimble-angular/src/directives/anchor-tree-item/tests/nimble-anchor-tree-item-router-link.directive.spec.ts index 17fd45c5e0..4abd871605 100644 --- a/packages/angular-workspace/nimble-angular/src/directives/anchor-tree-item/tests/nimble-anchor-tree-item-router-link.directive.spec.ts +++ b/packages/angular-workspace/nimble-angular/src/directives/anchor-tree-item/tests/nimble-anchor-tree-item-router-link.directive.spec.ts @@ -1,7 +1,6 @@ import { Component } from '@angular/core'; import { TestBed } from '@angular/core/testing'; import { CommonModule } from '@angular/common'; -import { RouterTestingModule } from '@angular/router/testing'; import { processUpdates } from '../../../testing/async-helpers'; import { NimbleAnchorTreeItemModule } from '../nimble-anchor-tree-item.module'; @@ -23,8 +22,7 @@ describe('Nimble anchor tree item RouterLinkDirective', () => { imports: [ NimbleAnchorTreeItemModule, CommonModule, - RouterTestingModule.withRoutes([{ path: '', component: TestHostComponent, pathMatch: 'full' }], { useHash: true }) - ] + ], }); }); diff --git a/packages/angular-workspace/nimble-angular/src/directives/anchor/tests/nimble-anchor-router-link.directive.spec.ts b/packages/angular-workspace/nimble-angular/src/directives/anchor/tests/nimble-anchor-router-link.directive.spec.ts index e189e98291..72255fc843 100644 --- a/packages/angular-workspace/nimble-angular/src/directives/anchor/tests/nimble-anchor-router-link.directive.spec.ts +++ b/packages/angular-workspace/nimble-angular/src/directives/anchor/tests/nimble-anchor-router-link.directive.spec.ts @@ -1,7 +1,6 @@ import { Component } from '@angular/core'; import { TestBed } from '@angular/core/testing'; import { CommonModule } from '@angular/common'; -import { RouterTestingModule } from '@angular/router/testing'; import { processUpdates } from '../../../testing/async-helpers'; import { NimbleAnchorModule } from '../nimble-anchor.module'; @@ -20,10 +19,9 @@ describe('Nimble anchor RouterLinkDirective', () => { beforeEach(() => { TestBed.configureTestingModule({ declarations: [TestHostComponent], - imports: [NimbleAnchorModule, + imports: [ + NimbleAnchorModule, CommonModule, - RouterTestingModule.withRoutes([{ path: '', component: TestHostComponent, pathMatch: 'full' } - ], { useHash: true }) ] }); }); diff --git a/packages/angular-workspace/nimble-angular/src/directives/breadcrumb-item/tests/nimble-breadcrumb-item-router-link.directive.spec.ts b/packages/angular-workspace/nimble-angular/src/directives/breadcrumb-item/tests/nimble-breadcrumb-item-router-link.directive.spec.ts index 4402ece081..b5882b46f2 100644 --- a/packages/angular-workspace/nimble-angular/src/directives/breadcrumb-item/tests/nimble-breadcrumb-item-router-link.directive.spec.ts +++ b/packages/angular-workspace/nimble-angular/src/directives/breadcrumb-item/tests/nimble-breadcrumb-item-router-link.directive.spec.ts @@ -1,7 +1,6 @@ import { Component } from '@angular/core'; import { TestBed } from '@angular/core/testing'; import { CommonModule } from '@angular/common'; -import { RouterTestingModule } from '@angular/router/testing'; import { processUpdates } from '../../../testing/async-helpers'; import { NimbleBreadcrumbModule } from '../../breadcrumb/nimble-breadcrumb.module'; import { NimbleBreadcrumbItemModule } from '../nimble-breadcrumb-item.module'; @@ -23,11 +22,11 @@ describe('Nimble breadcrumb item RouterLinkDirective', () => { beforeEach(() => { TestBed.configureTestingModule({ declarations: [TestHostComponent], - imports: [NimbleBreadcrumbModule, NimbleBreadcrumbItemModule, + imports: [ + NimbleBreadcrumbModule, + NimbleBreadcrumbItemModule, CommonModule, - RouterTestingModule.withRoutes([{ path: '', component: TestHostComponent, pathMatch: 'full' } - ], { useHash: true }) - ] + ], }); }); From a3f19389d76fdd087c631999cd467bf4597c8d3a Mon Sep 17 00:00:00 2001 From: Jesse Attas Date: Tue, 8 Oct 2024 11:43:54 -0500 Subject: [PATCH 04/11] preventDefault in click handlers --- ...on-router-link-with-href.directive.spec.ts | 40 +++++++++--------- ...em-router-link-with-href.directive.spec.ts | 40 +++++++++--------- ...ab-router-link-with-href.directive.spec.ts | 40 +++++++++--------- ...em-router-link-with-href.directive.spec.ts | 40 +++++++++--------- ...or-router-link-with-href.directive.spec.ts | 9 +++- ...em-router-link-with-href.directive.spec.ts | 42 +++++++++---------- ...-anchor-navigation-guard.directive.spec.ts | 4 +- 7 files changed, 106 insertions(+), 109 deletions(-) diff --git a/packages/angular-workspace/nimble-angular/src/directives/anchor-button/tests/nimble-anchor-button-router-link-with-href.directive.spec.ts b/packages/angular-workspace/nimble-angular/src/directives/anchor-button/tests/nimble-anchor-button-router-link-with-href.directive.spec.ts index 92cb9a098f..8f10baa506 100644 --- a/packages/angular-workspace/nimble-angular/src/directives/anchor-button/tests/nimble-anchor-button-router-link-with-href.directive.spec.ts +++ b/packages/angular-workspace/nimble-angular/src/directives/anchor-button/tests/nimble-anchor-button-router-link-with-href.directive.spec.ts @@ -1,20 +1,20 @@ import { Component, ElementRef, Sanitizer, SecurityContext, ViewChild } from '@angular/core'; -import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; -import { Router } from '@angular/router'; +import { fakeAsync, TestBed, tick } from '@angular/core/testing'; +import { By } from '@angular/platform-browser'; +import { provideRouter, Router } from '@angular/router'; import { CommonModule, Location } from '@angular/common'; -import { RouterTestingModule } from '@angular/router/testing'; +import { RouterTestingHarness } from '@angular/router/testing'; import { parameterizeSpec } from '@ni/jasmine-parameterized'; import { processUpdates } from '../../../testing/async-helpers'; import { NimbleAnchorButtonModule } from '../nimble-anchor-button.module'; import type { AnchorButton } from '../nimble-anchor-button.directive'; -describe('Nimble anchor button RouterLinkWithHrefDirective', () => { +xdescribe('Nimble anchor button RouterLinkWithHrefDirective', () => { @Component({ template: ` Anchor text - ` }) class TestHostComponent { @@ -25,7 +25,6 @@ describe('Nimble anchor button RouterLinkWithHrefDirective', () => { class BlankComponent { } let anchorButton: AnchorButton; - let fixture: ComponentFixture; let testHostComponent: TestHostComponent; let router: Router; let location: Location; @@ -33,41 +32,40 @@ describe('Nimble anchor button RouterLinkWithHrefDirective', () => { let routerNavigateByUrlSpy: jasmine.Spy; let anchorClickHandlerSpy: jasmine.Spy; let sanitizer: jasmine.SpyObj; + let harness: RouterTestingHarness; - beforeEach(() => { + beforeEach(async () => { sanitizer = jasmine.createSpyObj('Sanitizer', ['sanitize']); sanitizer.sanitize.and.callFake((_, value: string) => value); TestBed.configureTestingModule({ declarations: [TestHostComponent, BlankComponent], - imports: [NimbleAnchorButtonModule, + imports: [ + NimbleAnchorButtonModule, CommonModule, - RouterTestingModule.withRoutes([ - { path: '', redirectTo: '/start', pathMatch: 'full' }, - { path: 'page1', component: BlankComponent }, - { path: 'start', component: TestHostComponent } - ], { useHash: true }) ], providers: [ - { provide: Sanitizer, useValue: sanitizer } + { provide: Sanitizer, useValue: sanitizer }, + provideRouter([ + { path: 'page1', component: BlankComponent }, + { path: '', component: TestHostComponent } + ]), ] }); + harness = await RouterTestingHarness.create(''); }); - beforeEach(fakeAsync(() => { + beforeEach(() => { router = TestBed.inject(Router); location = TestBed.inject(Location); - fixture = TestBed.createComponent(TestHostComponent); - testHostComponent = fixture.componentInstance; + testHostComponent = harness.fixture.debugElement.query(By.directive(TestHostComponent)).componentInstance as TestHostComponent; anchorButton = testHostComponent.anchor.nativeElement; - fixture.detectChanges(); - tick(); processUpdates(); innerAnchor = anchorButton!.shadowRoot!.querySelector('a')!; routerNavigateByUrlSpy = spyOn(router, 'navigateByUrl').and.callThrough(); - anchorClickHandlerSpy = jasmine.createSpy('click'); + anchorClickHandlerSpy = jasmine.createSpy('click').and.callFake((event: Event) => event.preventDefault()); innerAnchor!.addEventListener('click', anchorClickHandlerSpy); - })); + }); afterEach(() => { processUpdates(); diff --git a/packages/angular-workspace/nimble-angular/src/directives/anchor-menu-item/tests/nimble-anchor-menu-item-router-link-with-href.directive.spec.ts b/packages/angular-workspace/nimble-angular/src/directives/anchor-menu-item/tests/nimble-anchor-menu-item-router-link-with-href.directive.spec.ts index e80ad56781..0b1c4f8c8f 100644 --- a/packages/angular-workspace/nimble-angular/src/directives/anchor-menu-item/tests/nimble-anchor-menu-item-router-link-with-href.directive.spec.ts +++ b/packages/angular-workspace/nimble-angular/src/directives/anchor-menu-item/tests/nimble-anchor-menu-item-router-link-with-href.directive.spec.ts @@ -1,20 +1,20 @@ import { Component, ElementRef, Sanitizer, SecurityContext, ViewChild } from '@angular/core'; -import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; -import { Router } from '@angular/router'; +import { fakeAsync, TestBed, tick } from '@angular/core/testing'; +import { By } from '@angular/platform-browser'; +import { provideRouter, Router } from '@angular/router'; import { CommonModule, Location } from '@angular/common'; -import { RouterTestingModule } from '@angular/router/testing'; +import { RouterTestingHarness } from '@angular/router/testing'; import { parameterizeSpec } from '@ni/jasmine-parameterized'; import { processUpdates } from '../../../testing/async-helpers'; import { NimbleAnchorMenuItemModule } from '../nimble-anchor-menu-item.module'; import type { AnchorMenuItem } from '../nimble-anchor-menu-item.directive'; -describe('Nimble anchor menu item RouterLinkWithHrefDirective', () => { +xdescribe('Nimble anchor menu item RouterLinkWithHrefDirective', () => { @Component({ template: ` Anchor text - ` }) class TestHostComponent { @@ -25,7 +25,6 @@ describe('Nimble anchor menu item RouterLinkWithHrefDirective', () => { class BlankComponent { } let menuItem: AnchorMenuItem; - let fixture: ComponentFixture; let testHostComponent: TestHostComponent; let router: Router; let location: Location; @@ -33,41 +32,40 @@ describe('Nimble anchor menu item RouterLinkWithHrefDirective', () => { let routerNavigateByUrlSpy: jasmine.Spy; let anchorClickHandlerSpy: jasmine.Spy; let sanitizer: jasmine.SpyObj; + let harness: RouterTestingHarness; - beforeEach(() => { + beforeEach(async () => { sanitizer = jasmine.createSpyObj('Sanitizer', ['sanitize']); sanitizer.sanitize.and.callFake((_, value: string) => value); TestBed.configureTestingModule({ declarations: [TestHostComponent, BlankComponent], - imports: [NimbleAnchorMenuItemModule, + imports: [ + NimbleAnchorMenuItemModule, CommonModule, - RouterTestingModule.withRoutes([ - { path: '', redirectTo: '/start', pathMatch: 'full' }, - { path: 'page1', component: BlankComponent }, - { path: 'start', component: TestHostComponent } - ], { useHash: true }) ], providers: [ - { provide: Sanitizer, useValue: sanitizer } + { provide: Sanitizer, useValue: sanitizer }, + provideRouter([ + { path: 'page1', component: BlankComponent }, + { path: '', component: TestHostComponent } + ]), ] }); + harness = await RouterTestingHarness.create(''); }); - beforeEach(fakeAsync(() => { + beforeEach(() => { router = TestBed.inject(Router); location = TestBed.inject(Location); - fixture = TestBed.createComponent(TestHostComponent); - testHostComponent = fixture.componentInstance; + testHostComponent = harness.fixture.debugElement.query(By.directive(TestHostComponent)).componentInstance as TestHostComponent; menuItem = testHostComponent.menuItem.nativeElement; - fixture.detectChanges(); - tick(); processUpdates(); innerAnchor = menuItem!.shadowRoot!.querySelector('a')!; routerNavigateByUrlSpy = spyOn(router, 'navigateByUrl').and.callThrough(); - anchorClickHandlerSpy = jasmine.createSpy('click'); + anchorClickHandlerSpy = jasmine.createSpy('click').and.callFake((event: Event) => event.preventDefault()); innerAnchor!.addEventListener('click', anchorClickHandlerSpy); - })); + }); afterEach(() => { processUpdates(); diff --git a/packages/angular-workspace/nimble-angular/src/directives/anchor-tab/tests/nimble-anchor-tab-router-link-with-href.directive.spec.ts b/packages/angular-workspace/nimble-angular/src/directives/anchor-tab/tests/nimble-anchor-tab-router-link-with-href.directive.spec.ts index d8bebb9743..18af8797ce 100644 --- a/packages/angular-workspace/nimble-angular/src/directives/anchor-tab/tests/nimble-anchor-tab-router-link-with-href.directive.spec.ts +++ b/packages/angular-workspace/nimble-angular/src/directives/anchor-tab/tests/nimble-anchor-tab-router-link-with-href.directive.spec.ts @@ -1,20 +1,20 @@ import { Component, ElementRef, Sanitizer, SecurityContext, ViewChild } from '@angular/core'; -import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; -import { Router } from '@angular/router'; +import { fakeAsync, TestBed, tick } from '@angular/core/testing'; +import { provideRouter, Router } from '@angular/router'; import { CommonModule, Location } from '@angular/common'; -import { RouterTestingModule } from '@angular/router/testing'; +import { By } from '@angular/platform-browser'; +import { RouterTestingHarness } from '@angular/router/testing'; import { parameterizeSpec } from '@ni/jasmine-parameterized'; import { processUpdates } from '../../../testing/async-helpers'; import { NimbleAnchorTabModule } from '../nimble-anchor-tab.module'; import type { AnchorTab } from '../nimble-anchor-tab.directive'; -describe('Nimble anchor tab RouterLinkWithHrefDirective', () => { +xdescribe('Nimble anchor tab RouterLinkWithHrefDirective', () => { @Component({ template: ` Anchor text - ` }) class TestHostComponent { @@ -25,7 +25,6 @@ describe('Nimble anchor tab RouterLinkWithHrefDirective', () => { class BlankComponent { } let anchorTab: AnchorTab; - let fixture: ComponentFixture; let testHostComponent: TestHostComponent; let router: Router; let location: Location; @@ -33,41 +32,40 @@ describe('Nimble anchor tab RouterLinkWithHrefDirective', () => { let routerNavigateByUrlSpy: jasmine.Spy; let anchorClickHandlerSpy: jasmine.Spy; let sanitizer: jasmine.SpyObj; + let harness: RouterTestingHarness; - beforeEach(() => { + beforeEach(async () => { sanitizer = jasmine.createSpyObj('Sanitizer', ['sanitize']); sanitizer.sanitize.and.callFake((_, value: string) => value); TestBed.configureTestingModule({ declarations: [TestHostComponent, BlankComponent], - imports: [NimbleAnchorTabModule, + imports: [ + NimbleAnchorTabModule, CommonModule, - RouterTestingModule.withRoutes([ - { path: '', redirectTo: '/start', pathMatch: 'full' }, - { path: 'page1', component: BlankComponent }, - { path: 'start', component: TestHostComponent } - ], { useHash: true }) ], providers: [ - { provide: Sanitizer, useValue: sanitizer } + { provide: Sanitizer, useValue: sanitizer }, + provideRouter([ + { path: 'page1', component: BlankComponent }, + { path: '', component: TestHostComponent } + ]), ] }); + harness = await RouterTestingHarness.create(''); }); - beforeEach(fakeAsync(() => { + beforeEach(() => { router = TestBed.inject(Router); location = TestBed.inject(Location); - fixture = TestBed.createComponent(TestHostComponent); - testHostComponent = fixture.componentInstance; + testHostComponent = harness.fixture.debugElement.query(By.directive(TestHostComponent)).componentInstance as TestHostComponent; anchorTab = testHostComponent.anchorTab.nativeElement; - fixture.detectChanges(); - tick(); processUpdates(); innerAnchor = anchorTab!.shadowRoot!.querySelector('a')!; routerNavigateByUrlSpy = spyOn(router, 'navigateByUrl').and.callThrough(); - anchorClickHandlerSpy = jasmine.createSpy('click'); + anchorClickHandlerSpy = jasmine.createSpy('click').and.callFake((event: Event) => event.preventDefault()); innerAnchor!.addEventListener('click', anchorClickHandlerSpy); - })); + }); afterEach(() => { processUpdates(); diff --git a/packages/angular-workspace/nimble-angular/src/directives/anchor-tree-item/tests/nimble-anchor-tree-item-router-link-with-href.directive.spec.ts b/packages/angular-workspace/nimble-angular/src/directives/anchor-tree-item/tests/nimble-anchor-tree-item-router-link-with-href.directive.spec.ts index b1a2737fcb..4a49609fe8 100644 --- a/packages/angular-workspace/nimble-angular/src/directives/anchor-tree-item/tests/nimble-anchor-tree-item-router-link-with-href.directive.spec.ts +++ b/packages/angular-workspace/nimble-angular/src/directives/anchor-tree-item/tests/nimble-anchor-tree-item-router-link-with-href.directive.spec.ts @@ -1,20 +1,20 @@ import { Component, ElementRef, Sanitizer, SecurityContext, ViewChild } from '@angular/core'; -import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; -import { Router } from '@angular/router'; +import { fakeAsync, TestBed, tick } from '@angular/core/testing'; +import { By } from '@angular/platform-browser'; +import { provideRouter, Router } from '@angular/router'; import { CommonModule, Location } from '@angular/common'; -import { RouterTestingModule } from '@angular/router/testing'; +import { RouterTestingHarness } from '@angular/router/testing'; import { parameterizeSpec } from '@ni/jasmine-parameterized'; import { processUpdates } from '../../../testing/async-helpers'; import { NimbleAnchorTreeItemModule } from '../nimble-anchor-tree-item.module'; import type { AnchorTreeItem } from '../nimble-anchor-tree-item.directive'; -describe('Nimble anchor tree item RouterLinkWithHrefDirective', () => { +xdescribe('Nimble anchor tree item RouterLinkWithHrefDirective', () => { @Component({ template: ` Anchor text - ` }) class TestHostComponent { @@ -25,7 +25,6 @@ describe('Nimble anchor tree item RouterLinkWithHrefDirective', () => { class BlankComponent { } let anchorTreeItem: AnchorTreeItem; - let fixture: ComponentFixture; let testHostComponent: TestHostComponent; let router: Router; let location: Location; @@ -33,41 +32,40 @@ describe('Nimble anchor tree item RouterLinkWithHrefDirective', () => { let routerNavigateByUrlSpy: jasmine.Spy; let anchorClickHandlerSpy: jasmine.Spy; let sanitizer: jasmine.SpyObj; + let harness: RouterTestingHarness; - beforeEach(() => { + beforeEach(async () => { sanitizer = jasmine.createSpyObj('Sanitizer', ['sanitize']); sanitizer.sanitize.and.callFake((_, value: string) => value); TestBed.configureTestingModule({ declarations: [TestHostComponent, BlankComponent], - imports: [NimbleAnchorTreeItemModule, + imports: [ + NimbleAnchorTreeItemModule, CommonModule, - RouterTestingModule.withRoutes([ - { path: '', redirectTo: '/start', pathMatch: 'full' }, - { path: 'page1', component: BlankComponent }, - { path: 'start', component: TestHostComponent } - ], { useHash: true }) ], providers: [ - { provide: Sanitizer, useValue: sanitizer } + { provide: Sanitizer, useValue: sanitizer }, + provideRouter([ + { path: 'page1', component: BlankComponent }, + { path: '', component: TestHostComponent } + ]), ] }); + harness = await RouterTestingHarness.create(''); }); - beforeEach(fakeAsync(() => { + beforeEach(() => { router = TestBed.inject(Router); location = TestBed.inject(Location); - fixture = TestBed.createComponent(TestHostComponent); - testHostComponent = fixture.componentInstance; + testHostComponent = harness.fixture.debugElement.query(By.directive(TestHostComponent)).componentInstance as TestHostComponent; anchorTreeItem = testHostComponent.treeItem.nativeElement; - fixture.detectChanges(); - tick(); processUpdates(); innerAnchor = anchorTreeItem!.shadowRoot!.querySelector('a')!; routerNavigateByUrlSpy = spyOn(router, 'navigateByUrl').and.callThrough(); - anchorClickHandlerSpy = jasmine.createSpy('click'); + anchorClickHandlerSpy = jasmine.createSpy('click').and.callFake((event: Event) => event.preventDefault()); innerAnchor!.addEventListener('click', anchorClickHandlerSpy); - })); + }); afterEach(() => { processUpdates(); diff --git a/packages/angular-workspace/nimble-angular/src/directives/anchor/tests/nimble-anchor-router-link-with-href.directive.spec.ts b/packages/angular-workspace/nimble-angular/src/directives/anchor/tests/nimble-anchor-router-link-with-href.directive.spec.ts index 8063e13998..4ab93fafdc 100644 --- a/packages/angular-workspace/nimble-angular/src/directives/anchor/tests/nimble-anchor-router-link-with-href.directive.spec.ts +++ b/packages/angular-workspace/nimble-angular/src/directives/anchor/tests/nimble-anchor-router-link-with-href.directive.spec.ts @@ -1,4 +1,5 @@ import { Component, ElementRef, Sanitizer, SecurityContext, ViewChild } from '@angular/core'; +import { provideLocationMocks } from '@angular/common/testing'; import { fakeAsync, TestBed, tick } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; import { provideRouter, Router } from '@angular/router'; @@ -25,6 +26,7 @@ describe('Nimble anchor RouterLinkWithHrefDirective', () => { class BlankComponent { } let anchor: Anchor; + let testHostComponent: TestHostComponent; let router: Router; let location: Location; let innerAnchor: HTMLAnchorElement; @@ -48,6 +50,7 @@ describe('Nimble anchor RouterLinkWithHrefDirective', () => { { path: 'page1', component: BlankComponent }, { path: '', component: TestHostComponent } ]), + provideLocationMocks() ] }); harness = await RouterTestingHarness.create(''); @@ -56,10 +59,12 @@ describe('Nimble anchor RouterLinkWithHrefDirective', () => { beforeEach(() => { router = TestBed.inject(Router); location = TestBed.inject(Location); - anchor = harness.fixture.debugElement.query(By.css('nimble-anchor')).nativeElement as Anchor; + testHostComponent = harness.fixture.debugElement.query(By.directive(TestHostComponent)).componentInstance as TestHostComponent; + anchor = testHostComponent.anchor.nativeElement; + processUpdates(); innerAnchor = anchor!.shadowRoot!.querySelector('a')!; routerNavigateByUrlSpy = spyOn(router, 'navigateByUrl').and.callThrough(); - anchorClickHandlerSpy = jasmine.createSpy('click'); + anchorClickHandlerSpy = jasmine.createSpy('click').and.callFake((event: Event) => event.preventDefault()); innerAnchor!.addEventListener('click', anchorClickHandlerSpy); }); diff --git a/packages/angular-workspace/nimble-angular/src/directives/breadcrumb-item/tests/nimble-breadcrumb-item-router-link-with-href.directive.spec.ts b/packages/angular-workspace/nimble-angular/src/directives/breadcrumb-item/tests/nimble-breadcrumb-item-router-link-with-href.directive.spec.ts index 7ab306df0f..31be12e11f 100644 --- a/packages/angular-workspace/nimble-angular/src/directives/breadcrumb-item/tests/nimble-breadcrumb-item-router-link-with-href.directive.spec.ts +++ b/packages/angular-workspace/nimble-angular/src/directives/breadcrumb-item/tests/nimble-breadcrumb-item-router-link-with-href.directive.spec.ts @@ -1,15 +1,16 @@ import { Component, ElementRef, Sanitizer, SecurityContext, ViewChild } from '@angular/core'; -import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; -import { Router } from '@angular/router'; +import { fakeAsync, TestBed, tick } from '@angular/core/testing'; +import { By } from '@angular/platform-browser'; +import { provideRouter, Router } from '@angular/router'; import { CommonModule, Location } from '@angular/common'; -import { RouterTestingModule } from '@angular/router/testing'; +import { RouterTestingHarness } from '@angular/router/testing'; import { parameterizeSpec } from '@ni/jasmine-parameterized'; import { processUpdates } from '../../../testing/async-helpers'; import { NimbleBreadcrumbModule } from '../../breadcrumb/nimble-breadcrumb.module'; import { NimbleBreadcrumbItemModule } from '../nimble-breadcrumb-item.module'; import type { BreadcrumbItem } from '../nimble-breadcrumb-item.directive'; -describe('Nimble breadcrumb item RouterLinkWithHrefDirective', () => { +xdescribe('Nimble breadcrumb item RouterLinkWithHrefDirective', () => { @Component({ template: ` @@ -17,7 +18,6 @@ describe('Nimble breadcrumb item RouterLinkWithHrefDirective', () => { Breadcrumb Text - ` }) class TestHostComponent { @@ -28,7 +28,6 @@ describe('Nimble breadcrumb item RouterLinkWithHrefDirective', () => { class BlankComponent { } let breadcrumbItem1: BreadcrumbItem; - let fixture: ComponentFixture; let testHostComponent: TestHostComponent; let router: Router; let location: Location; @@ -38,44 +37,45 @@ describe('Nimble breadcrumb item RouterLinkWithHrefDirective', () => { let anchorClickHandlerSpy: jasmine.Spy; let separatorClickHandlerSpy: jasmine.Spy; let sanitizer: jasmine.SpyObj; + let harness: RouterTestingHarness; - beforeEach(() => { + beforeEach(async () => { sanitizer = jasmine.createSpyObj('Sanitizer', ['sanitize']); sanitizer.sanitize.and.callFake((_, value: string) => value); TestBed.configureTestingModule({ declarations: [TestHostComponent, BlankComponent], - imports: [NimbleBreadcrumbModule, NimbleBreadcrumbItemModule, + imports: [ + NimbleBreadcrumbModule, + NimbleBreadcrumbItemModule, CommonModule, - RouterTestingModule.withRoutes([ - { path: '', redirectTo: '/start', pathMatch: 'full' }, - { path: 'page1', component: BlankComponent }, - { path: 'start', component: TestHostComponent } - ], { useHash: true }) ], providers: [ - { provide: Sanitizer, useValue: sanitizer } + { provide: Sanitizer, useValue: sanitizer }, + provideRouter([ + { path: 'page1', component: BlankComponent }, + { path: '', component: TestHostComponent } + ]), ] }); + harness = await RouterTestingHarness.create(''); }); - beforeEach(fakeAsync(() => { + beforeEach(() => { router = TestBed.inject(Router); location = TestBed.inject(Location); - fixture = TestBed.createComponent(TestHostComponent); - testHostComponent = fixture.componentInstance; + testHostComponent = harness.fixture.debugElement.query(By.directive(TestHostComponent)).componentInstance as TestHostComponent; breadcrumbItem1 = testHostComponent.breadcrumbItem1.nativeElement; - fixture.detectChanges(); - tick(); + // tick(); processUpdates(); anchor = breadcrumbItem1!.shadowRoot!.querySelector('a')!; separator = breadcrumbItem1!.shadowRoot!.querySelector('.separator')!; routerNavigateByUrlSpy = spyOn(router, 'navigateByUrl').and.callThrough(); - anchorClickHandlerSpy = jasmine.createSpy('click'); + anchorClickHandlerSpy = jasmine.createSpy('click').and.callFake((event: Event) => event.preventDefault()); separatorClickHandlerSpy = jasmine.createSpy('click'); anchor.addEventListener('click', anchorClickHandlerSpy); separator.addEventListener('click', separatorClickHandlerSpy); - })); + }); afterEach(() => { processUpdates(); diff --git a/packages/angular-workspace/nimble-angular/table-column/anchor/tests/nimble-table-column-anchor-navigation-guard.directive.spec.ts b/packages/angular-workspace/nimble-angular/table-column/anchor/tests/nimble-table-column-anchor-navigation-guard.directive.spec.ts index 1756358247..a52ed3b7fd 100644 --- a/packages/angular-workspace/nimble-angular/table-column/anchor/tests/nimble-table-column-anchor-navigation-guard.directive.spec.ts +++ b/packages/angular-workspace/nimble-angular/table-column/anchor/tests/nimble-table-column-anchor-navigation-guard.directive.spec.ts @@ -76,7 +76,7 @@ describe('Nimble anchor table column navigation guard', () => { const pageObject = new TablePageObject(testHostComponent.table.nativeElement); anchor = pageObject.getRenderedCellAnchor(0, 0); innerAnchor = anchor!.shadowRoot!.querySelector('a')!; - anchorClickHandlerSpy = jasmine.createSpy('click'); + anchorClickHandlerSpy = jasmine.createSpy('click').and.callFake((event: Event) => event.preventDefault()); innerAnchor!.addEventListener('click', anchorClickHandlerSpy); onClickSpy = spyOn(testHostComponent, 'onClick'); @@ -127,7 +127,7 @@ describe('Nimble anchor table column navigation guard', () => { const pageObject = new TablePageObject(testHostComponent.table.nativeElement); anchor = pageObject.getRenderedCellAnchor(0, 0); innerAnchor = anchor!.shadowRoot!.querySelector('a')!; - anchorClickHandlerSpy = jasmine.createSpy('click'); + anchorClickHandlerSpy = jasmine.createSpy('click').and.callFake((event: Event) => event.preventDefault()); innerAnchor!.addEventListener('click', anchorClickHandlerSpy); onClickSpy = spyOn(testHostComponent, 'onClick'); From 1788e3ac91dddeff651537f03cd2a7538d3e5e86 Mon Sep 17 00:00:00 2001 From: Jesse Attas Date: Tue, 8 Oct 2024 11:51:50 -0500 Subject: [PATCH 05/11] Add test scripts for dev --- packages/angular-workspace/package.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/angular-workspace/package.json b/packages/angular-workspace/package.json index c8350d58cb..3453ec4bd6 100644 --- a/packages/angular-workspace/package.json +++ b/packages/angular-workspace/package.json @@ -20,7 +20,11 @@ "pack:application": "cd dist/example-client-app && npm pack", "performance": "lhci autorun", "watch": "ng build --watch --configuration development", + "tdd:nimble": "ng test @ni/nimble-angular --browsers=Chrome", + "tdd:spright": "ng test @ni/spright-angular --browsers=Chrome", "test": "ng test --watch=false", + "test:nimble": "ng test @ni/nimble-angular --watch=false", + "test:spright": "ng test @ni/spright-angular --watch=false", "lint": "ng lint", "format": "ng lint --fix" }, From b1cd9f403332d68ef743a94f80df0d6423521f6d Mon Sep 17 00:00:00 2001 From: Jesse Attas Date: Tue, 8 Oct 2024 11:58:06 -0500 Subject: [PATCH 06/11] Remove provideLocationMocks() --- .../tests/nimble-anchor-router-link-with-href.directive.spec.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/angular-workspace/nimble-angular/src/directives/anchor/tests/nimble-anchor-router-link-with-href.directive.spec.ts b/packages/angular-workspace/nimble-angular/src/directives/anchor/tests/nimble-anchor-router-link-with-href.directive.spec.ts index 4ab93fafdc..766a67a4c8 100644 --- a/packages/angular-workspace/nimble-angular/src/directives/anchor/tests/nimble-anchor-router-link-with-href.directive.spec.ts +++ b/packages/angular-workspace/nimble-angular/src/directives/anchor/tests/nimble-anchor-router-link-with-href.directive.spec.ts @@ -1,5 +1,4 @@ import { Component, ElementRef, Sanitizer, SecurityContext, ViewChild } from '@angular/core'; -import { provideLocationMocks } from '@angular/common/testing'; import { fakeAsync, TestBed, tick } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; import { provideRouter, Router } from '@angular/router'; @@ -50,7 +49,6 @@ describe('Nimble anchor RouterLinkWithHrefDirective', () => { { path: 'page1', component: BlankComponent }, { path: '', component: TestHostComponent } ]), - provideLocationMocks() ] }); harness = await RouterTestingHarness.create(''); From b69736199519268052da345e3714f9be2f8fb80d Mon Sep 17 00:00:00 2001 From: Jesse Attas Date: Tue, 8 Oct 2024 13:30:46 -0500 Subject: [PATCH 07/11] xdescribe -> describe --- ...nimble-anchor-button-router-link-with-href.directive.spec.ts | 2 +- ...ble-anchor-menu-item-router-link-with-href.directive.spec.ts | 2 +- .../nimble-anchor-tab-router-link-with-href.directive.spec.ts | 2 +- ...ble-anchor-tree-item-router-link-with-href.directive.spec.ts | 2 +- ...mble-breadcrumb-item-router-link-with-href.directive.spec.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/angular-workspace/nimble-angular/src/directives/anchor-button/tests/nimble-anchor-button-router-link-with-href.directive.spec.ts b/packages/angular-workspace/nimble-angular/src/directives/anchor-button/tests/nimble-anchor-button-router-link-with-href.directive.spec.ts index 8f10baa506..c5a7741bd3 100644 --- a/packages/angular-workspace/nimble-angular/src/directives/anchor-button/tests/nimble-anchor-button-router-link-with-href.directive.spec.ts +++ b/packages/angular-workspace/nimble-angular/src/directives/anchor-button/tests/nimble-anchor-button-router-link-with-href.directive.spec.ts @@ -9,7 +9,7 @@ import { processUpdates } from '../../../testing/async-helpers'; import { NimbleAnchorButtonModule } from '../nimble-anchor-button.module'; import type { AnchorButton } from '../nimble-anchor-button.directive'; -xdescribe('Nimble anchor button RouterLinkWithHrefDirective', () => { +describe('Nimble anchor button RouterLinkWithHrefDirective', () => { @Component({ template: ` diff --git a/packages/angular-workspace/nimble-angular/src/directives/anchor-menu-item/tests/nimble-anchor-menu-item-router-link-with-href.directive.spec.ts b/packages/angular-workspace/nimble-angular/src/directives/anchor-menu-item/tests/nimble-anchor-menu-item-router-link-with-href.directive.spec.ts index 0b1c4f8c8f..e43ef5447f 100644 --- a/packages/angular-workspace/nimble-angular/src/directives/anchor-menu-item/tests/nimble-anchor-menu-item-router-link-with-href.directive.spec.ts +++ b/packages/angular-workspace/nimble-angular/src/directives/anchor-menu-item/tests/nimble-anchor-menu-item-router-link-with-href.directive.spec.ts @@ -9,7 +9,7 @@ import { processUpdates } from '../../../testing/async-helpers'; import { NimbleAnchorMenuItemModule } from '../nimble-anchor-menu-item.module'; import type { AnchorMenuItem } from '../nimble-anchor-menu-item.directive'; -xdescribe('Nimble anchor menu item RouterLinkWithHrefDirective', () => { +describe('Nimble anchor menu item RouterLinkWithHrefDirective', () => { @Component({ template: ` diff --git a/packages/angular-workspace/nimble-angular/src/directives/anchor-tab/tests/nimble-anchor-tab-router-link-with-href.directive.spec.ts b/packages/angular-workspace/nimble-angular/src/directives/anchor-tab/tests/nimble-anchor-tab-router-link-with-href.directive.spec.ts index 18af8797ce..008aa71d81 100644 --- a/packages/angular-workspace/nimble-angular/src/directives/anchor-tab/tests/nimble-anchor-tab-router-link-with-href.directive.spec.ts +++ b/packages/angular-workspace/nimble-angular/src/directives/anchor-tab/tests/nimble-anchor-tab-router-link-with-href.directive.spec.ts @@ -9,7 +9,7 @@ import { processUpdates } from '../../../testing/async-helpers'; import { NimbleAnchorTabModule } from '../nimble-anchor-tab.module'; import type { AnchorTab } from '../nimble-anchor-tab.directive'; -xdescribe('Nimble anchor tab RouterLinkWithHrefDirective', () => { +describe('Nimble anchor tab RouterLinkWithHrefDirective', () => { @Component({ template: ` diff --git a/packages/angular-workspace/nimble-angular/src/directives/anchor-tree-item/tests/nimble-anchor-tree-item-router-link-with-href.directive.spec.ts b/packages/angular-workspace/nimble-angular/src/directives/anchor-tree-item/tests/nimble-anchor-tree-item-router-link-with-href.directive.spec.ts index 4a49609fe8..f0b25f0291 100644 --- a/packages/angular-workspace/nimble-angular/src/directives/anchor-tree-item/tests/nimble-anchor-tree-item-router-link-with-href.directive.spec.ts +++ b/packages/angular-workspace/nimble-angular/src/directives/anchor-tree-item/tests/nimble-anchor-tree-item-router-link-with-href.directive.spec.ts @@ -9,7 +9,7 @@ import { processUpdates } from '../../../testing/async-helpers'; import { NimbleAnchorTreeItemModule } from '../nimble-anchor-tree-item.module'; import type { AnchorTreeItem } from '../nimble-anchor-tree-item.directive'; -xdescribe('Nimble anchor tree item RouterLinkWithHrefDirective', () => { +describe('Nimble anchor tree item RouterLinkWithHrefDirective', () => { @Component({ template: ` diff --git a/packages/angular-workspace/nimble-angular/src/directives/breadcrumb-item/tests/nimble-breadcrumb-item-router-link-with-href.directive.spec.ts b/packages/angular-workspace/nimble-angular/src/directives/breadcrumb-item/tests/nimble-breadcrumb-item-router-link-with-href.directive.spec.ts index 31be12e11f..0a7b9a9f70 100644 --- a/packages/angular-workspace/nimble-angular/src/directives/breadcrumb-item/tests/nimble-breadcrumb-item-router-link-with-href.directive.spec.ts +++ b/packages/angular-workspace/nimble-angular/src/directives/breadcrumb-item/tests/nimble-breadcrumb-item-router-link-with-href.directive.spec.ts @@ -10,7 +10,7 @@ import { NimbleBreadcrumbModule } from '../../breadcrumb/nimble-breadcrumb.modul import { NimbleBreadcrumbItemModule } from '../nimble-breadcrumb-item.module'; import type { BreadcrumbItem } from '../nimble-breadcrumb-item.directive'; -xdescribe('Nimble breadcrumb item RouterLinkWithHrefDirective', () => { +describe('Nimble breadcrumb item RouterLinkWithHrefDirective', () => { @Component({ template: ` From a0ea777ced9e46ad944638318952d1c488a2520f Mon Sep 17 00:00:00 2001 From: Jesse Attas Date: Tue, 8 Oct 2024 13:35:28 -0500 Subject: [PATCH 08/11] tick --- ...imble-breadcrumb-item-router-link-with-href.directive.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/angular-workspace/nimble-angular/src/directives/breadcrumb-item/tests/nimble-breadcrumb-item-router-link-with-href.directive.spec.ts b/packages/angular-workspace/nimble-angular/src/directives/breadcrumb-item/tests/nimble-breadcrumb-item-router-link-with-href.directive.spec.ts index 0a7b9a9f70..f6ce47b8d9 100644 --- a/packages/angular-workspace/nimble-angular/src/directives/breadcrumb-item/tests/nimble-breadcrumb-item-router-link-with-href.directive.spec.ts +++ b/packages/angular-workspace/nimble-angular/src/directives/breadcrumb-item/tests/nimble-breadcrumb-item-router-link-with-href.directive.spec.ts @@ -66,7 +66,6 @@ describe('Nimble breadcrumb item RouterLinkWithHrefDirective', () => { location = TestBed.inject(Location); testHostComponent = harness.fixture.debugElement.query(By.directive(TestHostComponent)).componentInstance as TestHostComponent; breadcrumbItem1 = testHostComponent.breadcrumbItem1.nativeElement; - // tick(); processUpdates(); anchor = breadcrumbItem1!.shadowRoot!.querySelector('a')!; separator = breadcrumbItem1!.shadowRoot!.querySelector('.separator')!; From 9f9681dfc49971d448e6148b52e650a30c939a19 Mon Sep 17 00:00:00 2001 From: Jesse Attas Date: Tue, 8 Oct 2024 14:05:15 -0500 Subject: [PATCH 09/11] Retrigger workflow --- ...mble-breadcrumb-item-router-link-with-href.directive.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/angular-workspace/nimble-angular/src/directives/breadcrumb-item/tests/nimble-breadcrumb-item-router-link-with-href.directive.spec.ts b/packages/angular-workspace/nimble-angular/src/directives/breadcrumb-item/tests/nimble-breadcrumb-item-router-link-with-href.directive.spec.ts index f6ce47b8d9..ecd1990b50 100644 --- a/packages/angular-workspace/nimble-angular/src/directives/breadcrumb-item/tests/nimble-breadcrumb-item-router-link-with-href.directive.spec.ts +++ b/packages/angular-workspace/nimble-angular/src/directives/breadcrumb-item/tests/nimble-breadcrumb-item-router-link-with-href.directive.spec.ts @@ -55,7 +55,7 @@ describe('Nimble breadcrumb item RouterLinkWithHrefDirective', () => { provideRouter([ { path: 'page1', component: BlankComponent }, { path: '', component: TestHostComponent } - ]), + ]) ] }); harness = await RouterTestingHarness.create(''); From 56a3afd4a694b61e08719151523970ef1fcec958 Mon Sep 17 00:00:00 2001 From: Jesse Attas Date: Wed, 9 Oct 2024 16:41:21 -0500 Subject: [PATCH 10/11] npm script names : to - Co-authored-by: Milan Raj --- packages/angular-workspace/package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/angular-workspace/package.json b/packages/angular-workspace/package.json index 3453ec4bd6..0e128c1a5e 100644 --- a/packages/angular-workspace/package.json +++ b/packages/angular-workspace/package.json @@ -20,11 +20,11 @@ "pack:application": "cd dist/example-client-app && npm pack", "performance": "lhci autorun", "watch": "ng build --watch --configuration development", - "tdd:nimble": "ng test @ni/nimble-angular --browsers=Chrome", - "tdd:spright": "ng test @ni/spright-angular --browsers=Chrome", + "tdd-nimble": "ng test @ni/nimble-angular --browsers=Chrome", + "tdd-spright": "ng test @ni/spright-angular --browsers=Chrome", "test": "ng test --watch=false", - "test:nimble": "ng test @ni/nimble-angular --watch=false", - "test:spright": "ng test @ni/spright-angular --watch=false", + "test-nimble": "ng test @ni/nimble-angular --watch=false", + "test-spright": "ng test @ni/spright-angular --watch=false", "lint": "ng lint", "format": "ng lint --fix" }, From ac3496eb55a381cce5694466fde81cf4f33c1e89 Mon Sep 17 00:00:00 2001 From: Jesse Attas Date: Wed, 9 Oct 2024 16:43:21 -0500 Subject: [PATCH 11/11] Rename watch commands --- packages/angular-workspace/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/angular-workspace/package.json b/packages/angular-workspace/package.json index 0e128c1a5e..2862b6817e 100644 --- a/packages/angular-workspace/package.json +++ b/packages/angular-workspace/package.json @@ -7,9 +7,7 @@ "start": "ng serve", "build": "npm run build:nimble && npm run build:spright && npm run build:application", "build:nimble": "npm run generate-icons && ng build @ni/nimble-angular", - "watch:nimble": "npm run generate-icons && ng build @ni/nimble-angular --watch", "build:spright": "ng build @ni/spright-angular", - "watch:spright": "ng build @ni/spright-angular --watch", "build:application": "ng build example-client-app", "generate-icons": "npm run generate-icons:bundle && npm run generate-icons:run", "generate-icons:bundle": "rollup --bundleConfigAsCjs --config nimble-angular/build/generate-icons/rollup.config.js", @@ -20,6 +18,8 @@ "pack:application": "cd dist/example-client-app && npm pack", "performance": "lhci autorun", "watch": "ng build --watch --configuration development", + "watch-nimble": "npm run generate-icons && ng build @ni/nimble-angular --watch", + "watch-spright": "ng build @ni/spright-angular --watch", "tdd-nimble": "ng test @ni/nimble-angular --browsers=Chrome", "tdd-spright": "ng test @ni/spright-angular --browsers=Chrome", "test": "ng test --watch=false",