Skip to content

Commit

Permalink
docs: ensure all code blocks contain valid code
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Jul 26, 2020
1 parent da5fec1 commit af9dc8b
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 53 deletions.
20 changes: 10 additions & 10 deletions docs/rules/consistent-test-it.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ This rule gives you control over the usage of these keywords in your codebase.

This rule can be configured as follows

```js
```json5
{
type: 'object',
properties: {
fn: {
enum: ['it', 'test'],
},
withinDescribe: {
enum: ['it', 'test'],
},
type: 'object',
properties: {
fn: {
enum: ['it', 'test'],
},
withinDescribe: {
enum: ['it', 'test'],
},
additionalProperties: false,
},
additionalProperties: false,
}
```

Expand Down
8 changes: 4 additions & 4 deletions docs/rules/expect-expect.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ option:
import { expectSaga } from 'redux-saga-test-plan';
import { addSaga } from '../src/sagas';

test('returns sum', () =>
test('returns sum', () => {
expectSaga(addSaga, 1, 1)
.returns(2)
.run();
);
});
```

Examples of **correct** code for the
Expand All @@ -71,11 +71,11 @@ Examples of **correct** code for the
import { expectSaga } from 'redux-saga-test-plan';
import { addSaga } from '../src/sagas';

test('returns sum', () =>
test('returns sum', () => {
expectSaga(addSaga, 1, 1)
.returns(2)
.run();
);
});
```

Since the string is compiled into aa regular expression, you'll need to escape
Expand Down
4 changes: 2 additions & 2 deletions docs/rules/no-large-snapshots.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ snapshot:
In an `eslintrc` file:

```json
...
{
"rules": {
"jest/no-large-snapshots": ["warn", { "maxSize": 12, "inlineMaxSize": 6 }]
}
...
}
```

Max number of lines allowed could be defined by snapshot type (Inline and
Expand Down
10 changes: 5 additions & 5 deletions docs/rules/prefer-expect-assertions.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ test('my test', () => {
The following patterns are considered warnings:

```js
test("my test", () => {
expect.assertions("1");
expect(someThing()).toEqual("foo");
test('my test', () => {
expect.assertions('1');
expect(someThing()).toEqual('foo');
});

test("my test", () => {
expect.(someThing()).toEqual("foo");
test('my test', () => {
expect(someThing()).toEqual('foo');
});
```

Expand Down
20 changes: 12 additions & 8 deletions docs/rules/require-to-throw-message.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,27 @@ an error message.
The following patterns are considered warnings:

```js
expect(() => a()).toThrow();
test('all the things', async () => {
expect(() => a()).toThrow();

expect(() => a()).toThrowError();
expect(() => a()).toThrowError();

await expect(a()).rejects.toThrow();
await expect(a()).rejects.toThrow();

await expect(a()).rejects.toThrowError();
await expect(a()).rejects.toThrowError();
});
```

The following patterns are not considered warnings:

```js
expect(() => a()).toThrow('a');
test('all the things', async () => {
expect(() => a()).toThrow('a');

expect(() => a()).toThrowError('a');
expect(() => a()).toThrowError('a');

await expect(a()).rejects.toThrow('a');
await expect(a()).rejects.toThrow('a');

await expect(a()).rejects.toThrowError('a');
await expect(a()).rejects.toThrowError('a');
});
```
52 changes: 28 additions & 24 deletions docs/rules/valid-expect.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,33 +95,37 @@ supported by `expect`, such as
The following patterns are considered warnings:

```js
expect();
expect().toEqual('something');
expect('something', 'else');
expect('something');
await expect('something');
expect(true).toBeDefined;
expect(Promise.resolve('hello')).resolves;
expect(Promise.resolve('hello')).resolves.toEqual('hello');
Promise.resolve(expect(Promise.resolve('hello')).resolves.toEqual('hello'));
Promise.all([
expect(Promise.resolve('hello')).resolves.toEqual('hello'),
expect(Promise.resolve('hi')).resolves.toEqual('hi'),
]);
test('all the things', async () => {
expect();
expect().toEqual('something');
expect('something', 'else');
expect('something');
await expect('something');
expect(true).toBeDefined;
expect(Promise.resolve('hello')).resolves;
expect(Promise.resolve('hello')).resolves.toEqual('hello');
Promise.resolve(expect(Promise.resolve('hello')).resolves.toEqual('hello'));
Promise.all([
expect(Promise.resolve('hello')).resolves.toEqual('hello'),
expect(Promise.resolve('hi')).resolves.toEqual('hi'),
]);
});
```

The following patterns are not warnings:

```js
expect('something').toEqual('something');
expect([1, 2, 3]).toEqual([1, 2, 3]);
expect(true).toBeDefined();
await expect(Promise.resolve('hello')).resolves.toEqual('hello');
await Promise.resolve(
expect(Promise.resolve('hello')).resolves.toEqual('hello'),
);
await Promise.all(
expect(Promise.resolve('hello')).resolves.toEqual('hello'),
expect(Promise.resolve('hi')).resolves.toEqual('hi'),
);
test('all the things', async () => {
expect('something').toEqual('something');
expect([1, 2, 3]).toEqual([1, 2, 3]);
expect(true).toBeDefined();
await expect(Promise.resolve('hello')).resolves.toEqual('hello');
await Promise.resolve(
expect(Promise.resolve('hello')).resolves.toEqual('hello'),
);
await Promise.all(
expect(Promise.resolve('hello')).resolves.toEqual('hello'),
expect(Promise.resolve('hi')).resolves.toEqual('hi'),
);
});
```

0 comments on commit af9dc8b

Please sign in to comment.