import { createMock } from 'ts-auto-mock' ; describe ( 'constructorType' , ( ) => { describe ( 'of an interface' , ( ) => { it ( 'should create a concrete newable type of the interface' , ( ) => { interface Test { a : string ; b : number ; } const mockConstructorType = createMock < new ( ) => Test > ( ) ; const mockInstance = new mockConstructorType ( ) ; expect ( mockInstance . a ) . toEqual ( '' ) ; expect ( mockInstance . b ) . toEqual ( 0 ) ; } ) ; it ( 'should not create a singleton newable type of the interface' , ( ) => { interface Test { a : string ; b : number ; } const mockConstructorType = createMock < new ( ) => Test > ( ) ; const mockInstance1 = new mockConstructorType ( ) ; const mockInstance2 = new mockConstructorType ( ) ; const mockInstance3 = new mockConstructorType ( ) ; mockInstance1 . a = 'test1' ; mockInstance2 . a = 'test2' ; mockInstance3 . a = 'test3' ; expect ( mockInstance1 . a ) . toEqual ( 'test1' ) ; expect ( mockInstance2 . a ) . toEqual ( 'test2' ) ; expect ( mockInstance3 . a ) . toEqual ( 'test3' ) ; } ) ; } ) ; describe ( 'of a class' , ( ) => { it ( 'should create a concrete newable type of the class' , ( ) => { class Test { public a : string ; public b : number ; } const mockConstructorType = createMock < new ( ) => Test > ( ) ; const mockInstance = new mockConstructorType ( ) ; expect ( mockInstance . a ) . toEqual ( '' ) ; expect ( mockInstance . b ) . toEqual ( 0 ) ; } ) ; } ) ; describe ( 'in a property' , ( ) => { it ( 'should create a concrete newable type in the property' , ( ) => { interface Test { a : string ; b : number ; c : new ( ) => Test ; } const mock = createMock < Test > ( ) ; const instance = new mock . c ( ) ; expect ( instance . a ) . toEqual ( '' ) ; expect ( instance . b ) . toEqual ( 0 ) ; } ) ; } ) ; describe ( 'in a method' , ( ) => { it ( 'should create a concrete newable type as a method returned value' , ( ) => { interface Test { a : string ; b : number ; c ( ) : new ( ) => Test ; } const mock = createMock < Test > ( ) ; const instance = new ( mock . c ( ) ) ( ) ; expect ( instance . a ) . toEqual ( '' ) ; expect ( instance . b ) . toEqual ( 0 ) ; } ) ; } ) ; describe ( 'from a type' , ( ) => { it ( 'should create a concrete newable type' , ( ) => { interface Test { a : string ; b : number ; } type TestType = new ( ) => Test ; const mockType = createMock < TestType > ( ) ; const instance = new mockType ( ) ; expect ( instance . a ) . toEqual ( '' ) ; expect ( instance . b ) . toEqual ( 0 ) ; } ) ; } ) ; } ) ;