Skip to content

Commit

Permalink
Update spec
Browse files Browse the repository at this point in the history
  • Loading branch information
nitsakh committed Oct 3, 2018
1 parent 7157dd2 commit 36927d8
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 @@ -150,13 +150,21 @@ describe('webFrame module', function () {
w.loadFile(path.join(fixtures, 'pages', 'webframe-spell-check.html'))
await emittedOnce(w.webContents, 'did-finish-load')

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 36927d8

Please sign in to comment.