File tree Expand file tree Collapse file tree 2 files changed +19
-8
lines changed
Expand file tree Collapse file tree 2 files changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ export function imock<T>(): T {
4040 const mockedValue = new Mocker ( Empty , true ) . getMock ( ) ;
4141
4242 if ( typeof Proxy === "undefined" ) {
43- return mockedValue ;
43+ throw new Error ( "Mocking of interfaces requires support for Proxy objects" ) ;
4444 }
4545 const tsmockitoMocker = mockedValue . __tsmockitoMocker ;
4646 return new Proxy ( mockedValue , tsmockitoMocker . createCatchAllHandlerForRemainingPropertiesWithoutGetters ( ) ) ;
Original file line number Diff line number Diff line change @@ -157,18 +157,29 @@ describe("mocking", () => {
157157 let mockedFoo : SampleInterface ;
158158 let foo : SampleInterface ;
159159
160- it ( "can create interface mock" , ( ) => {
161- // given
160+ if ( typeof Proxy === "undefined" ) {
161+ it ( "throws when creating interface mock" , ( ) => {
162+ // given
162163
163- // when
164- mockedFoo = imock ( ) ;
165- foo = instance ( mockedFoo ) ;
164+ // when
166165
167- // then
168- } ) ;
166+ // then
167+ expect ( ( ) => imock ( ) ) . toThrow ( ) ;
168+ } ) ;
169+ }
169170
170171 if ( typeof Proxy !== "undefined" ) {
171172
173+ it ( "can create interface mock" , ( ) => {
174+ // given
175+
176+ // when
177+ mockedFoo = imock ( ) ;
178+ foo = instance ( mockedFoo ) ;
179+
180+ // then
181+ } ) ;
182+
172183 it ( "can verify call count" , ( ) => {
173184 // given
174185 mockedFoo = imock ( ) ;
You can’t perform that action at this time.
0 commit comments