Skip to content

Instantly share code, notes, and snippets.

@togakangaroo
Created November 13, 2019 04:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save togakangaroo/f7c0c83d5d70ef094be84cd995b22c2e to your computer and use it in GitHub Desktop.
Save togakangaroo/f7c0c83d5d70ef094be84cd995b22c2e to your computer and use it in GitHub Desktop.
describe(`Stopwatch`, () => {
let clock
beforeEach(() => clock = useFakeTimers())
afterEach(() => clock.restore())
describe(`new instance`, () => {
let sw
beforeEach(() => sw = createStopWatch())
it(`shows nothing on main display`, () => expect(sw.displays.main).to.equal(null))
it(`shows no laps`, () => expect(sw.displays.laps).to.deep.equal([]))
describe(`1s elapses`, () => {
beforeEach(() => clock.tick(1000))
it(`shows nothing on main display`, () => expect(sw.displays.main).to.equal(null))
it(`shows no laps`, () => expect(sw.displays.laps).to.deep.equal([]))
})
describe(`started`, () => {
beforeEach(() => sw.toggle())
it(`shows 0s on main display`, () => expect(sw.displays.main).to.equal(0))
it(`shows no laps`, () => expect(sw.displays.laps).to.deep.equal([]))
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment