Skip to content

test: restructure app tests #42

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 1 commit into from
Aug 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"@angular/cli": "~8.0.0",
"@angular/compiler-cli": "^8.0.0",
"@angular/language-service": "^8.0.0",
"@testing-library/jest-dom": "^4.1.0",
"@types/jest": "~24.0.11",
"@types/node": "~12.0.3",
"codelyzer": "^5.0.1",
Expand Down
111 changes: 0 additions & 111 deletions projects/testing-library/tests/counter/counter.spec.ts

This file was deleted.

16 changes: 0 additions & 16 deletions projects/testing-library/tests/form/form.component.html

This file was deleted.

28 changes: 0 additions & 28 deletions projects/testing-library/tests/form/form.component.ts

This file was deleted.

38 changes: 0 additions & 38 deletions projects/testing-library/tests/form/form.spec.ts

This file was deleted.

50 changes: 32 additions & 18 deletions projects/testing-library/tests/render.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,49 @@ import { render } from '../src/public_api';

@Component({
selector: 'fixture',
template: ``,
template: `
<input type="text" data-testid="input" />
<button>button</button>
`,
})
class FixtureComponent {}

test('creates queries and events', async () => {
const component = await render(FixtureComponent);

component.input(component.getByTestId('input'), { target: { value: 'a super awesome input' } });
component.getByDisplayValue('a super awesome input');
component.click(component.getByText('button'));
});

@NgModule({
declarations: [FixtureComponent],
})
export class FixtureModule {}

test('should not throw if component is declared in an import', async () => {
await render(FixtureComponent, {
imports: [FixtureModule],
excludeComponentDeclaration: true,
describe('excludeComponentDeclaration', () => {
test('should not throw if component is declared in an import', async () => {
await render(FixtureComponent, {
imports: [FixtureModule],
excludeComponentDeclaration: true,
});
});
});

test('should add NoopAnimationsModule by default', async () => {
await render(FixtureComponent);
const noopAnimationsModule = TestBed.get<NoopAnimationsModule>(NoopAnimationsModule);
expect(noopAnimationsModule).toBeDefined();
});

test('should not add NoopAnimationsModule if BrowserAnimationsModule is an import', async () => {
await render(FixtureComponent, {
imports: [BrowserAnimationsModule],
describe('animationModule', () => {
test('should add NoopAnimationsModule by default', async () => {
await render(FixtureComponent);
const noopAnimationsModule = TestBed.get<NoopAnimationsModule>(NoopAnimationsModule);
expect(noopAnimationsModule).toBeDefined();
});

const browserAnimationsModule = TestBed.get<BrowserAnimationsModule>(BrowserAnimationsModule);
expect(browserAnimationsModule).toBeDefined();
test('should not add NoopAnimationsModule if BrowserAnimationsModule is an import', async () => {
await render(FixtureComponent, {
imports: [BrowserAnimationsModule],
});

expect(() => TestBed.get<NoopAnimationsModule>(NoopAnimationsModule)).toThrow();
const browserAnimationsModule = TestBed.get<BrowserAnimationsModule>(BrowserAnimationsModule);
expect(browserAnimationsModule).toBeDefined();

expect(() => TestBed.get<NoopAnimationsModule>(NoopAnimationsModule)).toThrow();
});
});
1 change: 0 additions & 1 deletion projects/testing-library/tests/wrapper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class WrapperComponent implements OnInit {
}

test('allows for a custom wrapper', async () => {
jest.spyOn(console, 'log').mockImplementation(() => {});
const { getByText } = await render('<fixture></fixture>', {
declarations: [FixtureComponent],
wrapper: WrapperComponent,
Expand Down
Loading