Add spec for electron module require

This commit is contained in:
Kevin Sawicki 2016-05-23 11:19:33 -07:00
parent 19fd841c30
commit fe0ec67623
4 changed files with 48 additions and 1 deletions

View file

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script>
require('electron').ipcRenderer.send('answer')
</script>
</head>
<body>
</body>
</html>

View file

View file

@ -0,0 +1,4 @@
{
"name": "electron",
"main": "index.js"
}

View file

@ -3,7 +3,8 @@ const child_process = require('child_process')
const fs = require('fs')
const path = require('path')
const os = require('os')
const remote = require('electron').remote
const {remote} = require('electron')
const {BrowserWindow, ipcMain} = remote
describe('node feature', function () {
var fixtures = path.join(__dirname, 'fixtures')
@ -228,4 +229,33 @@ describe('node feature', function () {
require('vm').runInNewContext('')
})
})
describe.only('require("electron")', function () {
let window = null
beforeEach(function () {
if (window != null) {
window.destroy()
}
window = new BrowserWindow({
show: false,
width: 400,
height: 400
})
})
afterEach(function () {
if (window != null) {
window.destroy()
}
window = null
})
it('always returns the internal electron module', function (done) {
ipcMain.once('answer', function () {
done()
})
window.loadURL('file://' + path.join(__dirname, 'fixtures', 'api', 'electron-module-app', 'index.html'))
})
})
})