diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-04-17 16:51:09 -0400 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-04-17 16:51:09 -0400 |
| commit | 54dd0e29830f04c9055863fb0449ee4fc2ab0689 (patch) | |
| tree | 920fc79aea7624f0480603ba716aa38358dbc5ab /frontend/__tests__/mockMang.js | |
| parent | 4f907fc051a9863e3cbea249b33a71009551f482 (diff) | |
these tests are on fireee but the bad kind
Diffstat (limited to 'frontend/__tests__/mockMang.js')
| -rw-r--r-- | frontend/__tests__/mockMang.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/frontend/__tests__/mockMang.js b/frontend/__tests__/mockMang.js new file mode 100644 index 0000000..5a98c6a --- /dev/null +++ b/frontend/__tests__/mockMang.js @@ -0,0 +1,39 @@ +import { importSchema } from 'graphql-import'; +import GraphQLMock from 'graphql-mock'; +import casual from 'casual'; +import PropTypes from 'prop-types'; + +// seed it so we get consistent results +casual.seed(123); + +const typeDefs = importSchema('../backend/src/schema.graphql'); + +// By default graphql-mock will generate random numbers, IDs, and Strings of "Hello World" +// We can overwrite any of those if we need to + +const mocks = { + ID: () => casual.uuid, + Item: () => ({ + title: casual.title, + description: casual.description, + price: () => 50000, + }), + User: () => ({ + email: casual.email, + name: casual.name, + }), +}; + +// Creates a mocked client +const mocked = new GraphQLMock(typeDefs, mocks); + +const mountOptions = { + context: { + client: mocked.client, + }, + childContextTypes: { + client: PropTypes.object, + }, +}; + +export default mountOptions; |
