spec: TypeArray should work in remote

This commit is contained in:
Cheng Zhao 2016-07-25 16:30:40 +09:00
Родитель 200d09cc70
Коммит eb51e080e5
2 изменённых файлов: 18 добавлений и 5 удалений

Просмотреть файл

@ -142,20 +142,25 @@ describe('ipc module', function () {
})
describe('remote value in browser', function () {
var print = path.join(fixtures, 'module', 'print_name.js')
const print = path.join(fixtures, 'module', 'print_name.js')
const printName = remote.require(print)
it('keeps its constructor name for objects', function () {
var buf = new Buffer('test')
var printName = remote.require(print)
const buf = new Buffer('test')
assert.equal(printName.print(buf), 'Buffer')
})
it('supports instanceof Date', function () {
var now = new Date()
var printName = remote.require(print)
const now = new Date()
assert.equal(printName.print(now), 'Date')
assert.deepEqual(printName.echo(now), now)
})
it('supports TypedArray', function () {
const values = [1, 2, 3, 4]
const typedArray = printName.typedArray(values)
assert.equal(values.toString(), typedArray.toString())
})
})
describe('remote promise', function () {

8
spec/fixtures/module/print_name.js поставляемый
Просмотреть файл

@ -5,3 +5,11 @@ exports.print = function (obj) {
exports.echo = function (obj) {
return obj
}
exports.typedArray = function (name) {
const int16 = new Int16Array(name.length)
for (let i = 0; i < name.length; ++i) {
int16[i] = name[i]
}
return int16
}