File tree 2 files changed +19
-8
lines changed
2 files changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ export function imock<T>(): T {
42
42
const mockedValue = new Mocker ( Empty , true ) . getMock ( ) ;
43
43
44
44
if ( typeof Proxy === "undefined" ) {
45
- return mockedValue ;
45
+ throw new Error ( "Mocking of interfaces requires support for Proxy objects" ) ;
46
46
}
47
47
const tsmockitoMocker = mockedValue . __tsmockitoMocker ;
48
48
return new Proxy ( mockedValue , tsmockitoMocker . createCatchAllHandlerForRemainingPropertiesWithoutGetters ( ) ) ;
Original file line number Diff line number Diff line change @@ -157,18 +157,29 @@ describe("mocking", () => {
157
157
let mockedFoo : SampleInterface ;
158
158
let foo : SampleInterface ;
159
159
160
- it ( "can create interface mock" , ( ) => {
161
- // given
160
+ if ( typeof Proxy === "undefined" ) {
161
+ it ( "throws when creating interface mock" , ( ) => {
162
+ // given
162
163
163
- // when
164
- mockedFoo = imock ( ) ;
165
- foo = instance ( mockedFoo ) ;
164
+ // when
166
165
167
- // then
168
- } ) ;
166
+ // then
167
+ expect ( ( ) => imock ( ) ) . toThrow ( ) ;
168
+ } ) ;
169
+ }
169
170
170
171
if ( typeof Proxy !== "undefined" ) {
171
172
173
+ it ( "can create interface mock" , ( ) => {
174
+ // given
175
+
176
+ // when
177
+ mockedFoo = imock ( ) ;
178
+ foo = instance ( mockedFoo ) ;
179
+
180
+ // then
181
+ } ) ;
182
+
172
183
it ( "can verify call count" , ( ) => {
173
184
// given
174
185
mockedFoo = imock ( ) ;
You can’t perform that action at this time.
0 commit comments