-
Notifications
You must be signed in to change notification settings - Fork 255
/
head-tags.tests.ts
59 lines (50 loc) · 1.52 KB
/
head-tags.tests.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import clone from "clone-deep";
import { createStore, InitializedStore } from "@frontity/connect";
import wpSource from "@frontity/wp-source/src";
import HeadTagsPackage, { PostTypeWithHeadTags } from "../../types";
import headTagsPackage from "..";
import { getCurrentHeadTags } from "../utils";
// Import all mocks.
import postType from "./mocks/post-type.json";
let store: InitializedStore<HeadTagsPackage>;
beforeEach(() => {
// Create store.
const config: HeadTagsPackage = clone(headTagsPackage());
// Mock wp-source state.
const {
state: { source }
} = clone(wpSource());
config.state.source = 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);
});
describe("HeadTags component", () => {
test("works with post archive", () => {
// Populate source state.
store.state.source.type = {
post: postType as PostTypeWithHeadTags
};
store.state.source.data = {
"/": {
type: "post",
items: [],
isArchive: true,
isPostTypeArchive: true,
isPostArchive: true,
isHome: true,
isFetching: false,
isReady: true
}
};
// Populate router state.
store.state.router.link = "/";
// Test current head tags.
expect(getCurrentHeadTags({ ...store })).toMatchSnapshot();
});
test.todo("add tests");
});