Skip to content

Commit

Permalink
breaking: remove vest.draft() (#474)
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed Oct 30, 2020
1 parent a10ae8a commit 3d47fb1
Show file tree
Hide file tree
Showing 16 changed files with 26 additions and 159 deletions.
1 change: 0 additions & 1 deletion CONTRIBUTING.md
Expand Up @@ -54,7 +54,6 @@ packages/
│ │ │ └── suite/ # Contains all the suite modules and methods
│ │ │ └── createSuite # Initializes the suite and creates a context and state.
│ │ └── hooks/ # Functions that extend vest's functionality. They all use context.
│ │ │ └── draft # Allows access to the intermediate test result.
│ │ │ └── exclusive # Allows including or excluding fields in runtime.
│ │ │ └── warn # Allows setting warn-only fields.
│ │ │ └── group # Adds another nesting level within suites.
Expand Down
3 changes: 0 additions & 3 deletions jsconfig.json
Expand Up @@ -197,9 +197,6 @@
"test": [
"./packages/vest/src/core/test/test.js"
],
"draft": [
"./packages/vest/src/hooks/draft.js"
],
"exclusive": [
"./packages/vest/src/hooks/exclusive.js"
],
Expand Down
2 changes: 0 additions & 2 deletions packages/eslint-plugin-vest/lib/constants/index.js
@@ -1,5 +1,4 @@
const constants = {
VEST_HOOK_DRAFT: 'draft',
VEST_HOOK_ONLY: 'only',
VEST_HOOK_SKIP: 'skip',
VEST_HOOK_WARN: 'warn',
Expand All @@ -12,7 +11,6 @@ constants.ALL_VEST_HOOKS = [
constants.VEST_HOOK_WARN,
constants.VEST_HOOK_ONLY,
constants.VEST_HOOK_SKIP,
constants.VEST_HOOK_DRAFT,
];

constants.VEST_EXCLUSIVE_HOOKS = [
Expand Down
1 change: 0 additions & 1 deletion packages/vest/docs/_sidebar.md
Expand Up @@ -9,5 +9,4 @@
- Advanced cases
- [Using with node](./node)
- [Excluding or including tests](./exclusion)
- [Accessing intermediate suite result](./draft)
- [Utilities](./utilities)
30 changes: 0 additions & 30 deletions packages/vest/docs/draft.md

This file was deleted.

6 changes: 1 addition & 5 deletions packages/vest/docs/exclusion.md
Expand Up @@ -101,8 +101,4 @@ If you combine `vest.only.group` with `vest.skip`, if you skip a field inside a

**vest.skip.group()**

If you combine `vest.skip.group` with `vest.only` your included field declared within the skipped tests will be ignored.

**Read next about:**

- [Accessing intermediate suite result](./draft).
If you combine `vest.skip.group` with `vest.only` your included field declared within the skipped tests will be ignored.
16 changes: 16 additions & 0 deletions packages/vest/docs/result.md
Expand Up @@ -41,6 +41,22 @@ const v = vest.create('my_form', () => {
v.get(); // -> returns the most recent result object for the current suite
```

You can also use `.get()` to access the intermediate validation result during your suite's run, this is a replacement of the deprecated `vest.draft()` hook.

```js
const v = vest.create('my_form', (data) => {
test('username', 'Username is too short', () => {
enforce(data.username).longerThanOrEquals(3);
})

if (!v.get().hasErrors('username')) {
test('username', 'already taken', async () => {
// some async test
})
}
});
```

# Result Object Methods:

Along with these values, the result object exposes the following methods:
Expand Down
1 change: 0 additions & 1 deletion packages/vest/docs/test.md
Expand Up @@ -115,4 +115,3 @@ export default vest.create('form-name', data => {
- [Grouping tests](./group).
- [Asserting with enforce](./enforce).
- [Skipping or including tests](./exclusion).
- [Accessing intermediate suite result](./draft).
Expand Up @@ -148,7 +148,6 @@ exports[`Vest exports All vest exports exist 1`] = `
Object {
"VERSION": Any<String>,
"create": [Function],
"draft": [Function],
"enforce": [Function],
"group": [Function],
"only": [Function],
Expand Down
6 changes: 3 additions & 3 deletions packages/vest/src/core/produce/__tests__/produce.test.js
Expand Up @@ -722,13 +722,13 @@ describe('module: produce', () => {
const control = jest.fn();
let draft;
const validate = vest.create('cache', () => {
draft = vest.draft();
draft = validate.get();
getStateFromContext();
expect(draft).toBe(vest.draft());
expect(draft).toBe(validate.get());
expect(produce(/*isDraft:*/ true)).toBe(validate.get());
testDummy(vest).failing();
expect(produce()).not.toBe(validate.get());
expect(draft).not.toBe(vest.draft());
expect(draft).not.toBe(validate.get());
testDummy(vest).failing();
control();
});
Expand Down
70 changes: 0 additions & 70 deletions packages/vest/src/hooks/__tests__/draft.test.js

This file was deleted.

20 changes: 0 additions & 20 deletions packages/vest/src/hooks/draft.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/vest/src/hooks/hooks.js
@@ -1,4 +1,3 @@
export { default as draft } from 'draft';
export { only, skip } from 'exclusive';
export { default as warn } from 'warn';
export { default as group } from 'group';
3 changes: 1 addition & 2 deletions packages/vest/src/index.js
@@ -1,15 +1,14 @@
import enforce from 'n4s';

import create from 'createSuite';
import { draft, only, skip, warn, group } from 'hooks';
import { only, skip, warn, group } from 'hooks';
import test from 'test';

const VERSION = __LIB_VERSION__;

export default {
VERSION,
create,
draft,
enforce,
group,
only,
Expand Down
6 changes: 3 additions & 3 deletions packages/vest/src/index.mjs
@@ -1,14 +1,14 @@
import enforce from 'n4s';

import create from 'createSuite';
import { draft, only, skip, warn, group } from 'hooks';
import { only, skip, warn, group } from 'hooks';
import test from 'test';

const VERSION = __LIB_VERSION__;

export default {
VERSION,
create,
draft,
enforce,
group,
only,
Expand All @@ -17,4 +17,4 @@ export default {
warn,
};

export { VERSION, create, draft, enforce, group, only, skip, test, warn };
export { VERSION, create, enforce, group, only, skip, test, warn };
18 changes: 2 additions & 16 deletions packages/vest/src/typings/vest.d.ts
Expand Up @@ -381,26 +381,12 @@ declare module 'vest' {
*/
warn(): void;

/**
* Retrieves an intermediate validation result during the validation runtime.
*/
draft(): DraftResult;
VERSION: string;
}

const {
test,
create,
warn,
draft,
VERSION,
enforce,
skip,
only,
group,
}: Vest;
const { test, create, warn, VERSION, enforce, skip, only, group }: Vest;

export { test, create, warn, draft, VERSION, enforce, skip, only, group };
export { test, create, warn, VERSION, enforce, skip, only, group };

const vest: Vest;

Expand Down

0 comments on commit 3d47fb1

Please sign in to comment.