Skip to content

Commit

Permalink
Add getConfig tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cookpete committed Sep 11, 2017
1 parent d368ae2 commit f7eb2b5
Showing 1 changed file with 62 additions and 1 deletion.
63 changes: 62 additions & 1 deletion test/karma/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { parseStartTime, randomString, omit } from '../../src/utils'
import { parseStartTime, randomString, omit, getConfig } from '../../src/utils'

const { describe, it, expect } = window

Expand Down Expand Up @@ -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
}
})
})
})

0 comments on commit f7eb2b5

Please sign in to comment.