Skip to content

Commit fe0ec67

Browse files
committed
Add spec for electron module require
1 parent 19fd841 commit fe0ec67

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title></title>
6+
<script>
7+
require('electron').ipcRenderer.send('answer')
8+
</script>
9+
</head>
10+
<body>
11+
12+
</body>
13+
</html>

spec/fixtures/api/electron-module-app/node_modules/electron/index.js

Whitespace-only changes.

spec/fixtures/api/electron-module-app/node_modules/electron/package.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/node-spec.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ const child_process = require('child_process')
33
const fs = require('fs')
44
const path = require('path')
55
const os = require('os')
6-
const remote = require('electron').remote
6+
const {remote} = require('electron')
7+
const {BrowserWindow, ipcMain} = remote
78

89
describe('node feature', function () {
910
var fixtures = path.join(__dirname, 'fixtures')
@@ -228,4 +229,33 @@ describe('node feature', function () {
228229
require('vm').runInNewContext('')
229230
})
230231
})
232+
233+
describe.only('require("electron")', function () {
234+
let window = null
235+
236+
beforeEach(function () {
237+
if (window != null) {
238+
window.destroy()
239+
}
240+
window = new BrowserWindow({
241+
show: false,
242+
width: 400,
243+
height: 400
244+
})
245+
})
246+
247+
afterEach(function () {
248+
if (window != null) {
249+
window.destroy()
250+
}
251+
window = null
252+
})
253+
254+
it('always returns the internal electron module', function (done) {
255+
ipcMain.once('answer', function () {
256+
done()
257+
})
258+
window.loadURL('file://' + path.join(__dirname, 'fixtures', 'api', 'electron-module-app', 'index.html'))
259+
})
260+
})
231261
})

0 commit comments

Comments
 (0)