-
Notifications
You must be signed in to change notification settings - Fork 34
feat(components/indicators): add key info component harness #498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
aeb995e
feat(components/indicators): add key info component harness
Blackbaud-CoreyArcher 8498d4a
address most comments
Blackbaud-CoreyArcher d998dfc
Merge branch 'main' into key-indicator-harness
Blackbaud-CoreyArcher 7f6076d
return old fixtures to root folder
Blackbaud-CoreyArcher a268255
Merge branch 'main' of https://github.com/blackbaud/skyux into key-in…
Blackbaud-CoreyArcher 67d640c
Merge branch 'key-indicator-harness' of https://github.com/blackbaud/…
Blackbaud-CoreyArcher 665dc19
Merge branch 'main' into key-indicator-harness
Blackbaud-CoreyArcher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
libs/components/indicators/src/lib/modules/key-info/key-info-layout-type.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export type SkyKeyInfoLayoutType = 'horizontal' | 'vertical'; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
.../components/indicators/testing/src/key-info/fixtures/key-info-harness-test.component.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <sky-key-info data-sky-id="vertical-key-info"> | ||
| <sky-key-info-value>100</sky-key-info-value> | ||
| <sky-key-info-label>Vertical label</sky-key-info-label> | ||
| </sky-key-info> | ||
| <sky-key-info [layout]="horizontalLayout" data-sky-id="horizontal-key-info"> | ||
| <sky-key-info-value>200</sky-key-info-value> | ||
| <sky-key-info-label>Horizontal label</sky-key-info-label> | ||
| </sky-key-info> |
10 changes: 10 additions & 0 deletions
10
libs/components/indicators/testing/src/key-info/fixtures/key-info-harness-test.component.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { Component } from '@angular/core'; | ||
| import { SkyKeyInfoLayoutType } from '@skyux/indicators'; | ||
|
|
||
| @Component({ | ||
| selector: 'sky-test-key-info', | ||
| templateUrl: './key-info-harness-test.component.html', | ||
| }) | ||
| export class KeyInfoHarnessTestComponent { | ||
| public horizontalLayout: SkyKeyInfoLayoutType = 'horizontal'; | ||
| } |
12 changes: 12 additions & 0 deletions
12
libs/components/indicators/testing/src/key-info/fixtures/key-info-harness-test.module.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { CommonModule } from '@angular/common'; | ||
| import { NgModule } from '@angular/core'; | ||
| import { SkyKeyInfoModule } from '@skyux/indicators'; | ||
|
|
||
| import { KeyInfoHarnessTestComponent } from './key-info-harness-test.component'; | ||
|
|
||
| @NgModule({ | ||
| declarations: [KeyInfoHarnessTestComponent], | ||
| imports: [CommonModule, SkyKeyInfoModule], | ||
| exports: [KeyInfoHarnessTestComponent], | ||
| }) | ||
| export class KeyInfoHarnessTestModule {} |
8 changes: 8 additions & 0 deletions
8
libs/components/indicators/testing/src/key-info/key-info-harness-filters.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import { SkyHarnessFilters } from '@skyux/core/testing'; | ||
|
|
||
| /** | ||
| * A set of criteria that can be used to filter a list of SkyKeyInfoHarness instances. | ||
| * @internal | ||
| */ | ||
| // eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
| export interface SkyKeyInfoHarnessFilters extends SkyHarnessFilters {} |
49 changes: 49 additions & 0 deletions
49
libs/components/indicators/testing/src/key-info/key-info-harness.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; | ||
| import { TestBed } from '@angular/core/testing'; | ||
|
|
||
| import { KeyInfoHarnessTestComponent } from './fixtures/key-info-harness-test.component'; | ||
| import { KeyInfoHarnessTestModule } from './fixtures/key-info-harness-test.module'; | ||
| import { SkyKeyInfoHarness } from './key-info-harness'; | ||
|
|
||
| describe('Key Info harness', () => { | ||
| async function setupTest(options: { dataSkyId?: string } = {}) { | ||
| const fixture = TestBed.createComponent(KeyInfoHarnessTestComponent); | ||
| const loader = TestbedHarnessEnvironment.loader(fixture); | ||
|
|
||
| const keyInfoHarness = await loader.getHarness( | ||
| SkyKeyInfoHarness.with({ dataSkyId: options.dataSkyId }) | ||
| ); | ||
|
|
||
| return { fixture, keyInfoHarness }; | ||
| } | ||
|
|
||
| beforeEach(() => { | ||
| TestBed.configureTestingModule({ | ||
| imports: [KeyInfoHarnessTestModule], | ||
| }); | ||
| }); | ||
|
|
||
| it('should return properties for a horizontal layout', async () => { | ||
| const { keyInfoHarness } = await setupTest({ | ||
| dataSkyId: 'horizontal-key-info', | ||
| }); | ||
|
|
||
| await expectAsync(keyInfoHarness.getLayout()).toBeResolvedTo('horizontal'); | ||
| await expectAsync(keyInfoHarness.getValueText()).toBeResolvedTo('200'); | ||
| await expectAsync(keyInfoHarness.getLabelText()).toBeResolvedTo( | ||
| 'Horizontal label' | ||
| ); | ||
| }); | ||
|
|
||
| it('should return properties for a vertical layout', async () => { | ||
| const { keyInfoHarness } = await setupTest({ | ||
| dataSkyId: 'vertical-key-info', | ||
| }); | ||
|
|
||
| await expectAsync(keyInfoHarness.getLayout()).toBeResolvedTo('vertical'); | ||
| await expectAsync(keyInfoHarness.getValueText()).toBeResolvedTo('100'); | ||
| await expectAsync(keyInfoHarness.getLabelText()).toBeResolvedTo( | ||
| 'Vertical label' | ||
| ); | ||
| }); | ||
| }); |
54 changes: 54 additions & 0 deletions
54
libs/components/indicators/testing/src/key-info/key-info-harness.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import { HarnessPredicate } from '@angular/cdk/testing'; | ||
| import { SkyComponentHarness } from '@skyux/core/testing'; | ||
| import { SkyKeyInfoLayoutType } from '@skyux/indicators'; | ||
|
|
||
| import { SkyKeyInfoHarnessFilters } from './key-info-harness-filters'; | ||
| import { SkyKeyInfoLabelHarness } from './key-info-label-harness'; | ||
| import { SkyKeyInfoValueHarness } from './key-info-value-harness'; | ||
|
|
||
| /** | ||
| * Harness for interacting with a key info component in tests. | ||
| * @internal | ||
| */ | ||
| export class SkyKeyInfoHarness extends SkyComponentHarness { | ||
| public static hostSelector = 'sky-key-info'; | ||
|
|
||
| #getLabel = this.locatorFor(SkyKeyInfoLabelHarness); | ||
Blackbaud-SteveBrush marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #getValue = this.locatorFor(SkyKeyInfoValueHarness); | ||
| #getWrapper = this.locatorFor('.sky-key-info'); | ||
|
|
||
| /** | ||
| * Gets a `HarnessPredicate` that can be used to search for a | ||
| * `SkyKeyInfoHarness` that meets certain criteria. | ||
| */ | ||
| public static with( | ||
| filters: SkyKeyInfoHarnessFilters | ||
| ): HarnessPredicate<SkyKeyInfoHarness> { | ||
| return SkyKeyInfoHarness.getDataSkyIdPredicate(filters); | ||
| } | ||
|
|
||
| /** | ||
| * Gets the current value text. | ||
| */ | ||
| public async getValueText(): Promise<string> { | ||
| return await (await this.#getValue()).getText(); | ||
| } | ||
|
|
||
| /** | ||
| * Gets the current label text. | ||
| */ | ||
| public async getLabelText(): Promise<string> { | ||
| return await (await this.#getLabel()).getText(); | ||
| } | ||
|
|
||
| /** | ||
| * Gets the current layout type. | ||
| */ | ||
| public async getLayout(): Promise<SkyKeyInfoLayoutType> { | ||
Blackbaud-SteveBrush marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return (await ( | ||
| await this.#getWrapper() | ||
| ).hasClass('sky-key-info-horizontal')) | ||
| ? 'horizontal' | ||
| : 'vertical'; | ||
| } | ||
| } | ||
16 changes: 16 additions & 0 deletions
16
libs/components/indicators/testing/src/key-info/key-info-label-harness.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { SkyComponentHarness } from '@skyux/core/testing'; | ||
|
|
||
| /** | ||
| * Harness for interacting with a key info label component in tests. | ||
| * @internal | ||
| */ | ||
| export class SkyKeyInfoLabelHarness extends SkyComponentHarness { | ||
Blackbaud-SteveBrush marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| public static hostSelector = 'sky-key-info-label'; | ||
|
|
||
| /** | ||
| * Gets the text value of the component content. | ||
| */ | ||
| public async getText(): Promise<string> { | ||
| return (await this.host()).text(); | ||
| } | ||
| } | ||
16 changes: 16 additions & 0 deletions
16
libs/components/indicators/testing/src/key-info/key-info-value-harness.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { SkyComponentHarness } from '@skyux/core/testing'; | ||
|
|
||
| /** | ||
| * Harness for interacting with a key info value component in tests. | ||
| * @internal | ||
| */ | ||
| export class SkyKeyInfoValueHarness extends SkyComponentHarness { | ||
Blackbaud-SteveBrush marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| public static hostSelector = 'sky-key-info-value'; | ||
|
|
||
| /** | ||
| * Gets the text value of the component content. | ||
| */ | ||
| public async getText(): Promise<string> { | ||
| return (await this.host()).text(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.