Skip to content

Commit 832a524

Browse files
committed
test: add types cheking test for 20-interface-using
1 parent 018898c commit 832a524

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

modules/35-interfaces/20-interface-using/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ const superMan: ISuperman = {
2424
};
2525
// END
2626

27-
export default superMan;
27+
export { superMan, ISuperman, IBird, IPlane };
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1-
import { expect, test } from 'vitest'
2-
import superMan from './index';
1+
import { expect, test, expectTypeOf } from 'vitest'
2+
import { superMan, ISuperman, IBird, IPlane } from './index';
33

44
test('guess who', () => {
55
expect(superMan.guessWho('bird')).toBe("It's a bird?");
66
expect(superMan.guessWho('plane')).toBe("It's a plane?");
77
expect(superMan.guessWho('SupErMan')).toBe("It's a SupErMan!");
88
});
9+
10+
test('Types check', () => {
11+
expectTypeOf<ISuperman>().toMatchTypeOf<IBird>();
12+
expectTypeOf<ISuperman>().toMatchTypeOf<IPlane>();
13+
expectTypeOf(superMan).toMatchTypeOf<ISuperman>();
14+
15+
expect(superMan).toHaveProperty('canFly');
16+
expect(superMan).toHaveProperty('isLiving');
17+
expect(superMan).toHaveProperty('canCarryPeople');
18+
});

0 commit comments

Comments
 (0)