From f7eb2b55929842523377bda20d80b62eb6c9a7d1 Mon Sep 17 00:00:00 2001 From: Pete Cook Date: Mon, 11 Sep 2017 12:49:12 +0100 Subject: [PATCH] Add getConfig tests --- test/karma/utils.js | 63 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/test/karma/utils.js b/test/karma/utils.js index 7f712d84..75a60a90 100644 --- a/test/karma/utils.js +++ b/test/karma/utils.js @@ -1,4 +1,4 @@ -import { parseStartTime, randomString, omit } from '../../src/utils' +import { parseStartTime, randomString, omit, getConfig } from '../../src/utils' const { describe, it, expect } = window @@ -82,3 +82,64 @@ describe('omit', () => { }) }) }) + +describe.only('getConfig', () => { + it('merges configs', () => { + const defaultProps = { + config: { + youtube: { + playerVars: { + autoplay: 0, + playsinline: 1 + }, + preload: false + } + } + } + const props = { + config: { + youtube: { + playerVars: { + playsinline: 0, + showinfo: 1 + }, + preload: true + } + } + } + const config = getConfig(props, defaultProps) + expect(config).to.deep.equal({ + youtube: { + playerVars: { + autoplay: 0, + playsinline: 0, + showinfo: 1 + }, + preload: true + } + }) + }) + + it('converts old style config', () => { + const props = { + config: {}, + youtubeConfig: { + playerVars: { + playsinline: 0, + showinfo: 1 + }, + preload: true + } + } + const config = getConfig(props, { config: {} }) + expect(config).to.deep.equal({ + youtube: { + playerVars: { + playsinline: 0, + showinfo: 1 + }, + preload: true + } + }) + }) +})