Skip to content

Commit

Permalink
fix(Next > CI): Drop Font import as Jest is not configured yet. Polyf…
Browse files Browse the repository at this point in the history
…il for matchMedia
  • Loading branch information
danactive committed Jul 31, 2023
1 parent 6422bbd commit 55f0eba
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ jobs:

- name: 📥 Download deps
uses: bahmutov/npm-install@v1
with:
working-directory: next

- name: 🔎 Type check
run: npm run typecheck --if-present
working-directory: next
13 changes: 13 additions & 0 deletions next/__mocks__/jsdom-missing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation(query => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(), // deprecated
removeListener: jest.fn(), // deprecated
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
});
4 changes: 3 additions & 1 deletion next/__tests__/home.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from 'react'
import '../__mocks__/jsdom-missing'; // Must be imported before the tested file

import { render } from '@testing-library/react'

import Home from '../pages'

test('renders deploy link', () => {
Expand Down
1 change: 0 additions & 1 deletion next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"dependencies": {
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@fontsource/public-sans": "^5.0.5",
"@mui/joy": "^5.0.0-alpha.89",
"boom": "~7.3.0",
"camelcase": "~6.3.0",
Expand Down
3 changes: 1 addition & 2 deletions next/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import '@fontsource/public-sans';
import { List, ListDivider, ListItem } from '@mui/joy';
import { CssVarsProvider } from '@mui/joy/styles';
import Head from 'next/head';
Expand Down Expand Up @@ -47,7 +46,7 @@ function Home({ galleries }) {
maxHeight: '30em',
overflowY: 'auto',
}}>
{galleries.map((item, i) => (
{galleries && galleries.map((item, i) => (
<>
{i > 0 && <ListDivider sx={{ background: '#ccc' }} inset="gutter"/>}
<ListItem><Link href={`/${item.gallery}`}>{item.gallery}</Link></ListItem>
Expand Down

0 comments on commit 55f0eba

Please sign in to comment.