Repository: skovhus/jest-codemods (ts)

Issue:
support jasmine spyOnProperty
jasmine can spy on properties , [see their docs](https://jasmine.github.io/tutorials/spying_on_properties).

## Desired behaviour
Input:
```ts
spyOnProperty(component, 'propertyName1').and.returnValue(42);
spyOnProperty(component, 'propertyName2', 'get').and.returnValue(true);
```

should be transformed to:
```ts
jest.spyOn(component, 'propertyName1', 'get').mockReturnValue(42);
jest.spyOn(component, 'propertyName2', 'get').mockReturnValue(true);
```

Pull request description:
feat(jasmine): add support for spyOnProperty
fixes #603 

Patch:
diff --git a/src/transformers/jasmine-globals.ts b/src/transformers/jasmine-globals.ts
index 9356bb1..8a35add 100644
--- a/src/transformers/jasmine-globals.ts
+++ b/src/transformers/jasmine-globals.ts
@@ -234,6 +234,19 @@ export default function jasmineGlobals(fileInfo, api, options) {
       path.node.callee = j.memberExpression(j.identifier('jest'), j.identifier('spyOn'))
     })
 
+  root
+    .find(j.CallExpression, {
+      callee: { type: 'Identifier', name: 'spyOnProperty' },
+    })
+    .forEach((path) => {
+      path.node.callee = j.memberExpression(j.identifier('jest'), j.identifier('spyOn'))
+
+      // explicitly add third parameter, which is defaulted as 'get' in jasmine
+      if (path.node.arguments.length === 2) {
+        path.node.arguments.push(j.literal('get'))
+      }
+    })
+
   root
     .find(j.CallExpression, {
       // find all `*.calls.count()`


Test patch:
diff --git a/src/transformers/jasmine-globals.test.ts b/src/transformers/jasmine-globals.test.ts
index 8910943..2a37635 100644
--- a/src/transformers/jasmine-globals.test.ts
+++ b/src/transformers/jasmine-globals.test.ts
@@ -51,6 +51,19 @@ test('spyOn', () => {
   )
 })
 
+test('spyOnProperty', () => {
+  expectTransformation(
+    `
+    spyOnProperty(component, 'propertyName1').and.returnValue(42);
+    spyOnProperty(component, 'propertyName2', 'get').and.returnValue(true);
+    jest.spyOn(something, 'property', 'get');`,
+    `
+    jest.spyOn(component, 'propertyName1', 'get').mockReturnValue(42);
+    jest.spyOn(component, 'propertyName2', 'get').mockReturnValue(true);
+    jest.spyOn(something, 'property', 'get');`
+  )
+})
+
 test('jasmine.createSpy', () => {
   expectTransformation(
     `