Skip to content

Instantly share code, notes, and snippets.

@jamesfulford
Created January 6, 2020 05:27
Show Gist options
  • Save jamesfulford/a600e6c52bfd184f10edb9cb7287ac08 to your computer and use it in GitHub Desktop.
Save jamesfulford/a600e6c52bfd184f10edb9cb7287ac08 to your computer and use it in GitHub Desktop.
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