Skip to content

Commit e310368

Browse files
committed
Added test for bind and apply
1 parent 3237c20 commit e310368

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

test/unit/functions.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,26 @@ export class FunctionTests {
231231
Expect(result).toBe(3 * returnValue);
232232
}
233233

234+
@Test("Function bind")
235+
public functionBind(): void {
236+
const source = `const abc = function (a: string) { console.log(this.a + a); }
237+
abc.bind({ a: 4 })("b");`;
238+
239+
const result = util.transpileAndExecute(source);
240+
241+
Expect(result).toBe("4b");
242+
}
243+
244+
@Test("Function apply")
245+
public functionApply(): void {
246+
const source = `const abc = function (a: string) { console.log(this.a + a); }
247+
abc.apply({ a: 4 }, ["b"]);`;
248+
249+
const result = util.transpileAndExecute(source);
250+
251+
Expect(result).toBe("4b");
252+
}
253+
234254
@Test("Invalid property access call transpilation")
235255
public invalidPropertyCall(): void {
236256
const transpiler = util.makeTestTranspiler();

0 commit comments

Comments
 (0)