From e7be13a4bf4a6f8798ade25b13d6a727713fd951 Mon Sep 17 00:00:00 2001 From: Cyril Coutelier Date: Mon, 27 Nov 2023 11:40:29 +0100 Subject: [PATCH 1/2] test: add test for `getEmbedConfig` --- test/integration/embed-integration.js | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/integration/embed-integration.js b/test/integration/embed-integration.js index ea7eef2..3912deb 100644 --- a/test/integration/embed-integration.js +++ b/test/integration/embed-integration.js @@ -1290,6 +1290,38 @@ describe('Integration - Embed', () => { }); }); + describe('getEmbedConfig', () => { + it('with layout and other config elements', async () => { + // Given + const container = document.createElement('div'); + document.body.appendChild(container); + const extraOpts = { + noHeader: true, + showTabRests: true, + layout: 'track', + hideTempo: true, + }; + + const embed = new Flat.Embed(container, { + baseUrl: BASE_URL, + score: QUARTET_SCORE, + embedParams: { + appId: APP_ID, + ...extraOpts, + }, + }); + + // When + const embedConfig = await embed.getEmbedConfig(); + + // Then + Object.entries(embedConfig).forEach(([key, expectedValue]) => { + const actualValue = embedConfig[key]; + assert.deepStrictEqual(actualValue, expectedValue); + }); + }); + }); + // describe('Editor config', () => { // it('should fetch the viewer config', (done) => { // var container = document.createElement('div'); From 2d10e81e8d2df92a3d432b49d9444048f65e912a Mon Sep 17 00:00:00 2001 From: Vincent Giersch Date: Wed, 3 Jan 2024 19:14:09 +0100 Subject: [PATCH 2/2] chore: remove unused tests --- karma.conf.js | 2 - test/integration/embed-integration.js | 57 +-------------------------- 2 files changed, 1 insertion(+), 58 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index 2240f7a..6a563c9 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,5 +1,3 @@ -var process = require('process'); - module.exports = function (config) { var configuration = { frameworks: ['mocha'], diff --git a/test/integration/embed-integration.js b/test/integration/embed-integration.js index 3912deb..bc06d73 100644 --- a/test/integration/embed-integration.js +++ b/test/integration/embed-integration.js @@ -1317,63 +1317,8 @@ describe('Integration - Embed', () => { // Then Object.entries(embedConfig).forEach(([key, expectedValue]) => { const actualValue = embedConfig[key]; - assert.deepStrictEqual(actualValue, expectedValue); + assert.deepEqual(actualValue, expectedValue); }); }); }); - - // describe('Editor config', () => { - // it('should fetch the viewer config', (done) => { - // var container = document.createElement('div'); - // document.body.appendChild(container); - - // var embed = new Flat.Embed(container, { - // score: PUBLIC_SCORE, - // baseUrl: BASE_URL, - // embedParams: { - // appId: APP_ID, - // controlsFloating: false, - // branding: false - // } - // }); - - // embed.getEmbedConfig().then((config) => { - // assert.equal(config.branding, false); - // assert.equal(config.controlsPlay, true); - // assert.equal(config.controlsFloating, false); - // container.parentNode.removeChild(container); - // done(); - // }); - // }); - - // it('should use the edit mode and set a tools config', (done) => { - // var container = document.createElement('div'); - // document.body.appendChild(container); - - // var embed = new Flat.Embed(container, { - // baseUrl: BASE_URL, - // embedParams: { - // appId: APP_ID, - // mode: 'edit', - // controlsFloating: false, - // branding: false - // } - // }); - - // embed.setEditorConfig({ - // noteMode: { - // durations: true, - // tuplet: false - // }, - // articulationMode: false - // }).then((config) => { - // assert.ok(config.global); - // assert.equal(config.articulationMode, false); - // assert.equal(config.noteMode.durations, true); - // assert.equal(config.noteMode.tuplet, false); - // container.parentNode.removeChild(container); - // done(); - // }).catch(done); - // }); - // }); });