Skip to content

Commit

Permalink
patch(vest): upgrade context package
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed May 11, 2021
1 parent 5791fef commit c0180d1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 70 deletions.
7 changes: 5 additions & 2 deletions packages/vest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,8 @@
"n4s": "^2.1.1",
"vast": "^1.0.1"
},
"module": "./esm/vest.es.production.js"
}
"module": "./esm/vest.es.production.js",
"dependencies": {
"context": "^1.1.3"
}
}
73 changes: 9 additions & 64 deletions packages/vest/src/hooks/__tests__/group.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import faker from 'faker';
import _ from 'lodash';
import enforce from 'n4s';

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

import context from 'ctx';
import group from 'group';
import vest from 'vest';

Expand Down Expand Up @@ -201,6 +199,7 @@ describe('group: exclusion', () => {
});

describe('group: base case', () => {
let inGroup, outsideGroup;
const validation = () =>
vest.create(suiteName, () => {
dummyTest.failing('field_1');
Expand All @@ -215,8 +214,10 @@ describe('group: base case', () => {
dummyTest.passing('field_2');
dummyTest.failingWarning('field_3');
dummyTest.passingWarning('field_4');
dummyTest.failing('field_6');
inGroup = dummyTest.failing('field_6');
});

outsideGroup = dummyTest.failing('last');
});
let res;
beforeEach(() => {
Expand Down Expand Up @@ -279,70 +280,14 @@ describe('group: base case', () => {
res.tests['field_3'].warnCount
);
});
});

let collect, collection;

describe('group: context creation', () => {
const validation = () =>
vest.create(suiteName, collect => {
collect({
context: context.use(),
groupName: context.use().groupName,
});

dummyTest.failing();
dummyTest.failing();

group(groupName, () => {
collect({
context: context.use(),
groupName: context.use().groupName,
});
dummyTest.failing();
});
collect({
context: context.use(),
groupName: context.use().groupName,
});
describe('Test object creation', () => {
it('when in group, should create test with matching group property', () => {
expect(inGroup.groupName).toBe(groupName);
});
let validate;

beforeEach(() => {
suiteName = faker.random.word();
groupName = faker.random.word();
collect = collector();
collection = collect.collection;
validate = validation();
});

test('Sanity', () => {
// checking that we have the right context in the right places

validate(collect);
expect(collection[1].groupName).toBe(groupName);
expect(collection[2].groupName).toBeUndefined();
});

it('Should initialize suite without group name', () => {
validate(collect);
expect(collection[0].groupName).toBeUndefined();
});

describe('When in group', () => {
it('should create child context with group name', () => {
validate(collect);
expect(collection[1].context.parentContext).toBe(collection[0].context);
expect(collection[1].groupName).toBe(groupName);
expect(collection[1].context.parentContext).toBe(collection[2].context);
});
});

describe('When out of group', () => {
it('should go back to upper context', () => {
validate(collect);
expect(collection[2].groupName).toBeUndefined();
expect(collection[2].context.parentContext).toBeNull();
it('after exiting group, should create est without group property', () => {
expect(outsideGroup).not.toHaveProperty('groupName');
});
});
});
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2049,10 +2049,10 @@ contains-path@^0.1.0:
resolved "https://registry.yarnpkg.com/contains-path/-/contains-path-0.1.0.tgz#fe8cf184ff6670b6baef01a9d4861a5cbec4120a"
integrity sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=

context@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/context/-/context-1.1.0.tgz#1675cfe546b4d8f9925a2c4896a7ee41e917f015"
integrity sha512-nfNLy6MbBleZuK0vDwxUnYyu1McpjaZIHo7a3+yNoLWEJtnUjnB4z5xYZhg3XmVcCflh5U2FeaHbHUfCCLSeHA==
context@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/context/-/context-1.1.3.tgz#e2d1e358b1a40bdc42c7f8bacb66abb050cf00b6"
integrity sha512-eHF34RlIQuloYviKLfTIcdA8p5teA5zg8fFlhCFK5kBvXhDE/HKOc4ezd/XYoz8/kMqWw59orOfetAa0flG6nA==

convert-source-map@^1.1.0, convert-source-map@^1.4.0, convert-source-map@^1.6.0, convert-source-map@^1.7.0:
version "1.7.0"
Expand Down

0 comments on commit c0180d1

Please sign in to comment.