Created
June 24, 2016 13:40
-
-
Save andrewjmead/5d21cc45d09a82501cb09e297afd494b to your computer and use it in GitHub Desktop.
For Murali
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var React = require('react'); | |
var ReactDOM = require('react-dom'); | |
var expect = require('expect'); | |
var $ = require('jQuery'); | |
var TestUtils = require('react-addons-test-utils'); | |
var Countdown = require('Countdown'); | |
describe('Countdown', () => { | |
it('should exist', () => { | |
expect(Countdown).toExist(); | |
}); | |
describe('handleSetCountDown', () => { | |
it('should set state to started and coutdown', (done) => { | |
var countdown = TestUtils.renderIntoDocument(<Countdown/>); | |
countdown.handleSetCountDown(10); | |
expect(countdown.state.count).toBe(10); | |
expect(countdown.state.countdownStatus).toBe('started'); | |
setTimeout(() => { | |
expect(countdown.state.count).toBe(9); | |
done(); | |
}, 1001) | |
}); | |
it('should never set count less than zero', (done) => { | |
var countdown = TestUtils.renderIntoDocument(<Countdown/>); | |
countdown.handleSetCountDown(1); | |
setTimeout(() => { | |
expect(countdown.state.count).toBe(0); | |
done(); | |
}, 3001) | |
}); | |
it('should pause countdown on paused status', (done) => { | |
var countdown = TestUtils.renderIntoDocument(<Countdown/>); | |
countdown.handleSetCountDown(3); | |
countdown.handleCountdownStatusChanged('pause'); | |
setTimeout(() => { | |
expect(countdown.state.count).toBe(3); | |
expect(countdown.state.countdownStatus).toBe('pause'); | |
done(); | |
}, 1001); | |
}); | |
it('should reset count on stopped', (done) => { | |
var countdown = TestUtils.renderIntoDocument(<Countdown/>); | |
countdown.handleSetCountDown(3); | |
countdown.handleCountdownStatusChanged('stopped'); | |
setTimeout(() => { | |
expect(countdown.state.count).toBe(0); | |
expect(countdown.state.countdownStatus).toBe('stopped'); | |
done(); | |
}, 1001); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment