Skip to content

Commit

Permalink
feat(date): add support for Date type (#310)
Browse files Browse the repository at this point in the history
* enhancement(transformer): Mock Date similar to that of Set and Map

* chore(transformer): Update TypeScript lib type test for Date
  • Loading branch information
martinjlowm authored May 8, 2020
1 parent 9965667 commit 7480aad
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/transformer/descriptor/tsLibs/typecriptLibs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export function GetTypescriptTypeDescriptor(node: ts.TypeReferenceNode, scope: S
[],
[dataResolved],
);
case(TypescriptLibsTypes.Date):
return ts.createNew(ts.createIdentifier('Date'), undefined, undefined);
case(TypescriptLibsTypes.Map):
return ts.createNew(ts.createIdentifier('Map'), undefined, undefined);
case(TypescriptLibsTypes.Set):
Expand Down
13 changes: 7 additions & 6 deletions src/transformer/descriptor/tsLibs/typescriptLibsTypes.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
export enum TypescriptLibsTypes {
Array = 'Array',
ReadonlyArray = 'ReadonlyArray',
Number = 'Number',
String = 'String',
Boolean = 'Boolean',
Object = 'Object',
Date = 'Date',
Function = 'Function',
Promise = 'Promise',
Map = 'Map',
Set = 'Set'
Number = 'Number',
Object = 'Object',
Promise = 'Promise',
ReadonlyArray = 'ReadonlyArray',
Set = 'Set',
String = 'String',
}

export const TypescriptLibsTypesFolder: string = 'node_modules/typescript/lib';
4 changes: 2 additions & 2 deletions test/transformer/descriptor/tsLibs/tsLibs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ describe('typescript lib', () => {
expect(properties.a).toEqual([]);
});

it('should set undefined for a Date', () => {
it('should create a new Date for a Date', () => {
interface Interface {
a: Date;
}

const properties: Interface = createMock<Interface>();
expect(properties.a).toBeUndefined();
expect(properties.a).toBeInstanceOf(Date);
});

it('should set a promise resolved for a promise', async () => {
Expand Down

0 comments on commit 7480aad

Please sign in to comment.