Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tests] Convert last of tests to Jasmine #387

Open
wants to merge 1 commit into
base: miranda/most-tests
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/unit/Apollo/addTypeNameBeforeWrite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe(`transform document before write`, () => {
});

it(`correctly write with __typename`, () => {
expect(hermes.readQuery({
jestExpect(hermes.readQuery({
query: gql(`
query getViewer {
viewer {
Expand All @@ -43,7 +43,7 @@ describe(`transform document before write`, () => {
}
}
`),
})).to.deep.eq({
})).toEqual({
viewer: {
id: 0,
name: 'Gouda',
Expand Down
4 changes: 2 additions & 2 deletions test/unit/Apollo/addTypeNameBeforeWriteFragment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe(`transform document before writeFragmetn`, () => {
});

it(`correctly writeFragment with __typename`, () => {
expect(hermes.readQuery({
jestExpect(hermes.readQuery({
query: gql(`
query getViewer {
viewer(count: 2) {
Expand All @@ -78,7 +78,7 @@ describe(`transform document before writeFragmetn`, () => {
}
}
`),
})).to.deep.eq({
})).toEqual({
viewer: [
{
id: 0,
Expand Down
4 changes: 2 additions & 2 deletions test/unit/Apollo/addTypeNameBeforeWriteQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe(`transform document before writeQuery`, () => {
});

it(`correctly writeQuery with __typename`, () => {
expect(hermes.readQuery({
jestExpect(hermes.readQuery({
query: gql(`
query getViewer {
viewer {
Expand All @@ -41,7 +41,7 @@ describe(`transform document before writeQuery`, () => {
}
}
`),
})).to.deep.eq({
})).toEqual({
viewer: {
id: 0,
name: 'Gouda',
Expand Down
20 changes: 10 additions & 10 deletions test/unit/Apollo/persistenceRoundTrip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ describe(`extract/restore roundtrip`, () => {
addTypename: true,
});

expect(() => {
jestExpect(() => {
hermes.restore(JSON.parse(persisted), undefined, {
query: gql(baseResourcesV2),
optimistic: false,
});
}).to.throw();
}).toThrow();
});

it(`extracted data is pruned according to the prune query`, () => {
Expand All @@ -82,7 +82,7 @@ describe(`extract/restore roundtrip`, () => {
addTypename: true,
});

expect(() => {
jestExpect(() => {
hermes.restore(JSON.parse(persisted), {
_entities: {
Viewer: {
Expand All @@ -93,9 +93,9 @@ describe(`extract/restore roundtrip`, () => {
query: gql(baseResourcesV2),
optimistic: false,
});
}).to.not.throw();
}).not.toThrow();

expect(() => {
jestExpect(() => {
hermes.readQuery({
query: gql(`
query getViewer {
Expand All @@ -106,7 +106,7 @@ describe(`extract/restore roundtrip`, () => {
}
`),
});
}).to.throw(/read not satisfied by the cache/i);
}).toThrow(/read not satisfied by the cache/i);

});

Expand All @@ -116,7 +116,7 @@ describe(`extract/restore roundtrip`, () => {
addTypename: true,
});

expect(() => {
jestExpect(() => {
hermes.restore(JSON.parse(persisted), {
_entities: {
Viewer: {
Expand All @@ -127,11 +127,11 @@ describe(`extract/restore roundtrip`, () => {
query: gql(baseResourcesV2),
optimistic: false,
});
}).to.not.throw();
}).not.toThrow();

expect(hermes.readQuery({
jestExpect(hermes.readQuery({
query: gql(baseResourcesV2),
})).to.deep.eq({
})).toEqual({
viewer: {
id: 0,
age: '',
Expand Down
4 changes: 2 additions & 2 deletions test/unit/Apollo/readFragment/aliasReference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe(`readFragment with alias references`, () => {
});

it(`correctly read a fragment with parameterized reference`, () => {
expect(hermes.readFragment({
jestExpect(hermes.readFragment({
id: '123',
fragment: gql(`
fragment viewer on Viewer {
Expand All @@ -77,7 +77,7 @@ describe(`readFragment with alias references`, () => {
variables: {
city: 'Seattle',
},
})).to.be.deep.eq({
})).toEqual({
id: 123,
fullName: 'Gouda',
name: 'Gouda',
Expand Down
4 changes: 2 additions & 2 deletions test/unit/Apollo/readFragment/basicOneFragment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ describe(`readFragment with one fragment`, () => {
});

it(`correctly read a fragment`, () => {
expect(hermes.readFragment({
jestExpect(hermes.readFragment({
id: '123',
fragment: gql(`
fragment viewer on Viewer {
id
name
}
`),
})).to.be.deep.eq({
})).toEqual({
id: 123,
name: 'Gouda',
__typename: 'Viewer',
Expand Down
4 changes: 2 additions & 2 deletions test/unit/Apollo/readFragment/dataNotFound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ describe(`readFragment with no matching data`, () => {
});

it(`correctly returns undefined`, () => {
expect(hermes.readFragment({
jestExpect(hermes.readFragment({
id: '123',
fragment: gql(`
fragment viewer on Viewer {
id
name
}
`),
})).to.be.eq(undefined);
})).toBe(undefined);
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe(`readFragment with ambiguous fragments`, () => {
});

it(`throws an error`, () => {
expect(() => {
jestExpect(() => {
hermes.readFragment({
id: '123',
fragment: gql(`
Expand All @@ -46,7 +46,7 @@ describe(`readFragment with ambiguous fragments`, () => {
}
`),
});
}).to.throw(/Found 2 fragments. `fragmentName` must be provided/i);
}).toThrow(/Found 2 fragments. `fragmentName` must be provided/i);
});

});
4 changes: 2 additions & 2 deletions test/unit/Apollo/readFragment/errorNoFragment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe(`readFragment when no fragment is provided`, () => {
});

it(`throws an error`, () => {
expect(() => {
jestExpect(() => {
hermes.readFragment({
id: '123',
fragment: gql(`
Expand All @@ -39,7 +39,7 @@ describe(`readFragment when no fragment is provided`, () => {
}
`),
});
}).to.throw(/No operations are allowed when using a fragment as a query/i);
}).toThrow(/No operations are allowed when using a fragment as a query/i);
});

});
4 changes: 2 additions & 2 deletions test/unit/Apollo/readFragment/incompleteCacheData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe(`readFragment with incomplete cache`, () => {
});

it(`returns the partial result`, () => {
expect(hermes.readFragment({
jestExpect(hermes.readFragment({
id: '123',
fragment: gql(`
fragment viewer on Viewer {
Expand All @@ -38,7 +38,7 @@ describe(`readFragment with incomplete cache`, () => {
location
}
`),
})).to.be.deep.eq({
})).toEqual({
id: 123,
name: 'Gouda',
__typename: 'Viewer',
Expand Down
8 changes: 4 additions & 4 deletions test/unit/Apollo/readFragment/multipleFragments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe(`readFragment with multiple fragments`, () => {
});

it(`returns a value following the named fragment ('viewer')`, () => {
expect(hermes.readFragment({
jestExpect(hermes.readFragment({
id: '123',
fragmentName: 'viewer',
fragment: gql(`
Expand All @@ -55,7 +55,7 @@ describe(`readFragment with multiple fragments`, () => {
__typename
}
`),
})).to.be.deep.eq({
})).toEqual({
id: 123,
name: 'Gouda',
__typename: 'Viewer',
Expand All @@ -68,7 +68,7 @@ describe(`readFragment with multiple fragments`, () => {
});

it(`returns a value following the named fragment ('shipment')`, () => {
expect(hermes.readFragment({
jestExpect(hermes.readFragment({
id: 'shipment0',
fragmentName: 'shipment',
fragment: gql(`
Expand All @@ -83,7 +83,7 @@ describe(`readFragment with multiple fragments`, () => {
__typename
}
`),
})).to.be.deep.eq({
})).toEqual({
id: 'shipment0',
destination: 'Seattle',
__typename: 'Shipment',
Expand Down
4 changes: 2 additions & 2 deletions test/unit/Apollo/readFragment/parameterizedReference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe(`readFragment with parameterized references`, () => {
});

it(`returns parameterized data`, () => {
expect(hermes.readFragment({
jestExpect(hermes.readFragment({
id: '123',
fragment: gql(`
fragment viewer on Viewer {
Expand All @@ -77,7 +77,7 @@ describe(`readFragment with parameterized references`, () => {
variables: {
city: 'Seattle',
},
})).to.be.deep.eq({
})).toEqual({
id: 123,
name: 'Gouda',
__typename: 'Viewer',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe(`writeFragment with parameterized references within arrays`, () => {
});

it(`returns parameterized data`, () => {
expect(hermes.readFragment({
jestExpect(hermes.readFragment({
id: '123',
fragment: gql(`
fragment viewer on Viewer {
Expand All @@ -95,7 +95,7 @@ describe(`writeFragment with parameterized references within arrays`, () => {
city: 'Seattle',
area: 'PNW',
},
})).to.deep.eq({
})).toEqual({
id: 123,
name: 'Gouda',
__typename: 'Viewer',
Expand Down
4 changes: 2 additions & 2 deletions test/unit/Apollo/readFragment/parameterizedValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe(`readFragment with parameterized values`, () => {
});

it(`returns parameterized data`, () => {
expect(hermes.readFragment({
jestExpect(hermes.readFragment({
id: '123',
fragment: gql(`
fragment viewer on Viewer {
Expand All @@ -69,7 +69,7 @@ describe(`readFragment with parameterized values`, () => {
variables: {
city: 'Seattle',
},
})).to.be.deep.eq({
})).toEqual({
id: 123,
name: 'Gouda',
__typename: 'Viewer',
Expand Down
6 changes: 3 additions & 3 deletions test/unit/Apollo/writeFragment/addReference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe(`writeFragment`, () => {
});

it(`adds references`, () => {
expect(hermes.getCurrentCacheSnapshot().baseline.getNodeData('shipment0')).to.deep.eq({
jestExpect(hermes.getCurrentCacheSnapshot().baseline.getNodeData('shipment0')).toEqual({
id: 'shipment0',
city: 'Seattle',
__typename: 'Shipment',
Expand All @@ -66,7 +66,7 @@ describe(`writeFragment`, () => {

it(`inlines referenced data into referencing entities`, () => {
const baseline = hermes.getCurrentCacheSnapshot().baseline;
expect(baseline.getNodeSnapshot('123')).to.deep.eq(
jestExpect(baseline.getNodeSnapshot('123')).toEqual(
new EntitySnapshot(
{
id: 123,
Expand All @@ -83,7 +83,7 @@ describe(`writeFragment`, () => {
)
);

expect(baseline.getNodeData('123')!['shipment']).to.eq(baseline.getNodeData('shipment0'));
jestExpect(baseline.getNodeData('123')!['shipment']).toBe(baseline.getNodeData('shipment0'));
});

});
4 changes: 2 additions & 2 deletions test/unit/Apollo/writeFragment/errorConvertListToNonList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe(`writeFragment`, () => {
});

it(`throws an error when trying to convert from list to non-list`, () => {
expect(() => {
jestExpect(() => {
hermes.writeFragment({
id: '123',
fragment: gql(`
Expand All @@ -62,7 +62,7 @@ describe(`writeFragment`, () => {
},
},
});
}).to.throw(/Unsupported transition from a list to a non-list value/i);
}).toThrow(/Unsupported transition from a list to a non-list value/i);
});

});
4 changes: 2 additions & 2 deletions test/unit/Apollo/writeFragment/errorConvertNonListToList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe(`writeFragment`, () => {
});

it(`throws an error when trying to convert from list to non-list`, () => {
expect(() => {
jestExpect(() => {
hermes.writeFragment({
id: '123',
fragment: gql(`
Expand All @@ -62,7 +62,7 @@ describe(`writeFragment`, () => {
],
},
});
}).to.throw(/Unsupported transition from a non-list to list value/i);
}).toThrow(/Unsupported transition from a non-list to list value/i);
});

});
Loading