test(elements): clean up TestStrategy
between tests (#36114)
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
This commit is contained in:
parent
ed46d9ebd7
commit
cb719ee16e
@ -45,6 +45,8 @@ if (browserDetection.supportsCustomElements) {
|
|||||||
.then(done, done.fail);
|
.then(done, done.fail);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterEach(() => strategy.reset());
|
||||||
|
|
||||||
afterAll(() => destroyPlatform());
|
afterAll(() => destroyPlatform());
|
||||||
|
|
||||||
it('should use a default strategy for converting component inputs', () => {
|
it('should use a default strategy for converting component inputs', () => {
|
||||||
@ -155,6 +157,12 @@ if (browserDetection.supportsCustomElements) {
|
|||||||
setInputValue(propName: string, value: string): void {
|
setInputValue(propName: string, value: string): void {
|
||||||
this.inputs.set(propName, value);
|
this.inputs.set(propName, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reset(): void {
|
||||||
|
this.connectedElement = null;
|
||||||
|
this.disconnectCalled = false;
|
||||||
|
this.inputs.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TestStrategyFactory implements NgElementStrategyFactory {
|
class TestStrategyFactory implements NgElementStrategyFactory {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user