Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5d623f3

Browse files
test: restructure app tests (testing-library#42)
1 parent ddbc1fc commit 5d623f3

35 files changed

+877
-864
lines changed

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"@angular/cli": "~8.0.0",
5151
"@angular/compiler-cli": "^8.0.0",
5252
"@angular/language-service": "^8.0.0",
53+
"@testing-library/jest-dom": "^4.1.0",
5354
"@types/jest": "~24.0.11",
5455
"@types/node": "~12.0.3",
5556
"codelyzer": "^5.0.1",

‎projects/testing-library/tests/counter/counter.spec.ts‎

Lines changed: 0 additions & 111 deletions
This file was deleted.

‎projects/testing-library/tests/form/form.component.html‎

Lines changed: 0 additions & 16 deletions
This file was deleted.

‎projects/testing-library/tests/form/form.component.ts‎

Lines changed: 0 additions & 28 deletions
This file was deleted.

‎projects/testing-library/tests/form/form.spec.ts‎

Lines changed: 0 additions & 38 deletions
This file was deleted.

‎projects/testing-library/tests/render.spec.ts‎

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,49 @@ import { render } from '../src/public_api';
55

66
@Component({
77
selector: 'fixture',
8-
template: ``,
8+
template: `
9+
<input type="text" data-testid="input" />
10+
<button>button</button>
11+
`,
912
})
1013
class FixtureComponent {}
1114

15+
test('creates queries and events', async () => {
16+
const component = await render(FixtureComponent);
17+
18+
component.input(component.getByTestId('input'), { target: { value: 'a super awesome input' } });
19+
component.getByDisplayValue('a super awesome input');
20+
component.click(component.getByText('button'));
21+
});
22+
1223
@NgModule({
1324
declarations: [FixtureComponent],
1425
})
1526
export class FixtureModule {}
16-
17-
test('should not throw if component is declared in an import', async () => {
18-
await render(FixtureComponent, {
19-
imports: [FixtureModule],
20-
excludeComponentDeclaration: true,
27+
describe('excludeComponentDeclaration', () => {
28+
test('should not throw if component is declared in an import', async () => {
29+
await render(FixtureComponent, {
30+
imports: [FixtureModule],
31+
excludeComponentDeclaration: true,
32+
});
2133
});
2234
});
2335

24-
test('should add NoopAnimationsModule by default', async () => {
25-
await render(FixtureComponent);
26-
const noopAnimationsModule = TestBed.get<NoopAnimationsModule>(NoopAnimationsModule);
27-
expect(noopAnimationsModule).toBeDefined();
28-
});
29-
30-
test('should not add NoopAnimationsModule if BrowserAnimationsModule is an import', async () => {
31-
await render(FixtureComponent, {
32-
imports: [BrowserAnimationsModule],
36+
describe('animationModule', () => {
37+
test('should add NoopAnimationsModule by default', async () => {
38+
await render(FixtureComponent);
39+
const noopAnimationsModule = TestBed.get<NoopAnimationsModule>(NoopAnimationsModule);
40+
expect(noopAnimationsModule).toBeDefined();
3341
});
3442

35-
const browserAnimationsModule = TestBed.get<BrowserAnimationsModule>(BrowserAnimationsModule);
36-
expect(browserAnimationsModule).toBeDefined();
43+
test('should not add NoopAnimationsModule if BrowserAnimationsModule is an import', async () => {
44+
await render(FixtureComponent, {
45+
imports: [BrowserAnimationsModule],
46+
});
3747

38-
expect(() => TestBed.get<NoopAnimationsModule>(NoopAnimationsModule)).toThrow();
48+
const browserAnimationsModule = TestBed.get<BrowserAnimationsModule>(BrowserAnimationsModule);
49+
expect(browserAnimationsModule).toBeDefined();
50+
51+
expect(() => TestBed.get<NoopAnimationsModule>(NoopAnimationsModule)).toThrow();
52+
});
3953
});

‎projects/testing-library/tests/wrapper.spec.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class WrapperComponent implements OnInit {
2020
}
2121

2222
test('allows for a custom wrapper', async () => {
23-
jest.spyOn(console, 'log').mockImplementation(() => {});
2423
const { getByText } = await render('<fixture></fixture>', {
2524
declarations: [FixtureComponent],
2625
wrapper: WrapperComponent,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /