Skip to content

Commit

Permalink
fix(client: return result of confirm and prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
voltrevo authored and dignifiedquire committed Mar 21, 2017
1 parent f5d99fb commit 01d6d4c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions context/karma.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ var ContextKarma = function (callParentKarmaMethod) {

contextWindow.confirm = function (msg) {
self.log('confirm', [msg])
_confirm(msg)
return _confirm(msg)
}

contextWindow.prompt = function (msg, defaultVal) {
self.log('prompt', [msg, defaultVal])
_prompt(msg, defaultVal)
return _prompt(msg, defaultVal)
}

// If we want to overload our console, then do it
Expand Down
8 changes: 6 additions & 2 deletions test/client/karma.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,15 @@ describe('Karma', function () {
var mockWindow = {
confirm: function () {
confirmCalled = true
return true
}
}

ck.setupContext(mockWindow)
mockWindow.confirm('What?')
var confirmResult = mockWindow.confirm('What?')
assert(ck.log.calledWith('confirm', ['What?']))
assert.equal(confirmCalled, true)
assert.equal(confirmResult, true)
})

it('should capture prompt', function () {
Expand All @@ -277,13 +279,15 @@ describe('Karma', function () {
var mockWindow = {
prompt: function () {
promptCalled = true
return 'user-input'
}
}

ck.setupContext(mockWindow)
mockWindow.prompt('What is your favorite color?', 'blue')
var promptResult = mockWindow.prompt('What is your favorite color?', 'blue')
assert(ck.log.calledWith('prompt', ['What is your favorite color?', 'blue']))
assert.equal(promptCalled, true)
assert.equal(promptResult, 'user-input')
})
})

Expand Down

0 comments on commit 01d6d4c

Please sign in to comment.