Repository: skovhus/jest-codemods (ts)

Issue:
jasmine *.calls.reset() should be replaced by *.mockReset()
jasmine has a namespace `calls` on spies with a method called `reset()` , [see their docs](https://jasmine.github.io/api/5.2/Spy_calls.html).

## Desired behaviour
Input:
```ts
mySpy.calls.reset();
```

should be transformed to:
```ts
mySpy.mockReset();
```

Pull request description:
feat(jasmine): add support for *.calls.reset()
fixes #602 

Patch:
diff --git a/src/transformers/jasmine-globals.ts b/src/transformers/jasmine-globals.ts
index 8a35add..1c48066 100644
--- a/src/transformers/jasmine-globals.ts
+++ b/src/transformers/jasmine-globals.ts
@@ -271,6 +271,27 @@ export default function jasmineGlobals(fileInfo, api, options) {
       j(path).replaceWith(path.node.callee)
     })
 
+  root
+    .find(j.CallExpression, {
+      // find all `*.calls.reset()`
+      callee: {
+        type: 'MemberExpression',
+        property: { type: 'Identifier', name: 'reset' },
+        object: {
+          type: 'MemberExpression',
+          property: { type: 'Identifier', name: 'calls' },
+        },
+      },
+    })
+    .forEach((path) => {
+      j(path).replaceWith(
+        j.callExpression(
+          j.memberExpression(path.node.callee.object.object, j.identifier('mockReset')),
+          []
+        )
+      )
+    })
+
   root
     .find(j.MemberExpression, {
       // find all `stuff.callCount`


Test patch:
diff --git a/src/transformers/jasmine-globals.test.ts b/src/transformers/jasmine-globals.test.ts
index 2a37635..37fc2ba 100644
--- a/src/transformers/jasmine-globals.test.ts
+++ b/src/transformers/jasmine-globals.test.ts
@@ -135,6 +135,21 @@ test('*.calls.count()', () => {
   )
 })
 
+test('*.calls.reset()', () => {
+  expectTransformation(
+    `
+    someMock.calls.reset();
+    stuff.someMock.calls.reset();
+    getMock(stuff).calls.reset();
+    `,
+    `
+    someMock.mockReset();
+    stuff.someMock.mockReset();
+    getMock(stuff).mockReset();
+    `
+  )
+})
+
 test('*.mostRecentCall', () => {
   expectTransformation(
     `