diff --git a/src/switcher.d.ts b/src/switcher.d.ts index 6714071..c527a17 100644 --- a/src/switcher.d.ts +++ b/src/switcher.d.ts @@ -151,6 +151,11 @@ export class Switcher { */ restrictRelay(restrict: boolean): Switcher; + /** + * Resets all strategy inputs + */ + resetInputs(): Switcher; + /** * Adds a strategy for validation */ diff --git a/src/switcherBuilder.js b/src/switcherBuilder.js index 0f5fb11..f2e789a 100644 --- a/src/switcherBuilder.js +++ b/src/switcherBuilder.js @@ -53,6 +53,11 @@ export class SwitcherBuilder { return this; } + resetInputs() { + this._input = undefined; + return this; + } + check(startegyType, input) { if (!this._input) { this._input = []; diff --git a/tests/switcher-client.test.js b/tests/switcher-client.test.js index 8327d53..6a41251 100644 --- a/tests/switcher-client.test.js +++ b/tests/switcher-client.test.js @@ -197,6 +197,22 @@ describe('E2E test - Client local #1:', function () { 'Group disabled'); }); + it('should clear strategy inputs', async function () { + // when + await switcher + .checkValue('Japan') + .checkNetwork('10.0.0.2') + .prepare('FF2FOR2020'); + + assert.exists(switcher.input); + assert.isTrue(await switcher.isItOn()); + + // test + switcher.resetInputs(); + assert.equal(switcher.input, undefined); + assert.isFalse(await switcher.isItOn()); + }); + it('should be valid - Local mode', async function () { this.timeout(3000);