1
- jest . mock ( "../../hooks/use-site-metadata" , ( ) => {
2
- return ( ) => {
3
- return { siteUrl : "https://www.gatsbyjs.org" }
4
- }
1
+ jest . mock ( `../../hooks/use-site-metadata` , ( ) => ( ) => {
2
+ return { siteUrl : `https://www.gatsbyjs.org` }
5
3
} )
6
4
7
5
import React from "react"
@@ -12,88 +10,88 @@ import BlogPostMetadata from "../blog-post-metadata"
12
10
const basePost = {
13
11
timeToRead : 2 ,
14
12
fields : {
15
- excerpt : " This is the very first Gatsby blog post." ,
13
+ excerpt : ` This is the very first Gatsby blog post.` ,
16
14
} ,
17
15
frontmatter : {
18
- title : " My first Gatsby blog post!" ,
19
- seoTitle : " How to write a Gatsby blog post" ,
16
+ title : ` My first Gatsby blog post!` ,
17
+ seoTitle : ` How to write a Gatsby blog post` ,
20
18
rawDate : 12345 ,
21
19
author : {
22
- id : " Kyle Mathews" ,
23
- twitter : " @kylemathews" ,
20
+ id : ` Kyle Mathews` ,
21
+ twitter : ` @kylemathews` ,
24
22
fields : {
25
- slug : " /contributors/kyle-mathews/" ,
23
+ slug : ` /contributors/kyle-mathews/` ,
26
24
} ,
27
25
} ,
28
26
} ,
29
27
}
30
28
31
- it ( " generates an alternate url the post has a canonicalLink in frontmatter" , ( ) => {
29
+ it ( ` generates an alternate url the post has a canonicalLink in frontmatter` , ( ) => {
32
30
const post = {
33
31
...basePost ,
34
32
frontmatter : {
35
33
...basePost . frontmatter ,
36
- canonicalLink : " https://reactjs.org/" ,
34
+ canonicalLink : ` https://reactjs.org/` ,
37
35
} ,
38
36
}
39
37
render ( < BlogPostMetadata post = { post } /> )
40
38
const content = Helmet . peek ( )
41
39
expect ( content . linkTags ) . toContainEqual ( {
42
- rel : " canonical" ,
43
- href : " https://reactjs.org/" ,
40
+ rel : ` canonical` ,
41
+ href : ` https://reactjs.org/` ,
44
42
} )
45
43
expect ( content . metaTags ) . toContainEqual ( {
46
- property : " og:url" ,
47
- content : " https://reactjs.org/" ,
44
+ property : ` og:url` ,
45
+ content : ` https://reactjs.org/` ,
48
46
} )
49
47
} )
50
48
51
- it ( " does not generate an alternate url if the post doesn't have a canonicalLink" , ( ) => {
49
+ it ( ` does not generate an alternate url if the post doesn't have a canonicalLink` , ( ) => {
52
50
render ( < BlogPostMetadata post = { basePost } /> )
53
51
const content = Helmet . peek ( )
54
52
expect ( content . linkTags ) . not . toContainEqual ( {
55
- rel : " canonical" ,
56
- href : " https://reactjs.org/" ,
53
+ rel : ` canonical` ,
54
+ href : ` https://reactjs.org/` ,
57
55
} )
58
56
expect ( content . metaTags ) . not . toContainEqual ( {
59
- property : " og:url" ,
60
- content : " https://reactjs.org/" ,
57
+ property : ` og:url` ,
58
+ content : ` https://reactjs.org/` ,
61
59
} )
62
60
} )
63
61
64
- it ( " populates the author info and published time" , ( ) => {
62
+ it ( ` populates the author info and published time` , ( ) => {
65
63
render ( < BlogPostMetadata post = { basePost } /> )
66
64
const content = Helmet . peek ( )
67
65
expect ( content . linkTags ) . toContainEqual ( {
68
- rel : " author" ,
69
- href : " https://www.gatsbyjs.org/contributors/kyle-mathews/" ,
66
+ rel : ` author` ,
67
+ href : ` https://www.gatsbyjs.org/contributors/kyle-mathews/` ,
70
68
} )
71
69
expect ( content . metaTags ) . toContainEqual ( {
72
- name : " author" ,
73
- content : " Kyle Mathews" ,
70
+ name : ` author` ,
71
+ content : ` Kyle Mathews` ,
74
72
} )
75
73
expect ( content . metaTags ) . toContainEqual ( {
76
- name : " twitter:creator" ,
77
- content : " @kylemathews" ,
74
+ name : ` twitter:creator` ,
75
+ content : ` @kylemathews` ,
78
76
} )
79
77
expect ( content . metaTags ) . toContainEqual ( {
80
- property : " article:author" ,
81
- content : " Kyle Mathews" ,
78
+ property : ` article:author` ,
79
+ content : ` Kyle Mathews` ,
82
80
} )
83
81
expect ( content . metaTags ) . toContainEqual ( {
84
- property : " article:published_time" ,
82
+ property : ` article:published_time` ,
85
83
content : 12345 ,
86
84
} )
87
85
} )
88
86
89
- it ( " uses the seoTitle when available" , ( ) => {
87
+ it ( ` uses the seoTitle when available` , ( ) => {
90
88
render ( < BlogPostMetadata post = { basePost } /> )
91
89
const content = Helmet . peek ( )
92
90
93
- expect ( content . title ) . toEqual ( " How to write a Gatsby blog post" )
91
+ expect ( content . title ) . toEqual ( ` How to write a Gatsby blog post` )
94
92
} )
95
93
96
- it ( " uses the default title when seoTitle is not available" , ( ) => {
94
+ it ( ` uses the default title when seoTitle is not available` , ( ) => {
97
95
const basePostWithoutSeoTitle = {
98
96
...basePost ,
99
97
frontmatter : {
@@ -105,5 +103,5 @@ it("uses the default title when seoTitle is not available", () => {
105
103
render ( < BlogPostMetadata post = { basePostWithoutSeoTitle } /> )
106
104
const content = Helmet . peek ( )
107
105
108
- expect ( content . title ) . toEqual ( " My first Gatsby blog post!" )
106
+ expect ( content . title ) . toEqual ( ` My first Gatsby blog post!` )
109
107
} )
0 commit comments