Skip to content

Commit

Permalink
Update spec
Browse files Browse the repository at this point in the history
  • Loading branch information
nitsakh committed Oct 14, 2018
1 parent 20df488 commit c46860a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
14 changes: 11 additions & 3 deletions spec/api-web-frame-spec.js
Expand Up @@ -152,13 +152,21 @@ describe('webFrame module', function () {
w.focus()
await w.webContents.executeJavaScript('document.querySelector("input").focus()', true)

const spellCheckerFeedback = emittedOnce(ipcMain, 'spec-spell-check')
const spellCheckerFeedback =
new Promise((resolve, reject) => {
ipcMain.on('spec-spell-check', (e, words, callback) => {
if (words.length === 2) {
// The promise is resolved only after this event is received twice
// Array contains only 1 word first time and 2 the next time
resolve([words, callback])
}
})
})
const inputText = 'spleling test '
for (const keyCode of inputText) {
w.webContents.sendInputEvent({ type: 'char', keyCode })
}
const [, words, callback] = await spellCheckerFeedback

const [words, callback] = await spellCheckerFeedback
expect(words).to.deep.equal(['spleling', 'test'])
expect(callback).to.be.true()
})
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/pages/webframe-spell-check.html
Expand Up @@ -4,6 +4,7 @@
const {ipcRenderer, webFrame} = require('electron')
webFrame.setSpellCheckProvider('en-US', {
spellCheck: (words, callback) => {
callback(words)
ipcRenderer.send('spec-spell-check', words, callback != undefined)
}
})
Expand Down

0 comments on commit c46860a

Please sign in to comment.