1- defmodule JolaDevWeb.SEOTest do
1+ defmodule JolaDevWeb.Helpers. SEOTest do
22 use JolaDevWeb.ConnCase , async: true
33
4+ alias JolaDevWeb.Helpers.SEO
5+
46 describe "json_ld/1" do
57 test "includes WebSite schema on all pages" , % { conn: conn } do
68 conn = get ( conn , ~p" /" )
7- schemas = JolaDevWeb. SEO. json_ld ( conn )
9+ schemas = SEO . json_ld ( conn )
810
911 website = Enum . find ( schemas , & ( & 1 [ "@type" ] == "WebSite" ) )
1012 assert website [ "name" ] == "jola.dev"
@@ -14,7 +16,7 @@ defmodule JolaDevWeb.SEOTest do
1416 test "includes BlogPosting schema on blog post pages" , % { conn: conn } do
1517 post = List . first ( JolaDev.Blog . all_posts ( ) )
1618 conn = get ( conn , ~p" /posts/#{ post . id } " )
17- schemas = JolaDevWeb. SEO. json_ld ( conn )
19+ schemas = SEO . json_ld ( conn )
1820
1921 blog_posting = Enum . find ( schemas , & ( & 1 [ "@type" ] == "BlogPosting" ) )
2022 assert blog_posting [ "headline" ] == post . title
@@ -30,7 +32,7 @@ defmodule JolaDevWeb.SEOTest do
3032
3133 test "includes ProfilePage schema on about page" , % { conn: conn } do
3234 conn = get ( conn , ~p" /about" )
33- schemas = JolaDevWeb. SEO. json_ld ( conn )
35+ schemas = SEO . json_ld ( conn )
3436
3537 profile = Enum . find ( schemas , & ( & 1 [ "@type" ] == "ProfilePage" ) )
3638 assert profile [ "mainEntity" ] [ "@type" ] == "Person"
@@ -40,21 +42,21 @@ defmodule JolaDevWeb.SEOTest do
4042
4143 test "does not include BlogPosting on non-post pages" , % { conn: conn } do
4244 conn = get ( conn , ~p" /projects" )
43- schemas = JolaDevWeb. SEO. json_ld ( conn )
45+ schemas = SEO . json_ld ( conn )
4446
4547 refute Enum . any? ( schemas , & ( & 1 [ "@type" ] == "BlogPosting" ) )
4648 end
4749
4850 test "omits BreadcrumbList on the home page" , % { conn: conn } do
4951 conn = get ( conn , ~p" /" )
50- schemas = JolaDevWeb. SEO. json_ld ( conn )
52+ schemas = SEO . json_ld ( conn )
5153
5254 refute Enum . any? ( schemas , & ( & 1 [ "@type" ] == "BreadcrumbList" ) )
5355 end
5456
5557 test "includes BreadcrumbList on /about" , % { conn: conn } do
5658 conn = get ( conn , ~p" /about" )
57- schemas = JolaDevWeb. SEO. json_ld ( conn )
59+ schemas = SEO . json_ld ( conn )
5860
5961 breadcrumb = Enum . find ( schemas , & ( & 1 [ "@type" ] == "BreadcrumbList" ) )
6062
@@ -77,7 +79,7 @@ defmodule JolaDevWeb.SEOTest do
7779 test "includes BreadcrumbList with post title on post pages" , % { conn: conn } do
7880 post = List . first ( JolaDev.Blog . all_posts ( ) )
7981 conn = get ( conn , ~p" /posts/#{ post . id } " )
80- schemas = JolaDevWeb. SEO. json_ld ( conn )
82+ schemas = SEO . json_ld ( conn )
8183
8284 breadcrumb = Enum . find ( schemas , & ( & 1 [ "@type" ] == "BreadcrumbList" ) )
8385 items = breadcrumb [ "itemListElement" ]
@@ -90,7 +92,7 @@ defmodule JolaDevWeb.SEOTest do
9092 test "includes BreadcrumbList with tag on tag pages" , % { conn: conn } do
9193 tag = "elixir"
9294 conn = get ( conn , ~p" /posts/tag/#{ tag } " )
93- schemas = JolaDevWeb. SEO. json_ld ( conn )
95+ schemas = SEO . json_ld ( conn )
9496
9597 breadcrumb = Enum . find ( schemas , & ( & 1 [ "@type" ] == "BreadcrumbList" ) )
9698 items = breadcrumb [ "itemListElement" ]
0 commit comments