-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
1,229 additions
and
1,238 deletions.
There are no files selected for viewing
This file contains 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,61 @@ | ||
import type { HarnessLoader } from '@angular/cdk/testing'; | ||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; | ||
import { Component } from '@angular/core'; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
import { MatButtonHarness } from '@angular/material/button/testing'; | ||
import { MATERIAL_SANITY_CHECKS } from '@angular/material/core'; | ||
|
||
@Component({ | ||
selector: 'snd-button-page', | ||
template: ` | ||
<p>button-page works!</p> | ||
<p> | ||
<button mat-button (click)="click()">Click</button> | ||
</p> | ||
`, | ||
styles: [], | ||
}) | ||
class ButtonPageComponent { | ||
r = 0; | ||
|
||
click(): void { | ||
this.r = 1; | ||
} | ||
} | ||
|
||
describe('ButtonPageComponent', () => { | ||
let component: ButtonPageComponent; | ||
let fixture: ComponentFixture<ButtonPageComponent>; | ||
let loader: HarnessLoader; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [MatButtonModule], | ||
declarations: [ButtonPageComponent], | ||
providers: [ | ||
{ | ||
provide: MATERIAL_SANITY_CHECKS, | ||
useValue: false, | ||
}, | ||
], | ||
}).compileComponents(); | ||
fixture = TestBed.createComponent(ButtonPageComponent); | ||
loader = TestbedHarnessEnvironment.loader(fixture); | ||
}); | ||
|
||
beforeEach(() => { | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should click', async () => { | ||
const button = await loader.getHarness(MatButtonHarness); | ||
await button.click(); | ||
expect(component.r).toBe(1); | ||
}); | ||
}); |
This file contains 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 |
---|---|---|
@@ -1,13 +1,23 @@ | ||
const jestCfg = require('./jest.config'); | ||
|
||
/** @type {import('ts-jest/dist/types').ProjectConfigTsJest} */ | ||
module.exports = { | ||
displayName: 'async', | ||
preset: '<rootDir>/../../node_modules/ts-jest/presets/default-esm', | ||
...jestCfg, | ||
globals: { | ||
'ts-jest': { | ||
useESM: true, | ||
tsconfig: '<rootDir>/../tsconfig-esm.json', | ||
tsconfig: { | ||
...require('../tsconfig-esm.json').compilerOptions, | ||
/** | ||
* Set at ES2018 to test Angular doesn't work with ES2017+ | ||
* see https://github.com/angular/components/issues/21632#issuecomment-764975917 | ||
*/ | ||
target: 'ES2018', | ||
}, | ||
}, | ||
}, | ||
setupFilesAfterEnv: ['<rootDir>/../../setup-jest.js'], | ||
transform: { '^.+\\.(ts|js|html)$': '<rootDir>/../../build/index.js' }, | ||
moduleNameMapper: { | ||
tslib: 'tslib/tslib.es6.js', | ||
}, | ||
transformIgnorePatterns: ['node_modules/(?!tslib)'], | ||
}; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.