Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function WordPressBlocksProvider(props: {
config: WordPressBlocksProviderConfig;
}) {
const { children, config } = props;
const { blocks, theme } = config;
const { blocks, theme = {} } = config;

return (
<WordPressBlocksContext.Provider value={blocks}>
Expand Down
Copy link
Member

Choose a reason for hiding this comment

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

@colinmurphy I'm guessing we need to leave these tests in now that we've changed the fix, yes?

Copy link
Member Author

Choose a reason for hiding this comment

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

@moonmeister We probably don't. I was leaving this for reference if someone wanted to use the theme argument but I removed the failing test for undefined.

Copy link
Member Author

Choose a reason for hiding this comment

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

@moonmeister Tests reverted back. Thanks for pointing this out.

Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ import type { BlocksTheme } from '../../src/types/theme';
import { renderHook } from '@testing-library/react'; // Import from @testing-library/react

describe('useBlocksTheme', () => {
it('Throws an error if not used within WordPressBlocksProvider', () => {
// Assert that renderHook throws an error when used outside of WordPressBlocksProvider
expect(() => {
renderHook(() => useBlocksTheme());
}).toThrow('useBlocksTheme hook was called outside of context, make sure your app is wrapped with WordPressBlocksProvider');
});

it('returns the passed in theme from WordPressBlocksProvider', () => {
// Wrapping component to provide context
const wrapper = ({ children }: PropsWithChildren<{}>) => {
Expand Down Expand Up @@ -46,4 +39,4 @@ describe('useBlocksTheme', () => {
// Check the correct theme is returned
expect(theme?.colors?.palette).toStrictEqual({ primary: 'black' });
});
});
});
Loading