forked from canjs/canjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproxy_test.js
47 lines (47 loc) · 1012 Bytes
/
proxy_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
steal("can/construct/proxy", "can/control", function () {
/* global Car */
var isSteal = typeof steal !== 'undefined';
module('can/construct/proxy');
test('static proxy if control is loaded first', function () {
var curVal = 0;
expect(2);
can.Control('Car', {
show: function (value) {
equal(curVal, value);
}
}, {});
var cb = Car.proxy('show');
curVal = 1;
cb(1);
curVal = 2;
var cb2 = Car.proxy('show', 2);
cb2();
});
test('proxy', function () {
var curVal = 0;
expect(2);
can.Construct('Car', {
show: function (value) {
equal(curVal, value);
}
}, {});
var cb = Car.proxy('show');
curVal = 1;
cb(1);
curVal = 2;
var cb2 = Car.proxy('show', 2);
cb2();
});
// this won't work in dist mode (this functionality is removed)
if (isSteal) {
test('proxy error', 1, function () {
can.Construct('Car', {});
try {
Car.proxy('huh');
ok(false, 'I should have errored');
} catch (e) {
ok(true, 'Error was thrown');
}
});
}
});