From ca1200b90f4fddb68cc7189449cac2e5cd82c2b4 Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Thu, 16 Nov 2017 11:39:26 -0500 Subject: [PATCH] add failing tests for stripping null values --- .../{json_ld_spec.rb => json_ld_drop_spec.rb} | 8 ++++++++ spec/jekyll_seo_tag_integration_spec.rb | 4 ++++ 2 files changed, 12 insertions(+) rename spec/jekyll_seo_tag/{json_ld_spec.rb => json_ld_drop_spec.rb} (96%) diff --git a/spec/jekyll_seo_tag/json_ld_spec.rb b/spec/jekyll_seo_tag/json_ld_drop_spec.rb similarity index 96% rename from spec/jekyll_seo_tag/json_ld_spec.rb rename to spec/jekyll_seo_tag/json_ld_drop_spec.rb index df463d5..ea6a601 100644 --- a/spec/jekyll_seo_tag/json_ld_spec.rb +++ b/spec/jekyll_seo_tag/json_ld_drop_spec.rb @@ -152,4 +152,12 @@ RSpec.describe Jekyll::SeoTag::JSONLDDrop do expect(subject).to have_key("url") expect(subject["url"]).to eql("/page.html") end + + context "with null values" do + let(:metadata) { {} } + + it "does not return null values as json" do + expect(subject.to_json).to_not match(/:null/) + end + end end diff --git a/spec/jekyll_seo_tag_integration_spec.rb b/spec/jekyll_seo_tag_integration_spec.rb index 8f4f589..9a13ac7 100755 --- a/spec/jekyll_seo_tag_integration_spec.rb +++ b/spec/jekyll_seo_tag_integration_spec.rb @@ -338,6 +338,10 @@ EOS it "minifies JSON-LD" do expect(output).to_not match(%r!{.*?\s.*?}!) end + + it "removes null values from JSON-LD" do + expect(output).to_not match(/:null/) + end end end