You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
987 B
32 lines
987 B
'use strict';
|
|
var getArgs = require('../');
|
|
var test = require('tape');
|
|
test('scope should be the same', function (t) {
|
|
t.test('with call', function (t) {
|
|
var foo = {};
|
|
var ourFunc = getArgs(function (args) {
|
|
t.deepEquals(args, [1, 2, 3, 4], 'args should be right');
|
|
t.strictEquals(this, foo, 'scope should be the same');
|
|
t.end();
|
|
});
|
|
ourFunc.call(foo, 1, 2, 3, 4);
|
|
});
|
|
test('with apply', function (t) {
|
|
var foo = {};
|
|
var ourFunc = getArgs(function (args) {
|
|
t.deepEquals(args, [1, 2, 3, 4], 'args should be right');
|
|
t.strictEquals(this, foo, 'scope should be the same');
|
|
t.end();
|
|
});
|
|
ourFunc.apply(foo, [1, 2, 3, 4]);
|
|
});
|
|
test('with bind', function (t) {
|
|
var foo = {};
|
|
var ourFunc = getArgs(function (args) {
|
|
t.deepEquals(args, [1, 2, 3, 4], 'args should be right');
|
|
t.strictEquals(this, foo, 'scope should be the same');
|
|
t.end();
|
|
}).bind(foo, 1);
|
|
ourFunc(2, 3, 4);
|
|
});
|
|
}); |