From 3fd6c16ab668fbbeb947fa2243ad3d2ad87975a3 Mon Sep 17 00:00:00 2001 From: omsuneri <142336291+omsuneri@users.noreply.github.com> Date: Sun, 22 Dec 2024 11:17:50 +0530 Subject: [PATCH 1/3] Create platformstyle.test.js --- js/utils/__tests__/platformstyle.test.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 js/utils/__tests__/platformstyle.test.js diff --git a/js/utils/__tests__/platformstyle.test.js b/js/utils/__tests__/platformstyle.test.js new file mode 100644 index 0000000000..9893cd9309 --- /dev/null +++ b/js/utils/__tests__/platformstyle.test.js @@ -0,0 +1,19 @@ +describe('Platform Style Tests', () => { + beforeEach(() => { + const meta = document.createElement('meta'); + meta.name = 'theme-color'; + document.head.appendChild(meta); + }); + + afterEach(() => { + document.head.innerHTML = ''; + }); + + test('should set the meta theme-color content based on platformColor', () => { + const platformColor = { header: '#ff0000' }; + document.querySelector("meta[name=theme-color]").content = platformColor.header; + + const meta = document.querySelector("meta[name=theme-color]"); + expect(meta.content).toBe('#ff0000'); + }); +}); From 8fed77350a07088d74a01a9269a3226fe9f90dfc Mon Sep 17 00:00:00 2001 From: omsuneri <142336291+omsuneri@users.noreply.github.com> Date: Sun, 22 Dec 2024 11:18:31 +0530 Subject: [PATCH 2/3] Update jest.config.js --- jest.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/jest.config.js b/jest.config.js index 03041592e6..bbc1122763 100644 --- a/jest.config.js +++ b/jest.config.js @@ -2,4 +2,5 @@ module.exports = { testMatch: ['**/__tests__/**/*.test.js', '**/?(*.)+(spec|test).[jt]s?(x)'], clearMocks: true, moduleFileExtensions: ['js', 'json', 'node'], + testEnvironment: 'jsdom', }; From 5dd9c7204b6c8e89dc85c2f719743bd7d454bd2a Mon Sep 17 00:00:00 2001 From: omsuneri <142336291+omsuneri@users.noreply.github.com> Date: Sun, 22 Dec 2024 11:20:25 +0530 Subject: [PATCH 3/3] Update musicutils.test.js resolving conflicts with the platformstyle.test.js --- js/utils/__tests__/musicutils.test.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/js/utils/__tests__/musicutils.test.js b/js/utils/__tests__/musicutils.test.js index 38de4093f0..7dc7a41cfb 100644 --- a/js/utils/__tests__/musicutils.test.js +++ b/js/utils/__tests__/musicutils.test.js @@ -1,3 +1,5 @@ +const { TextEncoder } = require('util'); +global.TextEncoder = TextEncoder; global._ = jest.fn((str) => str); global.window = { btoa: jest.fn((str) => Buffer.from(str, "utf8").toString("base64")) @@ -2007,4 +2009,4 @@ describe("getSolfege", () => { }); // TODO: Implement `pitchinfo` and `_calculate_pitch_number` methods. -// These are pending as they are related with the Activity class and DOM. \ No newline at end of file +// These are pending as they are related with the Activity class and DOM.