From 4256b66b13351a03e622b1c860154c7182b98f1f Mon Sep 17 00:00:00 2001 From: "Zaid \"Nico" Date: Thu, 25 Feb 2021 11:54:45 -0500 Subject: [PATCH 1/6] rename lint.yml to quality.yml and add tests step --- .github/workflows/{lint.yml => quality.yml} | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) rename .github/workflows/{lint.yml => quality.yml} (88%) diff --git a/.github/workflows/lint.yml b/.github/workflows/quality.yml similarity index 88% rename from .github/workflows/lint.yml rename to .github/workflows/quality.yml index 5432e2e..3c9dea1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/quality.yml @@ -2,7 +2,7 @@ name: Lint on: [push, pull_request] jobs: lint: - name: ESLint + name: Quality Check runs-on: ubuntu-latest steps: - name: Checkout repository @@ -30,3 +30,7 @@ jobs: - name: Run ESLint run: pnpm run lint + + - name: Run Jest Tests + run: pnpm run test + \ No newline at end of file From 4c77fb8c3c93b1b01192d9c1b7c8bf08bd60c2d9 Mon Sep 17 00:00:00 2001 From: "Zaid \"Nico" Date: Thu, 25 Feb 2021 12:00:22 -0500 Subject: [PATCH 2/6] whoopsie --- .github/workflows/quality.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index 3c9dea1..f7356e8 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -1,4 +1,4 @@ -name: Lint +name: Quality Check on: [push, pull_request] jobs: lint: @@ -33,4 +33,3 @@ jobs: - name: Run Jest Tests run: pnpm run test - \ No newline at end of file From ab248b2c486d5af63bb1d651a593abaebe097573 Mon Sep 17 00:00:00 2001 From: "Zaid \"Nico" Date: Thu, 25 Feb 2021 12:04:28 -0500 Subject: [PATCH 3/6] use pnpm install recursive --- .github/workflows/quality.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index f7356e8..eef2122 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -23,7 +23,7 @@ jobs: key: ${{ runner.os }}-modules-${{ hashFiles('**/pnpm-lock.yaml') }} - name: Install deps - run: pnpm i + run: pnpm i --r - name: Build the code run: pnpm run build From f70b56a2e8b2d052ce1949caf30815f6bd0ed73a Mon Sep 17 00:00:00 2001 From: "Zaid \"Nico" Date: Thu, 25 Feb 2021 12:08:18 -0500 Subject: [PATCH 4/6] add missing @babel/generator dep --- package.json | 1 + pnpm-lock.yaml | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/package.json b/package.json index 32d560d..7d51c76 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "homepage": "https://github.com/cordis-lib/cordis#readme", "devDependencies": { "@babel/core": "^7.12.17", + "@babel/generator": "^7.13.0", "@babel/preset-env": "^7.12.17", "@babel/preset-typescript": "^7.12.17", "@strictsoftware/typedoc-plugin-monorepo": "^0.3.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 332cb9f..b495cd8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2,6 +2,7 @@ importers: .: devDependencies: '@babel/core': 7.12.17 + '@babel/generator': 7.13.0 '@babel/preset-env': 7.12.17_@babel+core@7.12.17 '@babel/preset-typescript': 7.12.17_@babel+core@7.12.17 '@strictsoftware/typedoc-plugin-monorepo': 0.3.1_typedoc@0.19.2 @@ -24,6 +25,7 @@ importers: typescript: 4.2.2 specifiers: '@babel/core': ^7.12.17 + '@babel/generator': ^7.13.0 '@babel/preset-env': ^7.12.17 '@babel/preset-typescript': ^7.12.17 '@strictsoftware/typedoc-plugin-monorepo': ^0.3.1 @@ -308,6 +310,14 @@ packages: dev: true resolution: integrity: sha512-DSA7ruZrY4WI8VxuS1jWSRezFnghEoYEFrZcw9BizQRmOZiUsiHl59+qEARGPqPikwA/GPTyRCi7isuCK/oyqg== + /@babel/generator/7.13.0: + dependencies: + '@babel/types': 7.13.0 + jsesc: 2.5.2 + source-map: 0.5.7 + dev: true + resolution: + integrity: sha512-zBZfgvBB/ywjx0Rgc2+BwoH/3H+lDtlgD4hBOpEv5LxRnYsm/753iRuLepqnYlynpjC3AdQxtxsoeHJoEEwOAw== /@babel/helper-annotate-as-pure/7.12.13: dependencies: '@babel/types': 7.12.17 @@ -1220,6 +1230,14 @@ packages: dev: true resolution: integrity: sha512-tNMDjcv/4DIcHxErTgwB9q2ZcYyN0sUfgGKUK/mm1FJK7Wz+KstoEekxrl/tBiNDgLK1HGi+sppj1An/1DR4fQ== + /@babel/types/7.13.0: + dependencies: + '@babel/helper-validator-identifier': 7.12.11 + lodash: 4.17.21 + to-fast-properties: 2.0.0 + dev: true + resolution: + integrity: sha512-hE+HE8rnG1Z6Wzo+MhaKE5lM5eMx71T4EHJgku2E3xIfaULhDcxiiRxUYgwX8qwP1BBSlag+TdGOt6JAidIZTA== /@bcoe/v8-coverage/0.2.3: dev: true resolution: From c55861086e54d6a4d8b94a08cc4095ee9880a336 Mon Sep 17 00:00:00 2001 From: "Zaid \"Nico" Date: Thu, 25 Feb 2021 12:16:29 -0500 Subject: [PATCH 5/6] revert recursive install and switch to test:ci --- .github/workflows/quality.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index eef2122..7674939 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -23,7 +23,7 @@ jobs: key: ${{ runner.os }}-modules-${{ hashFiles('**/pnpm-lock.yaml') }} - name: Install deps - run: pnpm i --r + run: pnpm i - name: Build the code run: pnpm run build @@ -32,4 +32,4 @@ jobs: run: pnpm run lint - name: Run Jest Tests - run: pnpm run test + run: pnpm run test:ci From 45207ce1980acb92e7348cb3564f1091c89e8382 Mon Sep 17 00:00:00 2001 From: didinele Date: Thu, 25 Feb 2021 19:34:07 +0200 Subject: [PATCH 6/6] fix(store): tests left open handles --- libs/store/src/index.test.ts | 127 ++++++++++++++++++----------------- 1 file changed, 65 insertions(+), 62 deletions(-) diff --git a/libs/store/src/index.test.ts b/libs/store/src/index.test.ts index 78f721c..fa748cf 100644 --- a/libs/store/src/index.test.ts +++ b/libs/store/src/index.test.ts @@ -1,117 +1,120 @@ import { Store, CordisStoreTypeError } from './Store'; -describe('constructing a bag', () => { +describe('constructing a store', () => { test('max size', () => { - const bag = new Store({ maxSize: 1 }); + const store = new Store({ maxSize: 1 }); - bag.set('boop', 1); - expect(bag.size).toBe(1); - expect(bag.has('boop')).toBe(true); + store.set('boop', 1); + expect(store.size).toBe(1); + expect(store.has('boop')).toBe(true); - bag.set('boop2', 1); - expect(bag.size).toBe(1); - expect(bag.has('boop')).toBe(false); - expect(bag.has('boop2')).toBe(true); + store.set('boop2', 1); + expect(store.size).toBe(1); + expect(store.has('boop')).toBe(false); + expect(store.has('boop2')).toBe(true); }); describe('auto emptying', () => { test('all elements', async () => { - const bag = new Store({ emptyEvery: 300 }); - bag.set('boop', 1); + const store = new Store({ emptyEvery: 300 }); + store.set('boop', 1); await new Promise(resolve => setTimeout(resolve, 300)); - expect(bag.size).toBe(0); + expect(store.size).toBe(0); + clearTimeout(store.emptyTimer!); }); test('certain elements', async () => { - const bag = new Store({ emptyEvery: 300, emptyCb: v => v === 1 }); - bag.set('boop', 1); - bag.set('boop2', 2); + const store = new Store({ emptyEvery: 300, emptyCb: v => v === 1 }); + store.set('boop', 1); + store.set('boop2', 2); await new Promise(resolve => setTimeout(resolve, 300)); - expect(bag.has('boop')).toBe(false); - expect(bag.has('boop2')).toBe(true); + expect(store.has('boop')).toBe(false); + expect(store.has('boop2')).toBe(true); + + clearTimeout(store.emptyTimer!); }); }); }); test('finding a key/value', () => { - const bag = new Store(); - bag.set('boop', 1); - bag.set('boop2', 2); + const store = new Store(); + store.set('boop', 1); + store.set('boop2', 2); - expect(bag.findKey(v => v === 2)).toBe('boop2'); - expect(bag.find((_, key) => key === 'boop2')).toBe(2); + expect(store.findKey(v => v === 2)).toBe('boop2'); + expect(store.find((_, key) => key === 'boop2')).toBe(2); }); -test('filtering a bag', () => { - const bag = new Store(); - bag.set('boop', 1); - bag.set('boop2', 2); +test('filtering a store', () => { + const store = new Store(); + store.set('boop', 1); + store.set('boop2', 2); - expect(bag.filter((_, key) => key === 'boop2')).toStrictEqual(new Store({ entries: [['boop2', 2]] })); + expect(store.filter((_, key) => key === 'boop2')).toStrictEqual(new Store({ entries: [['boop2', 2]] })); }); -test('sorting a bag', () => { - const bag = new Store(); - bag.set('boop', 1); - bag.set('boop2', 2); +test('sorting a store', () => { + const store = new Store(); + store.set('boop', 1); + store.set('boop2', 2); - expect(bag.sort((a, b) => a - b)).toStrictEqual(new Store({ entries: [['boop2', 2], ['boop', 1]] })); + expect(store.sort((a, b) => a - b)).toStrictEqual(new Store({ entries: [['boop2', 2], ['boop', 1]] })); - const otherBag = new Store({ entries: [['boop', 1], ['boop2', 2]] }); - expect(bag).toStrictEqual(otherBag); - expect(bag.sort()).toStrictEqual(otherBag); + const otherstore = new Store({ entries: [['boop', 1], ['boop2', 2]] }); + expect(store).toStrictEqual(otherstore); + expect(store.sort()).toStrictEqual(otherstore); }); test('mutable sort', () => { - const bag = new Store(); - bag.set('boop2', 2); - bag.set('boop', 1); + const store = new Store(); + store.set('boop2', 2); + store.set('boop', 1); - const otherBag = new Store({ entries: [['boop', 1], ['boop2', 2]] }); - expect(bag.mSort()).toStrictEqual(otherBag); - expect(bag).toStrictEqual(otherBag); + const otherstore = new Store({ entries: [['boop', 1], ['boop2', 2]] }); + expect(store.mSort()).toStrictEqual(otherstore); + expect(store).toStrictEqual(otherstore); }); -test('mapping a bag', () => { - const bag = new Store(); - bag.set('boop', 1); - bag.set('boop2', 2); +test('mapping a store', () => { + const store = new Store(); + store.set('boop', 1); + store.set('boop2', 2); - expect(bag.map(v => v + 1)).toStrictEqual([2, 3]); + expect(store.map(v => v + 1)).toStrictEqual([2, 3]); }); -test('emptying a bag', () => { - const bag = new Store(); - bag.set('boop', 1); - bag.set('boop2', 2); +test('emptying a store', () => { + const store = new Store(); + store.set('boop', 1); + store.set('boop2', 2); - bag.empty(); + store.empty(); - expect(bag.size).toBe(0); + expect(store.size).toBe(0); }); -describe('reducing a bag', () => { +describe('reducing a store', () => { test('simple addition reducer', () => { - const bag = new Store(); - bag.set('boop', 1); - bag.set('boop2', 2); + const store = new Store(); + store.set('boop', 1); + store.set('boop2', 2); - expect(bag.reduce((acc, v) => acc + v)).toBe(3); + expect(store.reduce((acc, v) => acc + v)).toBe(3); }); test('simple addition reducer with initial value', () => { - const bag = new Store(); - bag.set('boop', 1); - bag.set('boop2', 2); + const store = new Store(); + store.set('boop', 1); + store.set('boop2', 2); - expect(bag.reduce((acc, v) => acc + v, 1)).toBe(4); + expect(store.reduce((acc, v) => acc + v, 1)).toBe(4); }); - test('reduce empty bag with no initial value', () => { + test('reduce empty store with no initial value', () => { expect( () => new Store().reduce((acc, v) => acc + v) ).toThrow(new CordisStoreTypeError('noReduceEmptyStore'));