parent
04cce89fdc
commit
e4214a6cbe
11 changed files with 1712 additions and 1945 deletions
|
@ -7,45 +7,45 @@ const {closeWindow} = require('./window-helpers')
|
|||
|
||||
const nativeModulesEnabled = remote.getGlobal('nativeModulesEnabled')
|
||||
|
||||
describe('modules support', function () {
|
||||
var fixtures = path.join(__dirname, 'fixtures')
|
||||
describe('modules support', () => {
|
||||
const fixtures = path.join(__dirname, 'fixtures')
|
||||
|
||||
describe('third-party module', function () {
|
||||
describe('runas', function () {
|
||||
describe('third-party module', () => {
|
||||
describe('runas', () => {
|
||||
if (!nativeModulesEnabled) return
|
||||
|
||||
it('can be required in renderer', function () {
|
||||
it('can be required in renderer', () => {
|
||||
require('runas')
|
||||
})
|
||||
|
||||
it('can be required in node binary', function (done) {
|
||||
var runas = path.join(fixtures, 'module', 'runas.js')
|
||||
var child = require('child_process').fork(runas)
|
||||
child.on('message', function (msg) {
|
||||
it('can be required in node binary', (done) => {
|
||||
const runas = path.join(fixtures, 'module', 'runas.js')
|
||||
const child = require('child_process').fork(runas)
|
||||
child.on('message', (msg) => {
|
||||
assert.equal(msg, 'ok')
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('ffi', function () {
|
||||
describe('ffi', () => {
|
||||
if (!nativeModulesEnabled) return
|
||||
if (process.platform === 'win32') return
|
||||
|
||||
it('does not crash', function () {
|
||||
var ffi = require('ffi')
|
||||
var libm = ffi.Library('libm', {
|
||||
it('does not crash', () => {
|
||||
const ffi = require('ffi')
|
||||
const libm = ffi.Library('libm', {
|
||||
ceil: ['double', ['double']]
|
||||
})
|
||||
assert.equal(libm.ceil(1.5), 2)
|
||||
})
|
||||
})
|
||||
|
||||
describe('q', function () {
|
||||
var Q = require('q')
|
||||
describe('Q.when', function () {
|
||||
it('emits the fullfil callback', function (done) {
|
||||
Q(true).then(function (val) {
|
||||
describe('q', () => {
|
||||
const Q = require('q')
|
||||
describe('Q.when', () => {
|
||||
it('emits the fullfil callback', (done) => {
|
||||
Q(true).then((val) => {
|
||||
assert.equal(val, true)
|
||||
done()
|
||||
})
|
||||
|
@ -53,9 +53,9 @@ describe('modules support', function () {
|
|||
})
|
||||
})
|
||||
|
||||
describe('coffee-script', function () {
|
||||
it('can be registered and used to require .coffee files', function () {
|
||||
assert.doesNotThrow(function () {
|
||||
describe('coffee-script', () => {
|
||||
it('can be registered and used to require .coffee files', () => {
|
||||
assert.doesNotThrow(() => {
|
||||
require('coffee-script').register()
|
||||
})
|
||||
assert.strictEqual(require('./fixtures/module/test.coffee'), true)
|
||||
|
@ -63,36 +63,36 @@ describe('modules support', function () {
|
|||
})
|
||||
})
|
||||
|
||||
describe('global variables', function () {
|
||||
describe('process', function () {
|
||||
it('can be declared in a module', function () {
|
||||
describe('global variables', () => {
|
||||
describe('process', () => {
|
||||
it('can be declared in a module', () => {
|
||||
assert.strictEqual(require('./fixtures/module/declare-process'), 'declared process')
|
||||
})
|
||||
})
|
||||
|
||||
describe('global', function () {
|
||||
it('can be declared in a module', function () {
|
||||
describe('global', () => {
|
||||
it('can be declared in a module', () => {
|
||||
assert.strictEqual(require('./fixtures/module/declare-global'), 'declared global')
|
||||
})
|
||||
})
|
||||
|
||||
describe('Buffer', function () {
|
||||
it('can be declared in a module', function () {
|
||||
describe('Buffer', () => {
|
||||
it('can be declared in a module', () => {
|
||||
assert.strictEqual(require('./fixtures/module/declare-buffer'), 'declared Buffer')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('Module._nodeModulePaths', function () {
|
||||
describe('when the path is inside the resources path', function () {
|
||||
it('does not include paths outside of the resources path', function () {
|
||||
describe('Module._nodeModulePaths', () => {
|
||||
describe('when the path is inside the resources path', () => {
|
||||
it('does not include paths outside of the resources path', () => {
|
||||
let modulePath = process.resourcesPath
|
||||
assert.deepEqual(Module._nodeModulePaths(modulePath), [
|
||||
path.join(process.resourcesPath, 'node_modules')
|
||||
])
|
||||
|
||||
modulePath = process.resourcesPath + '-foo'
|
||||
let nodeModulePaths = Module._nodeModulePaths(modulePath)
|
||||
const nodeModulePaths = Module._nodeModulePaths(modulePath)
|
||||
assert(nodeModulePaths.includes(path.join(modulePath, 'node_modules')))
|
||||
assert(nodeModulePaths.includes(path.join(modulePath, '..', 'node_modules')))
|
||||
|
||||
|
@ -124,8 +124,8 @@ describe('modules support', function () {
|
|||
})
|
||||
})
|
||||
|
||||
describe('when the path is outside the resources path', function () {
|
||||
it('includes paths outside of the resources path', function () {
|
||||
describe('when the path is outside the resources path', () => {
|
||||
it('includes paths outside of the resources path', () => {
|
||||
let modulePath = path.resolve('/foo')
|
||||
assert.deepEqual(Module._nodeModulePaths(modulePath), [
|
||||
path.join(modulePath, 'node_modules'),
|
||||
|
@ -140,9 +140,7 @@ describe('modules support', function () {
|
|||
let w
|
||||
|
||||
beforeEach(() => {
|
||||
w = new BrowserWindow({
|
||||
show: false
|
||||
})
|
||||
w = new BrowserWindow({show: false})
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue