From d98d0dbf17a9dfca7f605cce7e307b482feed33a Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Wed, 20 May 2020 11:10:25 +0300 Subject: [PATCH] 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 --- packages/elements/test/create-custom-element_spec.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/elements/test/create-custom-element_spec.ts b/packages/elements/test/create-custom-element_spec.ts index 0f22c9a2f2..7df5327569 100644 --- a/packages/elements/test/create-custom-element_spec.ts +++ b/packages/elements/test/create-custom-element_spec.ts @@ -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', () => { @@ -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 {