-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest.js
43 lines (36 loc) · 992 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
var test = require('ava')
var osa = require('.')
var osacb = require('./cb')
test('script execution', async t => {
var fn = osa(name => 'Hello there, ' + name + '!')
t.is(await fn('nodejs'), 'Hello there, nodejs!')
})
test('system access', async t => {
var fn = osa(() => Application('System Events').currentUser.name())
t.is(await fn(), process.env.USER)
})
test('multiline', async t => {
var fn = osa(function() {
var foo = 'bar'
var baz = 'foo'
return baz + foo
})
t.is(await fn(), 'foobar')
})
test('correct return value', async t => {
var fn = osa(() => 123.47)
t.is(await fn(), 123.47)
})
test('undefined return', async t => {
var fn = osa(() => {})
t.is(await fn(), undefined)
})
test.cb('callback mode', t => {
t.plan(2)
var fn = osacb(name => 'Hello there, ' + name + '!')
fn('nodejs', (err, data) => {
t.is(err, null)
t.is(data, 'Hello there, nodejs!')
t.end()
})
})