@@ -49,6 +49,14 @@ const ConsoleClassAndVariableCode = dedent`
4949 const console = new Console();
5050` ;
5151
52+ const ServiceClassAndMethodCode = dedent `
53+ class Service {
54+ method() {}
55+ }
56+
57+ const service = new Service();
58+ ` ;
59+
5260const toThrowMatchers = [
5361 'toThrow' ,
5462 'toThrowError' ,
@@ -73,6 +81,13 @@ const validTestCases: string[] = [
7381 'expect(() => Promise.resolve().then(console.log)).not.toThrow();' ,
7482 ...toThrowMatchers . map ( matcher => `expect(console.log).not.${ matcher } ();` ) ,
7583 ...toThrowMatchers . map ( matcher => `expect(console.log).${ matcher } ();` ) ,
84+ // Issue #1800: jest.mocked().mock.calls should be allowed
85+ ...[
86+ 'const parameter = jest.mocked(service.method).mock.calls[0][0];' ,
87+ 'const calls = jest.mocked(service.method).mock.calls;' ,
88+ 'const lastCall = jest.mocked(service.method).mock.calls[0];' ,
89+ 'const mockedMethod = jest.mocked(service.method); const parameter = mockedMethod.mock.calls[0][0];' ,
90+ ] . map ( code => [ ServiceClassAndMethodCode , code ] . join ( '\n' ) ) ,
7691] ;
7792
7893const invalidTestCases : Array < TSESLint . InvalidTestCase < MessageIds , Options > > = [
@@ -235,6 +250,7 @@ const arith = {
235250${ code }
236251 ` ;
237252}
253+
238254function addContainsMethodsClassInvalid (
239255 code : string [ ] ,
240256) : Array < TSESLint . InvalidTestCase < MessageIds , Options > > {
0 commit comments