Skip to content

Commit

Permalink
chore: cleanup unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed Nov 10, 2021
1 parent b4cb52e commit 5be986d
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 25 deletions.
3 changes: 2 additions & 1 deletion packages/n4s/src/n4s.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import assign from 'assign';
import mapFirst from 'mapFirst';
import throwError from 'throwError';
import { DropFirst } from 'utilityTypes';
Expand Down Expand Up @@ -52,7 +53,7 @@ const enforce = new Proxy(EnforceBase as TEnforce, {

if (key === 'extend') {
return function extend(customRules: TRule) {
Object.assign(baseRules, customRules);
assign(baseRules, customRules);
};
}

Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/assign.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default Object.assign;
3 changes: 2 additions & 1 deletion packages/vest/src/core/ctx.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import assign from 'assign';
import createContext from 'context';

import VestTest from 'VestTest';
Expand All @@ -6,7 +7,7 @@ import createStateRef from 'createStateRef';
export default createContext<CTXType>((ctxRef, parentContext) =>
parentContext
? null
: Object.assign(
: assign(
{},
{
exclusion: {
Expand Down
4 changes: 2 additions & 2 deletions packages/vest/src/core/suite/create.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asArray from 'asArray';
import assign from 'assign';
import genId from 'genId';
import isFunction from 'isFunction';
import throwError from 'throwError';
Expand All @@ -15,7 +16,6 @@ import {
useLagging,
} from 'stateHooks';


export default function create<T extends (...args: any[]) => void>(
suiteCallback: T
): {
Expand Down Expand Up @@ -53,7 +53,7 @@ export default function create<T extends (...args: any[]) => void>(
subscribe: (handler: () => void) => void;
}

const suite: IVestSuite = Object.assign(
const suite: IVestSuite = assign(
context.bind({ stateRef }, (...args: unknown[]) => {
const [previousTestObjects] = useTestObjects();
const [, setCarryOverTests] = useCarryOverTests();
Expand Down
3 changes: 2 additions & 1 deletion packages/vest/src/core/test/test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import assign from 'assign';
import isFunction from 'isFunction';

import VestTest, { TTestFn } from 'VestTest';
Expand Down Expand Up @@ -41,7 +42,7 @@ export function testBase(
return testObject;
}

export default Object.assign(testBase, {
export default assign(testBase, {
each: bindTestEach(testBase),
memo: bindTestMemo(testBase),
});
6 changes: 3 additions & 3 deletions packages/vest/src/hooks/__tests__/exclusive.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import faker from 'faker';
import * as vest from 'vest';

import testDummy from '../../../testUtils/testDummy';
import { dummyTest } from '../../../testUtils/testDummy';

import VestTest from 'VestTest';
import context from 'ctx';
Expand All @@ -26,10 +26,10 @@ describe('exclusive hooks', () => {
const validate = vest.create(() => {
vest.skip.group('group_1');

testObject = testDummy(vest).failing();
testObject = dummyTest.failing();

group('group_1', () => {
testObject1 = testDummy(vest).failing();
testObject1 = dummyTest.failing();
});

res = isExcluded(testObject);
Expand Down
7 changes: 1 addition & 6 deletions packages/vest/src/hooks/warn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ const ERROR_OUTSIDE_OF_TEST = __DEV__
* Sets a running test to warn only mode.
*/
export default function warn(): void {
const ctx = context.use();

if (!ctx) {
throwError('warn ' + ERROR_HOOK_CALLED_OUTSIDE);
return;
}
const ctx = context.useX('warn ' + ERROR_HOOK_CALLED_OUTSIDE);

if (!ctx.currentTest) {
throwError(ERROR_OUTSIDE_OF_TEST);
Expand Down
3 changes: 2 additions & 1 deletion packages/vest/src/produce/produce.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import assign from 'assign';
import createCache from 'cache';
import isFunction from 'isFunction';

Expand All @@ -14,7 +15,7 @@ export function produceFullResult(): IVestResult {
return cache(
[testObjects],
ctx.bind(ctxRef, () =>
Object.assign({}, produceDraft(), {
assign({}, produceDraft(), {
done: ctx.bind(ctxRef, done),
})
)
Expand Down
16 changes: 6 additions & 10 deletions packages/vest/testUtils/testDummy.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
/* eslint-disable jest/no-export */
import faker from 'faker';

import * as vest from 'vest';
import { test, warn } from 'vest';

/**
* Generates dummy vest tests.
* @param {Object} [vestRef] Reference to vest build.
*/
const testDummy = (vestRef = vest) => {
const { test } = vestRef;
const testDummy = () => {
const failing = (
name: string = faker.random.word(),
message: string = faker.random.words(),
Expand Down Expand Up @@ -38,7 +36,7 @@ const testDummy = (vestRef = vest) => {
name,
message,
jest.fn(() => {
vest.warn();
warn();
throw new Error();
})
);
Expand Down Expand Up @@ -73,7 +71,7 @@ const testDummy = (vestRef = vest) => {
name,
message,
jest.fn(() => {
vest.warn();
warn();
})
);
if (groupName) {
Expand Down Expand Up @@ -105,7 +103,7 @@ const testDummy = (vestRef = vest) => {
name,
message,
jest.fn(() => {
vest.warn();
warn();
return new Promise((_, reject) => {
setTimeout(reject, time);
});
Expand Down Expand Up @@ -135,7 +133,7 @@ const testDummy = (vestRef = vest) => {
name,
message,
jest.fn(() => {
vest.warn();
warn();
return new Promise(resolve => {
setTimeout(resolve, time);
});
Expand All @@ -154,6 +152,4 @@ const testDummy = (vestRef = vest) => {
};
};

export default testDummy;

export const dummyTest = testDummy();
1 change: 1 addition & 0 deletions tsconfig.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5be986d

Please sign in to comment.