From b45567450f28faaeb930845b03ff31e569331710 Mon Sep 17 00:00:00 2001 From: Dan Gowans Date: Mon, 30 Jan 2023 14:08:54 -0500 Subject: [PATCH] polyfill coverage testing --- test/functions.js | 13 ++++++++++++- test/functions.ts | 22 ++++++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/test/functions.js b/test/functions.js index 4e5d0bb1..c7caca90 100644 --- a/test/functions.js +++ b/test/functions.js @@ -5,9 +5,10 @@ import * as cacheFunctions from '../helpers/functions.cache.js'; import * as iconFunctions from '../helpers/functions.icons.js'; import * as sqlFilterFunctions from '../helpers/functions.sqlFilters.js'; import * as userFunctions from '../helpers/functions.user.js'; +import * as polyfills from '../helpers/polyfills.js'; describe('config.cemetery.ssm', () => { it('Sorts burial site names', () => { - const grave2 = 'XX-B1-G2'; + const grave2 = 'XX-B1-G2A'; const grave10 = 'XX-B1-G10'; assert.ok(lotNameSortNameFunction(grave2) < lotNameSortNameFunction(grave10)); }); @@ -334,3 +335,13 @@ describe('functions.user', () => { }); }); }); +describe('plyfills', () => { + it('applys Object.hasOwn polyfill', () => { + delete Object.hasOwn; + assert.ok(Object.hasOwn === undefined); + polyfills.applyPolyfills(); + assert.ok(Object.hasOwn !== undefined); + const testObject = { foo: 'bar' }; + assert.ok(Object.hasOwn(testObject, 'foo')); + }); +}); diff --git a/test/functions.ts b/test/functions.ts index a0dd2c95..76c8eb87 100644 --- a/test/functions.ts +++ b/test/functions.ts @@ -8,12 +8,16 @@ import * as iconFunctions from '../helpers/functions.icons.js' import * as sqlFilterFunctions from '../helpers/functions.sqlFilters.js' import * as userFunctions from '../helpers/functions.user.js' +import * as polyfills from '../helpers/polyfills.js' + describe('config.cemetery.ssm', () => { it('Sorts burial site names', () => { - const grave2 = 'XX-B1-G2' + const grave2 = 'XX-B1-G2A' const grave10 = 'XX-B1-G10' - assert.ok(lotNameSortNameFunction(grave2) < lotNameSortNameFunction(grave10)) + assert.ok( + lotNameSortNameFunction(grave2) < lotNameSortNameFunction(grave10) + ) }) }) @@ -511,3 +515,17 @@ describe('functions.user', () => { }) }) }) + +describe('plyfills', () => { + it('applys Object.hasOwn polyfill', () => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + delete (Object as any).hasOwn + assert.ok(Object.hasOwn === undefined) + + polyfills.applyPolyfills() + assert.ok(Object.hasOwn !== undefined) + + const testObject = { foo: 'bar' } + assert.ok(Object.hasOwn(testObject, 'foo')) + }) +})