Add test for require to search under app dir

This commit is contained in:
Ryohei Ikegami 2017-04-03 19:46:24 +09:00
parent a686237d9b
commit 673f4f4d0c

View file

@ -2,6 +2,8 @@ const assert = require('assert')
const Module = require('module')
const path = require('path')
const temp = require('temp')
const {remote} = require('electron')
const {BrowserWindow} = remote
describe('third-party module', function () {
var fixtures = path.join(__dirname, 'fixtures')
@ -129,3 +131,17 @@ describe('Module._nodeModulePaths', function () {
})
})
})
describe('require', () => {
describe('when loaded URL is not file: protocol', () => {
it('searches for module under app directory', async () => {
const w = new BrowserWindow({
show: false,
})
w.loadURL('about:blank')
const result = await w.webContents.executeJavaScript('typeof require("q").when')
assert.equal(result, 'function')
w.destroy()
})
})
})