Skip to content

Commit

Permalink
Adds GraphQL Codegen (#1130)
Browse files Browse the repository at this point in the history
  • Loading branch information
alessbell authored Oct 14, 2020
1 parent 2d1bb5b commit a97304a
Show file tree
Hide file tree
Showing 14 changed files with 4,849 additions and 186 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ node_modules
tsconfig.json
.vscode
coverage
graphql-types.ts
32 changes: 32 additions & 0 deletions __tests__/components/toggle.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import * as React from 'react';
import { render, screen } from '../utils';
import userEvent from '@testing-library/user-event';
import Toggle from '../../src/components/toggle';
import { ThemeContext } from '../../src/components/layout';

const mockedSetPreferredTheme = jest.fn();

beforeAll(() => {
window.__setPreferredTheme = mockedSetPreferredTheme;
});

describe('Toggle test', () => {
test('renders light to dark', () => {
render(
<ThemeContext.Provider value="light">
<Toggle />
</ThemeContext.Provider>
);
userEvent.click(screen.getByTestId('toggle'));
expect(mockedSetPreferredTheme).toHaveBeenCalledWith('dark');
});
test('renders dark to light', () => {
render(
<ThemeContext.Provider value="dark">
<Toggle />
</ThemeContext.Provider>
);
userEvent.click(screen.getByTestId('toggle'));
expect(mockedSetPreferredTheme).toHaveBeenCalledWith('light');
});
});
10 changes: 10 additions & 0 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ const config = {
commit: process.env.VERCEL_GITHUB_COMMIT_SHA || `main`,
},
plugins: [
{
resolve: `gatsby-plugin-graphql-codegen`,
options: {
documentPaths: [
'./src/**/!(*.d).{js,jsx,ts,tsx}',
'./.cache/fragments/*.js',
'./node_modules/gatsby-*/**/*.js',
],
},
},
`@pauliescanlon/gatsby-mdx-embed`,
{
resolve: `gatsby-source-filesystem`,
Expand Down
Loading

1 comment on commit a97304a

@vercel
Copy link

@vercel vercel bot commented on a97304a Oct 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.