From 424dbadbefc403be052344cc280f2f95fcb3538e Mon Sep 17 00:00:00 2001 From: petruki <31597636+petruki@users.noreply.github.com> Date: Sun, 5 May 2024 17:47:32 -0700 Subject: [PATCH] Moved fixture to test folder --- jsr.json | 18 ++++++++++++++++-- package.json | 2 +- sonar-project.properties | 2 +- src/declarations.d.ts | 1 + {snapshot => test/snapshot}/default.json | 0 {snapshot => test/snapshot}/dev.json | 0 {snapshot => test/snapshot}/dev_v2.json | 0 test/switcher-client.test.js | 2 +- test/switcher-functional.test.js | 12 ++++++------ test/switcher-snapshot.test.js | 8 ++++---- test/switcher-watch-snapshot.test.js | 2 +- tsconfig.json | 6 ++++++ 12 files changed, 37 insertions(+), 16 deletions(-) create mode 100644 src/declarations.d.ts rename {snapshot => test/snapshot}/default.json (100%) rename {snapshot => test/snapshot}/dev.json (100%) rename {snapshot => test/snapshot}/dev_v2.json (100%) create mode 100644 tsconfig.json diff --git a/jsr.json b/jsr.json index 371e3ff..67fc535 100644 --- a/jsr.json +++ b/jsr.json @@ -1,5 +1,19 @@ { "name": "@switcherapi/switcher-client-js", - "version": "4.0.4", - "exports": "./switcher-client.js" + "version": "4.0.5", + "exports": "./switcher-client.js", + "publish": { + "include": [ + "LICENSE", + "switcher-client.js", + "src/**/*" + ], + "exclude": [ + ".github", + ".vscode", + "test", + "sonar-project.properties", + ".snyk" + ] + } } \ No newline at end of file diff --git a/package.json b/package.json index 0dc9fc5..7ab2598 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "switcher-client", - "version": "4.0.4", + "version": "4.0.5", "description": "Client JS SDK for working with Switcher-API", "main": "./switcher-client.js", "type": "module", diff --git a/sonar-project.properties b/sonar-project.properties index 28be650..2511bc6 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,7 +1,7 @@ sonar.projectKey=switcherapi_switcher-client-master sonar.projectName=switcher-client-js sonar.organization=switcherapi -sonar.projectVersion=4.0.4 +sonar.projectVersion=4.0.5 sonar.links.homepage=https://github.com/switcherapi/switcher-client-js sonar.javascript.lcov.reportPaths=coverage/lcov.info diff --git a/src/declarations.d.ts b/src/declarations.d.ts new file mode 100644 index 0000000..3e8debe --- /dev/null +++ b/src/declarations.d.ts @@ -0,0 +1 @@ +declare module '@switcherapi/switcher-client-js'; \ No newline at end of file diff --git a/snapshot/default.json b/test/snapshot/default.json similarity index 100% rename from snapshot/default.json rename to test/snapshot/default.json diff --git a/snapshot/dev.json b/test/snapshot/dev.json similarity index 100% rename from snapshot/dev.json rename to test/snapshot/dev.json diff --git a/snapshot/dev_v2.json b/test/snapshot/dev_v2.json similarity index 100% rename from snapshot/dev_v2.json rename to test/snapshot/dev_v2.json diff --git a/test/switcher-client.test.js b/test/switcher-client.test.js index 1bcf325..802817a 100644 --- a/test/switcher-client.test.js +++ b/test/switcher-client.test.js @@ -18,7 +18,7 @@ describe('E2E test - Switcher local:', function () { }; const options = { - snapshotLocation: './snapshot/', + snapshotLocation: './test/snapshot/', local: true, logger: true, regexMaxBlackList: 1, diff --git a/test/switcher-functional.test.js b/test/switcher-functional.test.js index f481bb1..23b024e 100644 --- a/test/switcher-functional.test.js +++ b/test/switcher-functional.test.js @@ -12,7 +12,7 @@ describe('Integrated test - Switcher:', function () { let contextSettings; this.afterAll(function() { - unwatchFile('./snapshot/default.json'); + unwatchFile('./test/snapshot/default.json'); }); this.beforeEach(function() { @@ -198,7 +198,7 @@ describe('Integrated test - Switcher:', function () { const forceRemoteOptions = { local: true, - snapshotLocation: './snapshot/', + snapshotLocation: './test/snapshot/', regexSafe: false }; @@ -307,7 +307,7 @@ describe('Integrated test - Switcher:', function () { given(fetchStub, 0, { status: 429 }); //test - Switcher.buildContext(contextSettings, { silentMode: '5m', regexSafe: false, snapshotLocation: './snapshot/' }); + Switcher.buildContext(contextSettings, { silentMode: '5m', regexSafe: false, snapshotLocation: './test/snapshot/' }); await Switcher.checkSwitchers(['FEATURE01', 'FEATURE02']).catch(e => { assert.equal(e.message, 'Something went wrong: [FEATURE01,FEATURE02] not found'); }); @@ -322,7 +322,7 @@ describe('Integrated test - Switcher:', function () { // test let asyncErrorMessage = null; - Switcher.buildContext(contextSettings, { silentMode: '5m', regexSafe: false, snapshotLocation: './snapshot/' }); + Switcher.buildContext(contextSettings, { silentMode: '5m', regexSafe: false, snapshotLocation: './test/snapshot/' }); Switcher.subscribeNotifyError((error) => asyncErrorMessage = error.message); const switcher = Switcher.factory(); @@ -590,7 +590,7 @@ describe('Integrated test - Switcher:', function () { // setup context to read the snapshot in case the API does not respond Switcher.buildContext(contextSettings, { - snapshotLocation: './snapshot/', + snapshotLocation: './test/snapshot/', regexSafe: false, silentMode: '2s' }); @@ -642,7 +642,7 @@ describe('Integrated test - Switcher:', function () { // test Switcher.buildContext(contextSettings, { - snapshotLocation: './snapshot/', + snapshotLocation: './test/snapshot/', regexSafe: false, silentMode: '5m' }); diff --git a/test/switcher-snapshot.test.js b/test/switcher-snapshot.test.js index 1ce664c..3696a32 100644 --- a/test/switcher-snapshot.test.js +++ b/test/switcher-snapshot.test.js @@ -13,7 +13,7 @@ describe('E2E test - Switcher local - Snapshot:', function () { const environment = 'dev'; const url = 'http://localhost:3000'; - const dataBuffer = readFileSync('./snapshot/dev.json'); + const dataBuffer = readFileSync('./test/snapshot/dev.json'); const dataJSON = dataBuffer.toString(); let fetchStub; @@ -29,7 +29,7 @@ describe('E2E test - Switcher local - Snapshot:', function () { beforeEach(function() { Switcher.buildContext({ url, apiKey, domain, component, environment }, { - snapshotLocation: './snapshot/', + snapshotLocation: './test/snapshot/', local: true, regexSafe: false }); @@ -256,10 +256,10 @@ describe('E2E test - Snapshot AutoUpdater:', function () { const environment = 'dev'; const url = 'http://localhost:3000'; - const dataBuffer = readFileSync('./snapshot/dev.json'); + const dataBuffer = readFileSync('./test/snapshot/dev.json'); const dataJSON = dataBuffer.toString(); - const dataBufferV2 = readFileSync('./snapshot/dev_v2.json'); + const dataBufferV2 = readFileSync('./test/snapshot/dev_v2.json'); const dataJSONV2 = dataBufferV2.toString(); let fetchStub; diff --git a/test/switcher-watch-snapshot.test.js b/test/switcher-watch-snapshot.test.js index a3903f6..f084107 100644 --- a/test/switcher-watch-snapshot.test.js +++ b/test/switcher-watch-snapshot.test.js @@ -35,7 +35,7 @@ describe('E2E test - Switcher local - Watch Snapshot:', function () { mkdirSync('generated-snapshots/', { recursive: true }); } - const dataBuffer = readFileSync('./snapshot/dev.json'); + const dataBuffer = readFileSync('./test/snapshot/dev.json'); devJSON = JSON.parse(dataBuffer.toString()); devJSON.data.domain.group[0].config[0].activated = true; }); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..ef6c6c8 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,6 @@ +{ + "include": [ + "src/**/*", + "src/declarations.d.ts" + ] +} \ No newline at end of file