Skip to content
This repository was archived by the owner on Dec 8, 2023. It is now read-only.

chore: remove dependency on formatters for tests #221

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .grit/patterns/enzyme_rtl.md
Original file line number Diff line number Diff line change
@@ -122,7 +122,8 @@ describe('Modal', () => {
```

```js
import { render, screen } from '@testing-library/react';

import { render, screen } from "@testing-library/react";

import TestModel from './modal';

3 changes: 3 additions & 0 deletions .grit/patterns/es6_exports.md
Original file line number Diff line number Diff line change
@@ -58,6 +58,7 @@ module.exports.king = '9';

```js
export const king = '9';

```

## Transform default exports
@@ -81,6 +82,8 @@ export async function createTeam() {
}

export const addTeamToOrgSubscription = () => console.log('cool');


```

### Keep inline values intact
14 changes: 7 additions & 7 deletions .grit/patterns/es6_imports.md
Original file line number Diff line number Diff line change
@@ -48,13 +48,13 @@ const starImport = require('star');
```

```ts
import defaultImport from '../../shared/default';
import { something, another } from './lib';
import { value, original as renamed } from 'something';
import { ogName as otherName } from 'chai';
import { assert } from 'chai';
import { config as conf } from 'chai';
import starImport from 'star';
import defaultImport from '../../shared/default'
import { something, another } from './lib'
import { value, original as renamed } from 'something'
import { ogName as otherName } from 'chai'
import { assert } from 'chai'
import { config as conf } from 'chai'
import starImport from 'star'
```

### Handle dotenv
12 changes: 6 additions & 6 deletions .grit/patterns/es6_imports_to_require.md
Original file line number Diff line number Diff line change
@@ -45,12 +45,12 @@ import defaultImport from '../../shared/default';
```

```ts
const { something, another } = require('./lib');
const { assert } = require('chai');
const { config: conf } = require('chai');
const { mixed: mixie, foo } = require('life');
const starImport = require('star');
const { something, another } = require("./lib")
const { assert } = require("chai")
const { config: conf } = require("chai")
const { mixed: mixie, foo } = require("life")
const starImport = require("star")

// no special handling for default. Also, comments get removed.
const defaultImport = require('../../shared/default');
const defaultImport = require("../../shared/default")
```
23 changes: 15 additions & 8 deletions .grit/patterns/importing.md
Original file line number Diff line number Diff line change
@@ -53,12 +53,15 @@ fetch();

```js
import { keep } from 'keepable';
import { orderBy } from 'lodash';
import { v4 } from 'uuid';
import { orderBy } from "lodash";
import { v4 } from "uuid";



import fetch from 'elsewhere';

import { more } from 'node-fetch';
import { more } from 'node-fetch';


console.log(orderBy([1, 2, 3]));

@@ -87,12 +90,15 @@ fetch();

```js
#!/usr/bin/env node
import { orderBy } from 'lodash';
import { v4 } from 'uuid';
import { orderBy } from "lodash";
import { v4 } from "uuid";



import fetch from 'elsewhere';

import { more } from 'node-fetch';
import { more } from 'node-fetch';


console.log(orderBy([1, 2, 3]));

@@ -115,7 +121,8 @@ class Button extends Component {

```typescript
import _ from 'lodash';
import { Component } from 'React';
import { Component } from "React";


class Button extends Component {
// ...
@@ -141,7 +148,7 @@ class Button extends Component {
```

```typescript
import { Component } from 'React';
import { Component } from "React";

console.log('this is a test');

20 changes: 10 additions & 10 deletions .grit/patterns/index_of_to_includes.md
Original file line number Diff line number Diff line change
@@ -52,15 +52,15 @@ foo.indexOf("a") != -1;
```typescript
!foo.includes("a");

!foo.includes("a")
!foo.includes("a");

!foo.includes("a")
!foo.includes("a");

foo.includes("a")
foo.includes("a");

foo.includes("a")
foo.includes("a");

foo.includes("a")
foo.includes("a");
```

## Transforms lastIndexOf
@@ -82,15 +82,15 @@ foo.lastIndexOf("a") != -1;
```typescript
!foo.includes("a");

!foo.includes("a")
!foo.includes("a");

!foo.includes("a")
!foo.includes("a");

foo.includes("a")
foo.includes("a");

foo.includes("a")
foo.includes("a");

foo.includes("a")
foo.includes("a");
```

## Does not change lastIndexOf or indexOf if it checks for a real index
10 changes: 3 additions & 7 deletions .grit/patterns/jest_array_containing.md
Original file line number Diff line number Diff line change
@@ -55,16 +55,12 @@ describe('test', () => {
it('consolidates', async () => {
const values = ['console.log($9o)', 'console.log($x)', 'PatternWithArgs($arg)'];
const anotherValues = ['nine'];

expect(anotherValues).toEqual(expect.arrayContaining([expect.stringContaining('nine')]));

expect(values).toEqual(
expect.arrayContaining([
expect.stringContaining('console.log($9o)'),
expect(values).toEqual(expect.arrayContaining([expect.stringContaining('console.log($9o)'),
expect.stringContaining('console.log($x)'),
expect.stringContaining('PatternWithArgs($arg)'),
]),
);
expect.stringContaining('PatternWithArgs($arg)')]));
});
});
```
76 changes: 32 additions & 44 deletions .grit/patterns/jest_to_vitest.md
Original file line number Diff line number Diff line change
@@ -197,11 +197,13 @@ afterEach(function () {
```

```javascript


import { vi, test, expect, it, beforeAll, beforeEach, afterAll, afterEach } from 'vitest';

vi.mock('./some-path', () => ({
default: 'hello',
}));
default: 'hello'
}));
vi.mock('./some-path', function () {
doSomeSetups();
return { default: 'hello' };
@@ -227,55 +229,41 @@ const currentWorkerId = VITEST_POOL_ID;
test.skip('test.skip should be processed', () => {
expect('value').toBe('value');
});
it('should complete asynchronously', () =>
new Promise((done) => {
expect('value').toBe('value');
done();
}));
it('should complete asynchronously', () =>
new Promise((finish) => {
expect('value').toBe('value');
finish();
}));
it('should complete asynchronously', () =>
new Promise((done) => {
expect('value').toBe('value');
done();
}));
it('should complete asynchronously', () =>
new Promise(function (done) {
expect('value').toBe('value');
done();
}));
it('should complete asynchronously', () =>
new Promise(function (finish) {
expect('value').toBe('value');
finish();
}));
test.skip('test.skip with done should be processed', () =>
new Promise((done) => {
expect('value').toBe('value');
done();
}));
it('should complete asynchronously', () => new Promise((done) => {
expect('value').toBe('value');
done();
}));
it('should complete asynchronously', () => new Promise((finish) => {
expect('value').toBe('value');
finish();
}));
it('should complete asynchronously', () => new Promise((done) => {
expect('value').toBe('value');
done();
}));
it('should complete asynchronously', () => new Promise(function (done) {
expect('value').toBe('value');
done();
}));
it('should complete asynchronously', () => new Promise(function (finish) {
expect('value').toBe('value');
finish();
}));
test.skip('test.skip with done should be processed', () => new Promise((done) => {
expect('value').toBe('value');
done();
}));
it('should be ignored', () => {
expect('value').toBe('value');
});
it('should be ignored', function () {
expect('value').toBe('value');
});

beforeAll(() => {
setActivePinia(createTestingPinia());
});
beforeEach(() => {
setActivePinia(createTestingPinia());
});
afterAll(() => {
setActivePinia(createTestingPinia());
});
afterEach(() => {
setActivePinia(createTestingPinia());
});
beforeAll(() => { setActivePinia(createTestingPinia()) });
beforeEach(() => { setActivePinia(createTestingPinia()) });
afterAll(() => { setActivePinia(createTestingPinia()) });
afterEach(() => { setActivePinia(createTestingPinia()) });
beforeAll(async () => {
await expect('1').toBe('1');
await expect('2').toBe('2');
2 changes: 1 addition & 1 deletion .grit/patterns/knockout_to_react.md
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ var ViewModel = function (first, last) {
```

```typescript
import { useState } from 'react';
import { useState } from "react";

var ViewComponent = function (props) {
const [firstName, setFirstName] = useState(props.firstName);
Loading