Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
});
const config = wpSource();
// add a handler for tests
config.libraries.source.handlers.push({
name: "always",
priority: 0,
pattern: "/(.*)",
func: handler
});
// replace the mocked fetch by the real one we want to test
config.actions.source.fetch = actions.fetch;
// replace the mocked init by the real one we want to test
config.actions.source.init = actions.init;
return createStore(config);
};
const config = wpSource();
const { api, populate } = config.libraries.source;
// mock api
(api.get as jest.Mock).mockResolvedValue(mockResponse([post60]));
// mock populate
(populate as jest.Mock).mockResolvedValue([
{
id: 60,
slug: "the-beauties-of-gullfoss",
link: "https://test.frontity.io/2016/the-beauties-of-gullfoss/"
}
]);
store = createStore(config);
});
beforeEach(() => {
warn.mockClear();
// Create store.
const config: HeadTagsPackage = clone(headTagsPackage());
// Mock wp-source state.
config.state.source = clone(wpSource()).state.source;
config.state.source.api = "https://test.frontity.io/wp-json";
// Mock router state.
config.state.router = { link: "/" };
// Mock site url.
config.state.frontity = { url: "https://mars.frontity.org" };
// Initialize store.
store = createStore(config);
});
beforeEach(() => {
store = createStore(clone(wpSource()));
store.actions.source.init();
api = store.libraries.source.api as jest.Mocked;
});
beforeEach(() => {
store = createStore(clone(wpSource()));
store.actions.source.init();
api = store.libraries.source.api as jest.Mocked;
});
beforeEach(() => {
store = createStore(clone(wpSource()));
store.actions.source.init();
api = store.libraries.source.api as jest.Mocked;
});
beforeEach(() => {
store = createStore(clone(wpSource()));
store.actions.source.init();
api = store.libraries.source.api as jest.Mocked;
});
beforeEach(() => {
store = createStore(clone(wpSource()));
store.actions.source.init();
api = store.libraries.source.api as jest.Mocked;
});
beforeEach(() => {
store = createStore(clone(wpSource()));
store.actions.source.init();
api = store.libraries.source.api as jest.Mocked;
});