Skip to content

Commit

Permalink
test(elements): clean up TestStrategy between tests (#36114)
Browse files Browse the repository at this point in the history
Previously, the `TestStrategy` `NgElementStrategy` used in
`createCustomElement()` tests was created once and re-used in each test
(due to complications related to how `customElements.register()` works).
As a result, the `TestStrategy` instance's state (e.g. inputs) could be
polluted from previous tests and affect subsequent ones.

This commit ensures the strategy instance is reset before each test.

PR Close #36114
  • Loading branch information
gkalpak authored and subratpalhar92 committed Aug 15, 2020
1 parent 7f79e74 commit f33ca6f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/elements/test/create-custom-element_spec.ts
Expand Up @@ -45,6 +45,8 @@ if (browserDetection.supportsCustomElements) {
.then(done, done.fail);
});

afterEach(() => strategy.reset());

afterAll(() => destroyPlatform());

it('should use a default strategy for converting component inputs', () => {
Expand Down Expand Up @@ -155,6 +157,12 @@ if (browserDetection.supportsCustomElements) {
setInputValue(propName: string, value: string): void {
this.inputs.set(propName, value);
}

reset(): void {
this.connectedElement = null;
this.disconnectCalled = false;
this.inputs.clear();
}
}

class TestStrategyFactory implements NgElementStrategyFactory {
Expand Down

0 comments on commit f33ca6f

Please sign in to comment.