Created
January 6, 2020 05:27
-
-
Save jamesfulford/a600e6c52bfd184f10edb9cb7287ac08 to your computer and use it in GitHub Desktop.
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
import React, { FunctionComponent, ReactNode } from 'react'; | |
import { useResumeURL, ConfigurationContext } from '.'; | |
import { renderHook } from '@testing-library/react-hooks'; | |
describe('useResumeURL (context)', () => { | |
const makeWrapper = (value: any): FunctionComponent => ({ children }: { children?: ReactNode }) => ( | |
<ConfigurationContext.Provider value={value}> | |
{children} | |
</ConfigurationContext.Provider> | |
); | |
it('should use context provided config', () => { | |
const { result } = renderHook( | |
() => useResumeURL(), | |
{ | |
wrapper: makeWrapper({ baseurl: '{baseurl}', env: '{env}' }), | |
}, | |
); | |
expect(result.current).toBe('{baseurl}/resume/latest.pdf'); | |
}); | |
it('should use default config', () => { | |
const { result } = renderHook( | |
() => useResumeURL(), | |
); | |
expect(result.current).toBe('https://localhost:1948/resume/latest.pdf'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment