-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe636cb
commit 1074dcf
Showing
6 changed files
with
89 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* index.test.ts | ||
* author: evan kirkiles | ||
* created on Sun Jun 04 2023 | ||
* 2023 the nobot space | ||
*/ | ||
|
||
import React from 'react'; | ||
import { ColoredSection } from './helpers'; | ||
import { render } from './utils'; | ||
// import {ColoredSection} from "./helpers"; | ||
|
||
// TODO: Write tests | ||
// describe('<MetaThemeProvider />', () => { | ||
// test('mocks the theme-color meta tag', () => { | ||
// render( | ||
// <> | ||
// <ColoredSection color="#ffffff" /> | ||
// </>, | ||
// ); | ||
// const meta = document.querySelector('meta[name="theme-color"]'); | ||
// expect(meta?.getAttribute('content')).toBe('#000000'); | ||
// }); | ||
// }); | ||
|
||
describe('<MetaThemeProvider />', () => { | ||
test('needs a test', () => { | ||
expect(true).toBe(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* helpers.tsx | ||
* author: evan kirkiles | ||
* created on Tue Jun 06 2023 | ||
* 2023 the nobot space | ||
*/ | ||
|
||
import React, { useRef } from 'react'; | ||
import useMetaTheme from '../useMetaTheme'; | ||
|
||
export function ColoredSection({ size = '50vh', color }: { size?: string; color: string }) { | ||
const ref = useRef<HTMLDivElement>(null); | ||
useMetaTheme(ref, color); | ||
return ( | ||
<div id={color} style={{ backgroundColor: color, width: '100%', height: size }} ref={ref}> | ||
{color} | ||
</div> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* utils.ts | ||
* author: evan kirkiles | ||
* created on Tue Jun 06 2023 | ||
* 2023 the nobot space | ||
*/ | ||
import React, { StrictMode } from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import MetaThemeProvider from '../MetaThemeContext'; | ||
|
||
beforeEach(() => { | ||
// IntersectionObserver isn't available in test environment | ||
const mockIntersectionObserver = jest.fn(); | ||
mockIntersectionObserver.mockReturnValue({ | ||
observe: () => null, | ||
unobserve: () => null, | ||
disconnect: () => null, | ||
}); | ||
window.IntersectionObserver = mockIntersectionObserver; | ||
}); | ||
|
||
export const render = (node: React.ReactNode) => { | ||
// add white theme-color meta tag | ||
const meta = document.createElement('meta'); | ||
meta.setAttribute('name', 'theme-color'); | ||
meta.setAttribute('content', '#000000'); | ||
|
||
// render meta theme context around app | ||
const mount = document.getElementById('mount'); | ||
ReactDOM.render( | ||
<StrictMode> | ||
<MetaThemeProvider>{node}</MetaThemeProvider> | ||
</StrictMode>, | ||
mount, | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import '@testing-library/jest-dom/extend-expect'; |