Skip to content

Commit 6c9009f

Browse files
committed
Merge typing test file
1 parent 5ad6b7d commit 6c9009f

File tree

2 files changed

+24
-77
lines changed

2 files changed

+24
-77
lines changed

regression/typescript/test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,26 @@ class Dog {
88
bark() {}
99
}
1010

11+
class Cat {
12+
constructor() {};
13+
meow(): string { return "meow! meow!" }
14+
}
15+
16+
function sum (first: number, second: number): number {
17+
return first + second
18+
}
19+
20+
1121
const dog = td.constructor(Dog);
1222
td.when(dog.prototype.bark()).thenReturn("woof!");
1323

1424
const bird = td.object({ fly: function(){} });
1525
td.when(bird.fly()).thenReturn("swoosh!");
1626

27+
const kitty = td.object(["scratch","meow"]);
28+
td.when(kitty.scratch()).thenReturn("scratch!");
29+
td.when(kitty.meow()).thenReturn("meow!");
30+
1731
if (eval("typeof Proxy") !== "undefined") {
1832
class Bear { constructor() {}; sleep() {}; };
1933
const bear = td.object<Bear>("A bear");
@@ -36,12 +50,22 @@ td.when(f(td.matchers.isA(String))).thenDo(function(s: string) { return s; });
3650
td.when(f(td.matchers.not(true))).thenResolve("value1", "value2");
3751
td.when(f(td.matchers.not(false))).thenReject(new Error("rejected"));
3852

53+
const fakeSum = td.function(sum);
54+
td.when(fakeSum(1, 2)).thenReturn(3);
55+
56+
const fakestSum = td.function("sum");
57+
td.when(fakestSum(1, 2)).thenReturn(3);
58+
3959
f()
4060
td.verify(f());
4161
td.verify(f(), { times: 1 });
4262
td.verify(f(), { ignoreExtraArgs: false });
4363
td.verify(f(), { ignoreExtraArgs: true, times: 1 });
4464

65+
const CatFake = td.constructor(Cat);
66+
const cat = new CatFake()
67+
td.when(cat.meow()).thenReturn("moo!");
68+
4569
const explanation = td.explain(f);
4670

4771
console.log(

test/src/typescript/test.ts

Lines changed: 0 additions & 77 deletions
This file was deleted.

0 commit comments

Comments
 (0)