2020-08-24 17:16:35 +09:00
|
|
|
import test from 'ava'
|
2020-07-03 01:36:45 +09:00
|
|
|
|
|
|
|
const bindings = require('../index.node')
|
|
|
|
|
2020-07-03 01:31:50 +09:00
|
|
|
test('should call the function', (t) => {
|
2020-08-24 17:16:35 +09:00
|
|
|
bindings.testCallFunction((arg1: string, arg2: string) => {
|
2020-07-03 01:31:50 +09:00
|
|
|
t.is(`${arg1} ${arg2}`, 'hello world')
|
2020-07-03 01:36:45 +09:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-07-03 01:31:50 +09:00
|
|
|
test('should set "this" properly', (t) => {
|
2020-07-03 01:36:45 +09:00
|
|
|
const obj = {}
|
2020-08-24 17:16:35 +09:00
|
|
|
bindings.testCallFunctionWithThis.call(obj, function (this: typeof obj) {
|
2020-07-03 01:31:50 +09:00
|
|
|
t.is(this, obj)
|
2020-07-03 01:36:45 +09:00
|
|
|
})
|
|
|
|
})
|