Skip to content

Commit

Permalink
Add util tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cookpete committed Sep 9, 2017
1 parent 75710e4 commit 586f179
Showing 1 changed file with 43 additions and 3 deletions.
46 changes: 43 additions & 3 deletions test/karma/parseStartTime.js → test/karma/utils.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { parseStartTime } from '../../src/utils'
import { parseStartTime, randomString, omit } from '../../src/utils'

const { describe, it, expect } = window

const YOUTUBE_URL = 'http://youtu.be/12345678901'

describe('parseStartTime', () => {
const YOUTUBE_URL = 'http://youtu.be/12345678901'

it('parses seconds', () => {
expect(parseStartTime(YOUTUBE_URL + '?start=162')).to.equal(162)
})
Expand Down Expand Up @@ -42,3 +42,43 @@ describe('parseStartTime', () => {
expect(parseStartTime(YOUTUBE_URL + '#s=32')).to.equal(0)
})
})

describe('randomString', () => {
it('returns a 5 character string', () => {
expect(randomString()).to.be.a('string')
expect(randomString()).to.have.lengthOf(5)
})

it('returns different strings', () => {
const a = randomString()
const b = randomString()
const c = randomString()
expect(a).to.not.equal(b)
expect(a).to.not.equal(c)
expect(b).to.not.equal(c)
})
})

describe('omit', () => {
const object = {
a: 1,
b: 2,
c: 3,
d: 4,
e: 5
}

it('omits properties from an object', () => {
expect(omit(object, ['a', 'b', 'c'])).to.deep.equal({
d: 4,
e: 5
})
})

it('handles multiple array parameters', () => {
expect(omit(object, ['a'], ['b'], ['c'])).to.deep.equal({
d: 4,
e: 5
})
})
})

0 comments on commit 586f179

Please sign in to comment.