Skip to content

Commit

Permalink
v1.0.1 Release
Browse files Browse the repository at this point in the history
Patch to fix issue #3
  • Loading branch information
tohjustin authored Jan 2, 2017
2 parents ebab198 + 712e8f2 commit 1a2665c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 35 deletions.
4 changes: 1 addition & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,7 @@ export default {
this._clearWorker()
this.state = STATE.SWITCH(this.state)
this.timeRemaining = (STATE.GET_MODE(this.state) === 'WORK') ? this.workDuration : this.breakDuration
if (this.allowMelody) {
this._ringAlarm()
}
this._ringAlarm()
},
switchToSettingsView: function () {
this.pauseTimer()
Expand Down
57 changes: 25 additions & 32 deletions test/unit/specs/App.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,41 +545,34 @@ describe('App', () => {

CLOCK.restore()
})
it('[triggerAlarm] rings the alarm if [allowMelody] is true', () => {
it('[triggerAlarm] executes [_ringAlarm] regardless of [allowMelody]/[allowVibration] settings', () => {
// Restore the stubbed function so we can mock it
// vm._ringAlarm.restore()
// vm._stopAlarm.restore()

// Setup mocks
var mock = sinon.mock(vm)
var ringAlarmExpectation = mock.expects('_ringAlarm')
var stopAlarmExpectation = mock.expects('_stopAlarm')
ringAlarmExpectation.once()
stopAlarmExpectation.never()

// Verify it
vm.allowMelody = true
vm.triggerAlarm()
ringAlarmExpectation.verify()
stopAlarmExpectation.verify()
})
it('[triggerAlarm] rings the alarm if [allowMelody] is false', () => {
// Restore the stubbed function so we can mock it
// vm._ringAlarm.restore()
// vm._stopAlarm.restore()

// Setup mocks
var mock = sinon.mock(vm)
var ringAlarmExpectation = mock.expects('_ringAlarm')
var stopAlarmExpectation = mock.expects('_stopAlarm')
ringAlarmExpectation.never()
stopAlarmExpectation.never()

// Verify it
vm.allowMelody = false
vm.triggerAlarm()
ringAlarmExpectation.verify()
stopAlarmExpectation.verify()
const settings = [
{ allowMelody: false, allowVibration: false },
{ allowMelody: true, allowVibration: true },
{ allowMelody: true, allowVibration: false },
{ allowMelody: true, allowVibration: true }
]

for (let i = 0; i < settings.length; i++) {
// Setup mocks
let mock = sinon.mock(vm)
let ringAlarmExpectation = mock.expects('_ringAlarm')
let stopAlarmExpectation = mock.expects('_stopAlarm')
ringAlarmExpectation.once()
stopAlarmExpectation.never()

// Verify it
vm.allowMelody = true
vm.allowMelody = settings[i].allowMelody
vm.allowVibration = settings[i].allowVibration
vm.triggerAlarm()
ringAlarmExpectation.verify()
stopAlarmExpectation.verify()
mock.restore()
}
})
it('[switchToSettingsView] pauses timer', () => {
let spy = sinon.spy(vm, 'pauseTimer')
Expand Down

0 comments on commit 1a2665c

Please sign in to comment.