Skip to content

Commit

Permalink
run jest expect in parallel with chai
Browse files Browse the repository at this point in the history
  • Loading branch information
monotkate committed Oct 5, 2018
1 parent 510868e commit a4a913b
Show file tree
Hide file tree
Showing 34 changed files with 151 additions and 148 deletions.
1 change: 1 addition & 0 deletions test/env/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import chaiJestDiff from 'chai-jest-diff';
// Chai

// We prefer Chai's `expect` interface.
global.jestExpect = global.expect;
global.expect = chai.expect;
// Give us all the info!
chai.config.truncateThreshold = 0;
Expand Down
14 changes: 7 additions & 7 deletions test/unit/operations/restore/basic/arrayOfReferencesOffARoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,22 @@ describe(`operations.restore`, () => {
});

it(`restores GraphSnapshot from JSON serializable object`, () => {
expect(restoreGraphSnapshot).toEqual(originalGraphSnapshot);
jestExpect(restoreGraphSnapshot).toEqual(originalGraphSnapshot);
});

it(`correctly restores different types of NodeSnapshot`, () => {
expect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
expect(restoreGraphSnapshot.getNodeSnapshot('123')).toBeInstanceOf(EntitySnapshot);
expect(restoreGraphSnapshot.getNodeSnapshot('456')).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot('123')).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot('456')).toBeInstanceOf(EntitySnapshot);
});

it(`correctly restores NodeSnapshot, entity transformation on specific entity`, () => {
expect(restoreGraphSnapshot.getNodeData('123')).toBeInstanceOf(Viewer);
expect(restoreGraphSnapshot.getNodeData('456')).toBeInstanceOf(Viewer);
jestExpect(restoreGraphSnapshot.getNodeData('123')).toBeInstanceOf(Viewer);
jestExpect(restoreGraphSnapshot.getNodeData('456')).toBeInstanceOf(Viewer);
});

it(`correctly restores NodeSnapshot, no entity transformation on QueryRootId`, () => {
expect(restoreGraphSnapshot.getNodeData(QueryRootId)).not.toBeInstanceOf(Viewer);
jestExpect(restoreGraphSnapshot.getNodeData(QueryRootId)).not.toBeInstanceOf(Viewer);
});

});
Expand Down
4 changes: 2 additions & 2 deletions test/unit/operations/restore/basic/arrayOfValuesOffARoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ describe(`operations.restore`, () => {
});

it(`restores GraphSnapshot from JSON serializable object`, () => {
expect(restoreGraphSnapshot).toEqual(originalGraphSnapshot);
jestExpect(restoreGraphSnapshot).toEqual(originalGraphSnapshot);
});

it(`correctly restores different types of NodeSnapshot`, () => {
expect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
});

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ describe(`operations.restore`, () => {
});

it(`restores GraphSnapshot from JSON serializable object`, () => {
expect(restoreGraphSnapshot).toEqual(originalGraphSnapshot);
jestExpect(restoreGraphSnapshot).toEqual(originalGraphSnapshot);
});

it(`correctly restores different types of NodeSnapshot`, () => {
expect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
});

});
Expand Down
4 changes: 2 additions & 2 deletions test/unit/operations/restore/basic/falsyValues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ describe(`operations.restore`, () => {
`{ null, false, zero, string }`,
cacheContext
);
expect(restoreGraphSnapshot).toEqual(originalGraphSnapshot);
jestExpect(restoreGraphSnapshot).toEqual(originalGraphSnapshot);
});

it(`correctly restores different types of NodeSnapshot`, () => {
expect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
});

});
Expand Down
2 changes: 1 addition & 1 deletion test/unit/operations/restore/basic/invalidNodeSnapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe(`operations.restore`, () => {
describe(`invalid NodeSnapshot type`, () => {

it(`throws error when restore invalid NodeSnapshot type`, () => {
expect(() => {
jestExpect(() => {
const cacheContext = createStrictCacheContext();
restore({
[QueryRootId]: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ describe(`operations.restore`, () => {
});

it(`restores GraphSnapshot from JSON serializable object`, () => {
expect(restoreGraphSnapshot).toEqual(originalGraphSnapshot);
jestExpect(restoreGraphSnapshot).toEqual(originalGraphSnapshot);
});

it(`correctly restores different types of NodeSnapshot`, () => {
expect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
});

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ describe(`operations.restore`, () => {
});

it(`restores GraphSnapshot from JSON serializable object`, () => {
expect(restoreGraphSnapshot).toEqual(originalGraphSnapshot);
jestExpect(restoreGraphSnapshot).toEqual(originalGraphSnapshot);
});

it(`correctly restores different types of NodeSnapshot`, () => {
expect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
});

});
Expand Down
16 changes: 8 additions & 8 deletions test/unit/operations/restore/basic/multipleReferencesOffARoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,23 +126,23 @@ describe(`operations.restore`, () => {
});

it(`restores GraphSnapshot from JSON serializable object`, () => {
expect(restoreGraphSnapshot).toEqual(originaGraphSnapshot);
jestExpect(restoreGraphSnapshot).toEqual(originaGraphSnapshot);
});

it(`correctly restores different types of NodeSnapshot`, () => {
expect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
expect(restoreGraphSnapshot.getNodeSnapshot('123')).toBeInstanceOf(EntitySnapshot);
expect(restoreGraphSnapshot.getNodeSnapshot('456')).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot('123')).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot('456')).toBeInstanceOf(EntitySnapshot);
});

it(`correctly restore NodeSnapshot, entity transformation on specific entity`, () => {
expect(restoreGraphSnapshot.getNodeData('123')).toBeInstanceOf(Bar);
expect(restoreGraphSnapshot.getNodeData('456')).toBeInstanceOf(Foo);
jestExpect(restoreGraphSnapshot.getNodeData('123')).toBeInstanceOf(Bar);
jestExpect(restoreGraphSnapshot.getNodeData('456')).toBeInstanceOf(Foo);
});

it(`correctly restore NodeSnapshot, no entity transformation on QueryRootId`, () => {
expect(restoreGraphSnapshot.getNodeData(QueryRootId)).not.toBeInstanceOf(Bar);
expect(restoreGraphSnapshot.getNodeData(QueryRootId)).not.toBeInstanceOf(Foo);
jestExpect(restoreGraphSnapshot.getNodeData(QueryRootId)).not.toBeInstanceOf(Bar);
jestExpect(restoreGraphSnapshot.getNodeData(QueryRootId)).not.toBeInstanceOf(Foo);
});

});
Expand Down
10 changes: 5 additions & 5 deletions test/unit/operations/restore/basic/nestedReference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,20 @@ describe(`operations.restore`, () => {
});

it(`restores GraphSnapshot from JSON serializable object`, () => {
expect(restoreGraphSnapshot).toEqual(originalGraphSnapshot);
jestExpect(restoreGraphSnapshot).toEqual(originalGraphSnapshot);
});

it(`correctly restores different types of NodeSnapshot`, () => {
expect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
expect(restoreGraphSnapshot.getNodeSnapshot('0')).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot('0')).toBeInstanceOf(EntitySnapshot);
});

it(`correctly restore NodeSnapshot, entity transformation on specific entity`, () => {
expect(restoreGraphSnapshot.getNodeData('0')).toBeInstanceOf(Three);
jestExpect(restoreGraphSnapshot.getNodeData('0')).toBeInstanceOf(Three);
});

it(`correctly restore NodeSnapshot, no entity transformation on QueryRootId`, () => {
expect(restoreGraphSnapshot.getNodeData(QueryRootId)).not.toBeInstanceOf(Three);
jestExpect(restoreGraphSnapshot.getNodeData(QueryRootId)).not.toBeInstanceOf(Three);
});

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ describe(`operations.restore`, () => {
});

it(`restores GraphSnapshot from JSON serializable object`, () => {
expect(restoreGraphSnapshot).toEqual(originalGraphSnapshot);
jestExpect(restoreGraphSnapshot).toEqual(originalGraphSnapshot);
});

it(`correctly restores different types of NodeSnapshot`, () => {
expect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
expect(restoreGraphSnapshot.getNodeSnapshot('0')).toBeInstanceOf(EntitySnapshot);
expect(restoreGraphSnapshot.getNodeSnapshot('1')).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot('0')).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot('1')).toBeInstanceOf(EntitySnapshot);
});

});
Expand Down
14 changes: 7 additions & 7 deletions test/unit/operations/restore/basic/nestedReferencesInArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,22 @@ describe(`operations.restore`, () => {
});

it(`restores GraphSnapshot from JSON serializable object`, () => {
expect(restoreGraphSnapshot).toEqual(originalGraphSnapshot);
jestExpect(restoreGraphSnapshot).toEqual(originalGraphSnapshot);
});

it(`correctly restores different types of NodeSnapshot`, () => {
expect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
expect(restoreGraphSnapshot.getNodeSnapshot('0')).toBeInstanceOf(EntitySnapshot);
expect(restoreGraphSnapshot.getNodeSnapshot('1')).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot('0')).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot('1')).toBeInstanceOf(EntitySnapshot);
});

it(`correctly restore NodeSnapshot, entity transformation on specific entity`, () => {
expect(restoreGraphSnapshot.getNodeData('0')).toBeInstanceOf(Three);
expect(restoreGraphSnapshot.getNodeData('1')).toBeInstanceOf(Three);
jestExpect(restoreGraphSnapshot.getNodeData('0')).toBeInstanceOf(Three);
jestExpect(restoreGraphSnapshot.getNodeData('1')).toBeInstanceOf(Three);
});

it(`correctly restore NodeSnapshot, no entity transformation on QueryRootId`, () => {
expect(restoreGraphSnapshot.getNodeData(QueryRootId)).not.toBeInstanceOf(Three);
jestExpect(restoreGraphSnapshot.getNodeData(QueryRootId)).not.toBeInstanceOf(Three);
});

});
Expand Down
4 changes: 2 additions & 2 deletions test/unit/operations/restore/basic/nestedValueOffARoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ describe(`operations.restore`, () => {
});

it(`restores GraphSnapshot from JSON serializable object`, () => {
expect(restoreGraphSnapshot).toEqual(originalSnapshot);
jestExpect(restoreGraphSnapshot).toEqual(originalSnapshot);
});

it(`correctly restores different types of NodeSnapshot`, () => {
expect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
});

});
Expand Down
4 changes: 2 additions & 2 deletions test/unit/operations/restore/basic/nestedValuesInArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ describe(`operations.restore`, () => {
});

it(`restores GraphSnapshot from JSON serializable object`, () => {
expect(restoreGraphSnapshot).toEqual(originalGraphSnapshot);
jestExpect(restoreGraphSnapshot).toEqual(originalGraphSnapshot);
});

it(`correctly restores different types of NodeSnapshot`, () => {
expect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
});

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ describe(`operations.restore`, () => {
});

it(`restores GraphSnapshot from JSON serializable object`, () => {
expect(restoreGraphSnapshot).toEqual(originalGraphSnapshot);
jestExpect(restoreGraphSnapshot).toEqual(originalGraphSnapshot);
});

it(`correctly restores different types of NodeSnapshot`, () => {
expect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
});

});
Expand Down
6 changes: 3 additions & 3 deletions test/unit/operations/restore/basic/simpleReferenceOffARoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ describe(`operations.restore`, () => {
});

it(`restores GraphSnapshot from JSON serializable object`, () => {
expect(restoreGraphSnapshot).toEqual(originalGraphSnapshot);
jestExpect(restoreGraphSnapshot).toEqual(originalGraphSnapshot);
});

it(`correctly restores different types of NodeSnapshot`, () => {
expect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
expect(restoreGraphSnapshot.getNodeSnapshot('123')).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot('123')).toBeInstanceOf(EntitySnapshot);
});

});
Expand Down
36 changes: 18 additions & 18 deletions test/unit/operations/restore/cyclicReferencesGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ describe(`operations.restore`, () => {
});

it(`restores GraphSnapshot from JSON serializable object`, () => {
expect(restoreGraphSnapshot).toEqual(originalGraphSnapshot);
jestExpect(restoreGraphSnapshot).toEqual(originalGraphSnapshot);
});

it(`correctly restores different types of NodeSnapshot`, () => {
expect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
expect(restoreGraphSnapshot.getNodeSnapshot('1')).toBeInstanceOf(EntitySnapshot);
expect(restoreGraphSnapshot.getNodeSnapshot('2')).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot('1')).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot('2')).toBeInstanceOf(EntitySnapshot);
});

it(`restores RootQuery GraphSnapshot from JSON serialization object`, () => {
Expand All @@ -88,43 +88,43 @@ describe(`operations.restore`, () => {

const fooData = restoreGraphSnapshot.getNodeData('1');

expect(rootGraphSnapshot.inbound).toBe(undefined);
expect(rootGraphSnapshot.outbound).toEqual([{ id: '1', path: ['foo'] }]);
expect(rootData.foo).toBe(fooData);
jestExpect(rootGraphSnapshot.inbound).toBe(undefined);
jestExpect(rootGraphSnapshot.outbound).toEqual([{ id: '1', path: ['foo'] }]);
jestExpect(rootData.foo).toBe(fooData);
});

it(`restores id='1' GraphSnapshot from JSON serialization object`, () => {
const fooGraphSnapshot = restoreGraphSnapshot.getNodeSnapshot('1')!;
const fooData = restoreGraphSnapshot.getNodeData('1');
const barData = restoreGraphSnapshot.getNodeData('2');

expect(fooGraphSnapshot.inbound).toEqual([
jestExpect(fooGraphSnapshot.inbound).toEqual([
{ id: QueryRootId, path: ['foo'] },
{ id: '2', path: ['fizz'] },
]);
expect(fooGraphSnapshot.outbound).toEqual([{ id: '2', path: ['bar'] }]);
expect(fooData.id).toBe(1);
expect(fooData.name).toBe('Foo');
expect(fooData.bar).toBe(barData);
jestExpect(fooGraphSnapshot.outbound).toEqual([{ id: '2', path: ['bar'] }]);
jestExpect(fooData.id).toBe(1);
jestExpect(fooData.name).toBe('Foo');
jestExpect(fooData.bar).toBe(barData);
});

it(`restores id='2' GraphSnapshot from JSON serialization object`, () => {
const barGraphSnapshot = restoreGraphSnapshot.getNodeSnapshot('2')!;
const fooData = restoreGraphSnapshot.getNodeData('1');
const barData = restoreGraphSnapshot.getNodeData('2');

expect(barGraphSnapshot.inbound).toEqual([
jestExpect(barGraphSnapshot.inbound).toEqual([
{ id: '1', path: ['bar'] },
{ id: '2', path: ['buzz'] },
]);
expect(barGraphSnapshot.outbound).toEqual([
jestExpect(barGraphSnapshot.outbound).toEqual([
{ id: '1', path: ['fizz'] },
{ id: '2', path: ['buzz'] },
]);
expect(barData.id).toBe(2);
expect(barData.name).toBe('Bar');
expect(barData.fizz).toBe(fooData);
expect(barData.buzz).toBe(barData);
jestExpect(barData.id).toBe(2);
jestExpect(barData.name).toBe('Bar');
jestExpect(barData.fizz).toBe(fooData);
jestExpect(barData.buzz).toBe(barData);
});

});
Expand Down
10 changes: 5 additions & 5 deletions test/unit/operations/restore/duplicateReferencesGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ describe(`operations.restore`, () => {
});

it(`restores GraphSnapshot from JSON serializable object`, () => {
expect(restoreGraphSnapshot).toEqual(originalGraphSnapshot);
jestExpect(restoreGraphSnapshot).toEqual(originalGraphSnapshot);
});

it(`correctly restores different types of NodeSnapshot`, () => {
expect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
expect(restoreGraphSnapshot.getNodeSnapshot('1')).toBeInstanceOf(EntitySnapshot);
expect(restoreGraphSnapshot.getNodeSnapshot('a')).toBeInstanceOf(EntitySnapshot);
expect(restoreGraphSnapshot.getNodeSnapshot('b')).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot('1')).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot('a')).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot('b')).toBeInstanceOf(EntitySnapshot);
});

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ describe(`operations.restore`, () => {
});

it(`restores GraphSnapshot from JSON serializable object`, () => {
expect(restoreGraphSnapshot).toEqual(originalGraphSnapshot);
jestExpect(restoreGraphSnapshot).toEqual(originalGraphSnapshot);
});

it(`correctly restores different types of NodeSnapshot`, () => {
expect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
jestExpect(restoreGraphSnapshot.getNodeSnapshot(QueryRootId)).toBeInstanceOf(EntitySnapshot);
});

});
Expand Down
Loading

0 comments on commit a4a913b

Please sign in to comment.