Skip to content

Commit

Permalink
chore: bump prettier (#9153)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB authored Nov 9, 2019
1 parent e00ec07 commit 4a5bac1
Show file tree
Hide file tree
Showing 45 changed files with 783 additions and 535 deletions.
102 changes: 54 additions & 48 deletions docs/GlobalAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,22 +249,23 @@ Use `describe.each` if you keep duplicating the same test suites with different
Example:

```js
describe.each([[1, 1, 2], [1, 2, 3], [2, 1, 3]])(
'.add(%i, %i)',
(a, b, expected) => {
test(`returns ${expected}`, () => {
expect(a + b).toBe(expected);
});
describe.each([
[1, 1, 2],
[1, 2, 3],
[2, 1, 3],
])('.add(%i, %i)', (a, b, expected) => {
test(`returns ${expected}`, () => {
expect(a + b).toBe(expected);
});

test(`returned value not be greater than ${expected}`, () => {
expect(a + b).not.toBeGreaterThan(expected);
});
test(`returned value not be greater than ${expected}`, () => {
expect(a + b).not.toBeGreaterThan(expected);
});

test(`returned value not be less than ${expected}`, () => {
expect(a + b).not.toBeLessThan(expected);
});
},
);
test(`returned value not be less than ${expected}`, () => {
expect(a + b).not.toBeLessThan(expected);
});
});
```

#### 2. `` describe.each`table`(name, fn, timeout) ``
Expand Down Expand Up @@ -333,14 +334,15 @@ Use `describe.only.each` if you want to only run specific tests suites of data d
#### `describe.only.each(table)(name, fn)`

```js
describe.only.each([[1, 1, 2], [1, 2, 3], [2, 1, 3]])(
'.add(%i, %i)',
(a, b, expected) => {
test(`returns ${expected}`, () => {
expect(a + b).toBe(expected);
});
},
);
describe.only.each([
[1, 1, 2],
[1, 2, 3],
[2, 1, 3],
])('.add(%i, %i)', (a, b, expected) => {
test(`returns ${expected}`, () => {
expect(a + b).toBe(expected);
});
});

test('will not be ran', () => {
expect(1 / 0).toBe(Infinity);
Expand Down Expand Up @@ -401,14 +403,15 @@ Use `describe.skip.each` if you want to stop running a suite of data driven test
#### `describe.skip.each(table)(name, fn)`

```js
describe.skip.each([[1, 1, 2], [1, 2, 3], [2, 1, 3]])(
'.add(%i, %i)',
(a, b, expected) => {
test(`returns ${expected}`, () => {
expect(a + b).toBe(expected); // will not be ran
});
},
);
describe.skip.each([
[1, 1, 2],
[1, 2, 3],
[2, 1, 3],
])('.add(%i, %i)', (a, b, expected) => {
test(`returns ${expected}`, () => {
expect(a + b).toBe(expected); // will not be ran
});
});

test('will be ran', () => {
expect(1 / 0).toBe(Infinity);
Expand Down Expand Up @@ -491,12 +494,13 @@ Use `test.each` if you keep duplicating the same test with different data. `test
Example:

```js
test.each([[1, 1, 2], [1, 2, 3], [2, 1, 3]])(
'.add(%i, %i)',
(a, b, expected) => {
expect(a + b).toBe(expected);
},
);
test.each([
[1, 1, 2],
[1, 2, 3],
[2, 1, 3],
])('.add(%i, %i)', (a, b, expected) => {
expect(a + b).toBe(expected);
});
```

#### 2. `` test.each`table`(name, fn, timeout) ``
Expand Down Expand Up @@ -557,12 +561,13 @@ Use `test.only.each` if you want to only run specific tests with different test
#### `test.only.each(table)(name, fn)`

```js
test.only.each([[1, 1, 2], [1, 2, 3], [2, 1, 3]])(
'.add(%i, %i)',
(a, b, expected) => {
expect(a + b).toBe(expected);
},
);
test.only.each([
[1, 1, 2],
[1, 2, 3],
[2, 1, 3],
])('.add(%i, %i)', (a, b, expected) => {
expect(a + b).toBe(expected);
});

test('will not be ran', () => {
expect(1 / 0).toBe(Infinity);
Expand Down Expand Up @@ -619,12 +624,13 @@ Use `test.skip.each` if you want to stop running a collection of data driven tes
#### `test.skip.each(table)(name, fn)`

```js
test.skip.each([[1, 1, 2], [1, 2, 3], [2, 1, 3]])(
'.add(%i, %i)',
(a, b, expected) => {
expect(a + b).toBe(expected); // will not be ran
},
);
test.skip.each([
[1, 1, 2],
[1, 2, 3],
[2, 1, 3],
])('.add(%i, %i)', (a, b, expected) => {
expect(a + b).toBe(expected); // will not be ran
});

test('will be ran', () => {
expect(1 / 0).toBe(Infinity);
Expand Down
5 changes: 4 additions & 1 deletion docs/MockFunctionAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ An array containing the call arguments of all calls that have been made to this
For example: A mock function `f` that has been called twice, with the arguments `f('arg1', 'arg2')`, and then with the arguments `f('arg3', 'arg4')`, would have a `mock.calls` array that looks like this:

```js
[['arg1', 'arg2'], ['arg3', 'arg4']];
[
['arg1', 'arg2'],
['arg3', 'arg4'],
];
```

### `mockFn.mock.results`
Expand Down
70 changes: 35 additions & 35 deletions e2e/__tests__/__snapshots__/each.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,15 @@ FAIL __tests__/failure.test.js
Expected: false
Received: true
9 | 'array table fails on one row: expected %s == %s',
10 | (left, right) => {
> 11 | expect(left).toBe(right);
| ^
12 | }
13 | );
10 | [true, false],
11 | ])('array table fails on one row: expected %s == %s', (left, right) => {
> 12 | expect(left).toBe(right);
| ^
13 | });
14 |
15 | it.each([
at toBe (__tests__/failure.test.js:11:18)
at toBe (__tests__/failure.test.js:12:16)
● array table fails on all rows expected 1 == 2
Expand All @@ -167,15 +167,15 @@ FAIL __tests__/failure.test.js
Expected: 2
Received: 1
16 | 'array table fails on all rows expected %s == %s',
17 | (left, right) => {
> 18 | expect(left).toBe(right);
| ^
19 | }
20 | );
17 | [3, 4],
18 | ])('array table fails on all rows expected %s == %s', (left, right) => {
> 19 | expect(left).toBe(right);
| ^
20 | });
21 |
22 | it.each\`
at toBe (__tests__/failure.test.js:18:18)
at toBe (__tests__/failure.test.js:19:16)
● array table fails on all rows expected 3 == 4
Expand All @@ -184,15 +184,15 @@ FAIL __tests__/failure.test.js
Expected: 4
Received: 3
16 | 'array table fails on all rows expected %s == %s',
17 | (left, right) => {
> 18 | expect(left).toBe(right);
| ^
19 | }
20 | );
17 | [3, 4],
18 | ])('array table fails on all rows expected %s == %s', (left, right) => {
> 19 | expect(left).toBe(right);
| ^
20 | });
21 |
22 | it.each\`
at toBe (__tests__/failure.test.js:18:18)
at toBe (__tests__/failure.test.js:19:16)
● template table fails on one row expected: true == false
Expand Down Expand Up @@ -337,15 +337,15 @@ FAIL __tests__/failure.test.js
Expected: "b"
Received: "a"
66 | (left, right) => {
67 | it('fails', () => {
> 68 | expect(left).toBe(right);
69 | (left, right) => {
70 | it('fails', () => {
> 71 | expect(left).toBe(right);
| ^
69 | });
70 | }
71 | );
72 | });
73 | }
74 | );
at Object.toBe (__tests__/failure.test.js:68:20)
at Object.toBe (__tests__/failure.test.js:71:20)
● array table describe fails on all rows expected c == d › fails
Expand All @@ -354,13 +354,13 @@ FAIL __tests__/failure.test.js
Expected: "d"
Received: "c"
66 | (left, right) => {
67 | it('fails', () => {
> 68 | expect(left).toBe(right);
69 | (left, right) => {
70 | it('fails', () => {
> 71 | expect(left).toBe(right);
| ^
69 | });
70 | }
71 | );
72 | });
73 | }
74 | );
at Object.toBe (__tests__/failure.test.js:68:20)
at Object.toBe (__tests__/failure.test.js:71:20)
`;
16 changes: 10 additions & 6 deletions e2e/__tests__/jestChangedFiles.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,11 @@ test('gets changed files for git', async () => {

run(`${GIT} init`, DIR);

const roots = ['', 'nested-dir', 'nested-dir/second-nested-dir'].map(
filename => path.resolve(DIR, filename),
);
const roots = [
'',
'nested-dir',
'nested-dir/second-nested-dir',
].map(filename => path.resolve(DIR, filename));

let {changedFiles: files} = await getChangedFilesForRoots(roots, {});
expect(
Expand Down Expand Up @@ -290,9 +292,11 @@ testIfHg('gets changed files for hg', async () => {

run(`${HG} init`, DIR);

const roots = ['', 'nested-dir', 'nested-dir/second-nested-dir'].map(
filename => path.resolve(DIR, filename),
);
const roots = [
'',
'nested-dir',
'nested-dir/second-nested-dir',
].map(filename => path.resolve(DIR, filename));

let {changedFiles: files} = await getChangedFilesForRoots(roots, {});
expect(
Expand Down
5 changes: 4 additions & 1 deletion e2e/custom-resolver/resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ const {
default: defaultResolver,
} = require('jest-resolve/build/defaultResolver');

const exportedModules = new Map([['foo', 'foo'], ['bar', 'bar']]);
const exportedModules = new Map([
['foo', 'foo'],
['bar', 'bar'],
]);

module.exports = (name, options) => {
const resolution = exportedModules.get(name);
Expand Down
16 changes: 8 additions & 8 deletions e2e/each/__tests__/describeOnly.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

/* eslint-disable jest/no-focused-tests */

describe.only.each([[true, true], [true, true]])(
'passes all rows expected %s == %s',
(left, right) => {
it('passes', () => {
expect(left).toBe(right);
});
}
);
describe.only.each([
[true, true],
[true, true],
])('passes all rows expected %s == %s', (left, right) => {
it('passes', () => {
expect(left).toBe(right);
});
});

// This failing tests should never because of the above `only` so the suite
// should pass
Expand Down
24 changes: 12 additions & 12 deletions e2e/each/__tests__/eachOnly.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@

/* eslint-disable jest/no-focused-tests */

it.only.each([[true, true], [true, true]])(
'passes one row expected %s == %s',
(left, right) => {
expect(left).toBe(right);
}
);
it.only.each([
[true, true],
[true, true],
])('passes one row expected %s == %s', (left, right) => {
expect(left).toBe(right);
});

it.each([[true, false], [true, true]])(
'Should not be ran: fails all rows expected %s == %s',
(left, right) => {
expect(left).toBe(right);
}
);
it.each([
[true, false],
[true, true],
])('Should not be ran: fails all rows expected %s == %s', (left, right) => {
expect(left).toBe(right);
});

it.only.each`
left | right
Expand Down
Loading

0 comments on commit 4a5bac1

Please sign in to comment.