From 69c5a7bcd2b88118644cf3fd2e8735091f764004 Mon Sep 17 00:00:00 2001 From: Dani Pinyol Date: Wed, 16 Jun 2021 07:09:34 +0200 Subject: [PATCH] wip --- .github/workflows/botonic-plugin-contentful-tests.yml | 4 ++-- packages/botonic-plugin-contentful/src/util/objects.ts | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/botonic-plugin-contentful-tests.yml b/.github/workflows/botonic-plugin-contentful-tests.yml index 7acadd6ed9..8917d1a0e6 100644 --- a/.github/workflows/botonic-plugin-contentful-tests.yml +++ b/.github/workflows/botonic-plugin-contentful-tests.yml @@ -32,14 +32,14 @@ jobs: run: (cd ./packages/$PACKAGE && npm install -D) - name: Build run: (cd ./packages/$PACKAGE && npm run build_unit_tests) + - name: Verify lint + run: (cd ./packages/$PACKAGE && npm run lint_ci) - name: Run tests env: CONTENTFUL_TEST_SPACE_ID: ${{ secrets.CONTENTFUL_TEST_SPACE_ID }} CONTENTFUL_TEST_TOKEN: ${{ secrets.CONTENTFUL_TEST_TOKEN }} CONTENTFUL_TEST_MANAGE_TOKEN: ${{ secrets.CONTENTFUL_TEST_MANAGE_TOKEN }} run: (cd ./packages/$PACKAGE && npm run test) - - name: Verify lint - run: (cd ./packages/$PACKAGE && npm run lint_ci) - name: Upload coverage to codecov uses: codecov/codecov-action@v1 diff --git a/packages/botonic-plugin-contentful/src/util/objects.ts b/packages/botonic-plugin-contentful/src/util/objects.ts index 501c3ebb1b..7cb3af7faf 100644 --- a/packages/botonic-plugin-contentful/src/util/objects.ts +++ b/packages/botonic-plugin-contentful/src/util/objects.ts @@ -78,9 +78,11 @@ export function roughSizeOfObject(object: any): number { bytes = value.length * 2 } else if (typeof value === 'number') { bytes = 8 + } else if (value == null) { + //this branch is required because typeof null = 'object' + bytes = 0 } else if (typeof value === 'object' && objectList.indexOf(value) === -1) { objectList.push(value) - for (const [k, v] of Object.entries(value)) { bytes += 8 // an assumed existence overhead bytes += recurse(k)