/
try_invoke_test.js
60 lines (52 loc) · 1.57 KB
/
try_invoke_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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { tryInvoke } from '..';
import { moduleFor, AbstractTestCase as TestCase } from 'internal-test-helpers';
let obj;
moduleFor(
'Ember.tryInvoke',
class extends TestCase {
constructor() {
super();
obj = {
aMethodThatExists() {
return true;
},
aMethodThatTakesArguments(arg1, arg2) {
return arg1 === arg2;
},
};
}
teardown() {
obj = undefined;
}
["@test should return undefined when the object doesn't exist"](assert) {
expectDeprecation(
() => assert.equal(tryInvoke(undefined, 'aMethodThatDoesNotExist'), undefined),
/Use of tryInvoke is deprecated/
);
}
["@test should return undefined when asked to perform a method that doesn't exist on the object"](
assert
) {
expectDeprecation(
() => assert.equal(tryInvoke(obj, 'aMethodThatDoesNotExist'), undefined),
/Use of tryInvoke is deprecated/
);
}
['@test should return what the method returns when asked to perform a method that exists on the object'](
assert
) {
expectDeprecation(
() => assert.equal(tryInvoke(obj, 'aMethodThatExists'), true),
/Use of tryInvoke is deprecated/
);
}
['@test should return what the method returns when asked to perform a method that takes arguments and exists on the object'](
assert
) {
expectDeprecation(
() => assert.equal(tryInvoke(obj, 'aMethodThatTakesArguments', [true, true]), true),
/Use of tryInvoke is deprecated/
);
}
}
);