summaryrefslogtreecommitdiffstats
path: root/frontend/__tests__/mockMang.js
diff options
context:
space:
mode:
authorWes Bos <wesbos@gmail.com>2018-05-02 14:51:36 -0400
committerWes Bos <wesbos@gmail.com>2018-05-02 14:51:36 -0400
commit6a83ac97ba191e1169aca4a662825bc52624cf12 (patch)
tree19052e4591265d74b63fcca8a3b667b18ae4984c /frontend/__tests__/mockMang.js
parentf02a5dc73ac4a14c1d641a6ddbfcd2f1bd2ea0b5 (diff)
remove mockMang
Diffstat (limited to 'frontend/__tests__/mockMang.js')
-rw-r--r--frontend/__tests__/mockMang.js122
1 files changed, 0 insertions, 122 deletions
diff --git a/frontend/__tests__/mockMang.js b/frontend/__tests__/mockMang.js
deleted file mode 100644
index 31d096f..0000000
--- a/frontend/__tests__/mockMang.js
+++ /dev/null
@@ -1,122 +0,0 @@
-import { importSchema } from 'graphql-import';
-import { makeExecutableSchema } from 'graphql-tools';
-import MockClient from 'graphql-mock';
-import casual from 'casual';
-import PropTypes from 'prop-types';
-import { ApolloProvider } from 'react-apollo';
-import { mount } from 'enzyme';
-
-// seed it so we get consistent results
-casual.seed(777);
-
-// 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,
- Node: () => casual.uuid,
- DateTime: () => new Date(1400000000000),
- Int: () => casual.integer(400, 5500),
- OrderItem: () => ({
- quantity: casual.integer(1, 10),
- image: 'dog.jpg',
- title: casual.title,
- description: casual.description,
- price: () => 50000,
- }),
- Item: () => ({
- title: casual.title,
- description: casual.description,
- price: () => 50000,
- image: 'dog.jpg',
- largeImage: 'large-dog.jpg',
- }),
- User: () => ({
- email: casual.email,
- name: casual.name,
- }),
-};
-
-const fakeItem = () => ({
- __typename: 'Item',
- id: '123',
- price: 5000,
- user: null,
- image: 'dog-small.jpg',
- title: 'dogs are best',
- description: 'dogs',
- largeImage: 'dog.jpg',
-});
-
-const fakeUser = () => ({
- __typename: 'User',
- id: '4234',
- name: casual.name,
- email: casual.email,
- permissions: ['ADMIN'],
- orders: [],
- cart: [],
-});
-
-const fakeOrderItem = () => ({
- id: casual.uuid,
- image: `${casual.word}.jpg`,
- title: casual.words(),
- price: 4234,
- quantity: 1,
- description: casual.words(),
-});
-
-const fakeOrder = () => ({
- __typename: 'Order',
- id: 'ord123',
- charge: 'ch_123',
- total: 40000,
- items: [fakeOrderItem(), fakeOrderItem()],
- createdAt: '2018-04 - 06T19: 24: 16.000Z',
- user: fakeUser(),
-});
-
-const fakeCartItem = overrides => ({
- __typename: 'CartItem',
- id: 'omg123',
- quantity: 3,
- item: fakeItem(),
- user: fakeUser(),
- ...overrides,
-});
-
-const resolvers = {
- // Query: {
- // cartOpen: () => true,
- // },
-};
-
-const typeDefs = importSchema('../backend/src/schema.graphql');
-
-const schema = makeExecutableSchema({
- typeDefs,
- resolvers,
- resolverValidationOptions: { requireResolversForResolveType: false },
-});
-
-// Creates a mocked client
-const mocked = new MockClient(schema, mocks);
-
-const mountOptions = {
- context: {
- client: mocked.client,
- },
- childContextTypes: {
- client: PropTypes.object,
- },
-};
-
-const mountWithApollo = Component => {
- const wrapper = mount(<ApolloProvider client={mocked.client}>{Component}</ApolloProvider>);
- return { wrapper, component: wrapper.children() };
-};
-
-export default mountOptions;
-
-export { mocked, mountWithApollo, fakeItem, fakeUser, fakeCartItem, fakeOrder, fakeOrderItem };