From 64e0dff68434c0b2a72e7099c40ffbf5db67e06d Mon Sep 17 00:00:00 2001 From: Ezzudin Alkotob Date: Fri, 10 May 2024 14:56:07 -0700 Subject: [PATCH] improve test --- src/js/__tests__/contentUtils-test.js | 14 +++++++------- src/js/contentUtils.ts | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/js/__tests__/contentUtils-test.js b/src/js/__tests__/contentUtils-test.js index b3d44e1..9995851 100644 --- a/src/js/__tests__/contentUtils-test.js +++ b/src/js/__tests__/contentUtils-test.js @@ -31,7 +31,7 @@ describe('contentUtils', () => { const fakeScriptNode = { src: fakeUrl, getAttribute: () => { - return 'data-btmanifest'; + return '123_main'; }, }; storeFoundJS(fakeScriptNode); @@ -44,7 +44,7 @@ describe('contentUtils', () => { const fakeScriptNode = { src: fakeUrl, getAttribute: () => { - return 'data-btmanifest'; + return '123_main'; }, }; storeFoundJS(fakeScriptNode); @@ -68,7 +68,7 @@ describe('contentUtils', () => { it('should store any script elements we find', () => { const fakeElement = { getAttribute: () => { - return 'data-btmanifest'; + return '123_main'; }, childNodes: [], nodeName: 'SCRIPT', @@ -128,7 +128,7 @@ describe('contentUtils', () => { }, { getAttribute: () => { - return 'data-btmanifest'; + return '123_main'; }, nodeName: 'SCRIPT', nodeType: 1, @@ -169,13 +169,13 @@ describe('contentUtils', () => { nodeName: 'script', nodeType: 1, getAttribute: () => { - return 'data-btmanifest'; + return '123_main'; }, tagName: 'tagName', }, { getAttribute: () => { - return 'data-btmanifest'; + return '123_longtail'; }, nodeName: 'script', nodeType: 1, @@ -207,7 +207,7 @@ describe('contentUtils', () => { jest.resetModules(); document.body.innerHTML = '
' + - ' ' + + ' ' + '
'; scanForScripts(); expect(window.chrome.runtime.sendMessage.mock.calls.length).toBe(1); diff --git a/src/js/contentUtils.ts b/src/js/contentUtils.ts index 1297b10..25a056a 100644 --- a/src/js/contentUtils.ts +++ b/src/js/contentUtils.ts @@ -226,9 +226,9 @@ function handleScriptNode(scriptNode: HTMLScriptElement): void { // versions, so we can use the first manifest version as the script version. const version = manifest1.split('_')[0]; - if (!version) { + if (!version || !otherType) { invalidateAndThrow( - `Unable to parse a valid version from the data-btmanifest property of ${scriptNode.src}`, + `Missing manifest version or type from the data-btmanifest property of ${scriptNode.src}`, ); }