Skip to content

Commit ad3c537

Browse files
committed
chore: test cleanup
1 parent 9fcbc87 commit ad3c537

File tree

8 files changed

+17
-33
lines changed

8 files changed

+17
-33
lines changed

.eslintrc.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@
106106
"files": ["*.spec.ts"],
107107
"extends": ["plugin:jest/recommended"],
108108
"rules": {
109-
"jest/no-done-callback": "off",
110109
"jest/expect-expect": "off"
111110
}
112111
},

apps/example-app/src/app/examples/14-async-component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { fakeAsync, flush, tick } from '@angular/core/testing';
1+
import { fakeAsync, tick } from '@angular/core/testing';
22
import { render, screen, fireEvent } from '@testing-library/angular';
33

44
import { AsyncComponent } from './14-async-component';

apps/example-app/src/app/issues/issue-106.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class TestSelectComponent {
1515
}
1616
}
1717

18-
it('https://github.com/testing-library/angular-testing-library/issues/106', async () => {
18+
test('https://github.com/testing-library/angular-testing-library/issues/106', async () => {
1919
await render(TestSelectComponent);
2020
const toggle = screen.getByTestId('toggle');
2121
const hiddenText = screen.queryByTestId('getme');
@@ -30,7 +30,7 @@ it('https://github.com/testing-library/angular-testing-library/issues/106', asyn
3030
await waitFor(() => expect(screen.queryByTestId('getme')).toBeInTheDocument());
3131
});
3232

33-
it('better https://github.com/testing-library/angular-testing-library/issues/106', async () => {
33+
test('better https://github.com/testing-library/angular-testing-library/issues/106', async () => {
3434
await render(TestSelectComponent);
3535
const toggle = screen.getByTestId('toggle');
3636
const hiddenText = screen.queryByTestId('getme');

jest.preset.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ module.exports = {
77
},
88
resolver: '@nrwl/jest/plugins/resolver',
99
moduleFileExtensions: ['ts', 'js', 'html'],
10-
coverageReporters: ['html'],
11-
snapshotSerializers: [
12-
'jest-preset-angular/build/serializers/no-ng-attributes',
13-
'jest-preset-angular/build/serializers/ng-snapshot',
14-
'jest-preset-angular/build/serializers/html-comment',
15-
],
1610
globals: {
1711
'ts-jest': {
1812
tsconfig: '<rootDir>/tsconfig.spec.json',

projects/jest-utils/tests/create-mock.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ class FixtureComponent {
2424
}
2525
}
2626

27-
it('mocks all functions', () => {
27+
test('mocks all functions', () => {
2828
const mock = createMock(FixtureService);
2929
expect(mock.print.mock).toBeDefined();
3030
});
3131

32-
it('provides a mock service', async () => {
32+
test('provides a mock service', async () => {
3333
const { getByText } = await render(FixtureComponent, {
3434
providers: [provideMock(FixtureService)],
3535
});
@@ -39,7 +39,7 @@ it('provides a mock service', async () => {
3939
expect(service.print).toHaveBeenCalledTimes(1);
4040
});
4141

42-
it('is possible to write a mock implementation', async () => {
42+
test('is possible to write a mock implementation', async () => {
4343
const { getByText } = await render(FixtureComponent, {
4444
providers: [provideMock(FixtureService)],
4545
});

projects/testing-library/tests/issues/issue-188.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class BugOnChangeComponent implements OnChanges {
1717
}
1818
}
1919

20-
it('should output formatted name after rendering', async () => {
20+
test('should output formatted name after rendering', async () => {
2121
const { getByText } = await render(BugOnChangeComponent, { componentProperties: { name: 'name' } });
2222

2323
getByText('Hello NAME');

projects/testing-library/tests/issues/issue-67.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ import { render } from '../../src/public_api';
1515
})
1616
class BugGetByLabelTextComponent {}
1717

18-
it('first step to reproduce the bug: skip this test to avoid the error or remove the for attribute of label', async () => {
18+
test('first step to reproduce the bug: skip this test to avoid the error or remove the for attribute of label', async () => {
1919
expect(await render(BugGetByLabelTextComponent)).toBeDefined();
2020
});
2121

22-
it('second step: bug happens :`(', async () => {
22+
test('second step: bug happens :`(', async () => {
2323
const { getByLabelText, getByTestId } = await render(BugGetByLabelTextComponent);
2424

2525
const checkboxByTestId = getByTestId('checkbox');

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

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -126,28 +126,19 @@ describe('Angular component life-cycle hooks', () => {
126126
});
127127
});
128128

129-
test('Waits for angular app initialization before rendering components', (done) => {
130-
let resolve;
129+
test('waits for angular app initialization before rendering components', async () => {
130+
const mock = jest.fn();
131131

132-
const promise = new Promise((res) => {
133-
resolve = res;
134-
});
135-
136-
render(FixtureComponent, {
132+
await render(FixtureComponent, {
137133
providers: [
138134
{
139135
provide: APP_INITIALIZER,
140-
useFactory: () => () => promise,
136+
useFactory: () => mock,
141137
multi: true,
142138
},
143139
],
144-
})
145-
.then(() => {
146-
expect(TestBed.inject(ApplicationInitStatus).done).toEqual(true);
147-
done();
148-
})
149-
.catch(done);
150-
151-
// Wait a bit so the test will fail if render completes without us resolving the promise
152-
setTimeout(resolve, 1000);
140+
});
141+
142+
expect(TestBed.inject(ApplicationInitStatus).done).toEqual(true);
143+
expect(mock).toHaveBeenCalled();
153144
});

0 commit comments

Comments
 (0)