diff --git a/packages/yoastseo/spec/fullTextTests/testTexts/ja/japanesePaper.js b/packages/yoastseo/spec/fullTextTests/testTexts/ja/japanesePaper.js index 915451bc5df..39d9f79129a 100644 --- a/packages/yoastseo/spec/fullTextTests/testTexts/ja/japanesePaper.js +++ b/packages/yoastseo/spec/fullTextTests/testTexts/ja/japanesePaper.js @@ -66,7 +66,7 @@ const expectedResults = { textLength: { isApplicable: true, score: 9, - resultText: "Text length: The text contains 3165 characters. Good job!", + resultText: "Text length: The text contains 3022 characters. Good job!", }, externalLinks: { isApplicable: true, diff --git a/packages/yoastseo/spec/languageProcessing/helpers/sanitize/removeEmailAddressesSpec.js b/packages/yoastseo/spec/languageProcessing/helpers/sanitize/removeEmailAddressesSpec.js new file mode 100644 index 00000000000..31178173848 --- /dev/null +++ b/packages/yoastseo/spec/languageProcessing/helpers/sanitize/removeEmailAddressesSpec.js @@ -0,0 +1,19 @@ +import removeEmailAddresses from "../../../../src/languageProcessing/helpers/sanitize/removeEmailAddresses.js"; + +describe( "a test for removing email addresses from a string", function() { + it( "removes an email address", function() { + expect( removeEmailAddresses( "example@something.com" ) ).toBe( "" ); + } ); + it( "removes an email address with special characters", function() { + expect( removeEmailAddresses( "some+long+email+address23@some+host-weird-/looking.com" ) ).toBe( "" ); + } ); + it( "removes a very short email address", function() { + expect( removeEmailAddresses( "a@b.com" ) ).toBe( "" ); + } ); + it( "does not remove invalid email addresses", function() { + expect( removeEmailAddresses( "@b.com" ) ).toBe( "@b.com" ); + expect( removeEmailAddresses( "a@b" ) ).toBe( "a@b" ); + expect( removeEmailAddresses( "example@" ) ).toBe( "example@" ); + expect( removeEmailAddresses( "example.com" ) ).toBe( "example.com" ); + } ); +} ); diff --git a/packages/yoastseo/spec/languageProcessing/helpers/sanitize/removeURLsSpec.js b/packages/yoastseo/spec/languageProcessing/helpers/sanitize/removeURLsSpec.js new file mode 100644 index 00000000000..4e084f79ef0 --- /dev/null +++ b/packages/yoastseo/spec/languageProcessing/helpers/sanitize/removeURLsSpec.js @@ -0,0 +1,52 @@ +import removeURLs from "../../../../src/languageProcessing/helpers/sanitize/removeURLs.js"; + +describe( "a test for removing URLs from a string", function() { + it( "removes a base URL", function() { + expect( removeURLs( "https://example.com" ) ).toBe( "" ); + } ); + it( "removes a URL followed by a subdirectory", function() { + expect( removeURLs( "https://example.com/example1" ) ).toBe( "" ); + } ); + it( "removes a URL followed by multiple subdirectories", function() { + expect( removeURLs( "https://example.com/example1/part1" ) ).toBe( "" ); + } ); + it( "removes a URL with a subdomain", function() { + expect( removeURLs( "https://blog.example.com/examples" ) ).toBe( "" ); + } ); + it( "removes a URL starting with http://", function() { + expect( removeURLs( "http://blog.example.com/examples" ) ).toBe( "" ); + } ); + it( "removes a URL containing www.", function() { + expect( removeURLs( "http://www.blog.example.com/examples" ) ).toBe( "" ); + } ); + it( "removes a URL starting with www.", function() { + expect( removeURLs( "www.blog.example.com/examples" ) ).toBe( "" ); + } ); + it( "removes a URL starting with ftp", function() { + expect( removeURLs( "ftp://example.com" ) ).toBe( "" ); + } ); + it( "removes a URL containing special characters.", function() { + expect( removeURLs( "https://www.example.com/foo/?bar=baz&inga=42&quux" ) ).toBe( "" ); + } ); + it( "removes a URL containing a semi-colon.", function() { + expect( removeURLs( "https://www.example.com/foo/?bar=baz&inga=42&quux" ) ).toBe( "" ); + } ); + it( "removes a URL containing more special characters.", function() { + expect( removeURLs( "http://foo.com/blah_(wikipedia)_blah#cite-1" ) ).toBe( "" ); + } ); + it( "removes a URL with a different top-level domain", function() { + expect( removeURLs( "http://example.co.uk" ) ).toBe( "" ); + } ); + it( "removes a URL followed by Japanese characters", function() { + expect( removeURLs( "https://example.comこれに対し日本国有鉄道" ) ).toBe( "これに対し日本国有鉄道" ); + } ); + it( "does not remove a URL that doesn't start with 'http(s)://', 'ftp://' or 'www'.", function() { + expect( removeURLs( "example.com" ) ).toBe( "example.com" ); + } ); + it( "does not remove https:// on its own", function() { + expect( removeURLs( "https://" ) ).toBe( "https://" ); + } ); + it( "does not remove a URL without a top-level domain", function() { + expect( removeURLs( "https://example" ) ).toBe( "https://example" ); + } ); +} ); diff --git a/packages/yoastseo/spec/languageProcessing/helpers/sentence/sentencesLengthSpec.js b/packages/yoastseo/spec/languageProcessing/helpers/sentence/sentencesLengthSpec.js index 5a83c81d57c..0b50b8e7b7b 100644 --- a/packages/yoastseo/spec/languageProcessing/helpers/sentence/sentencesLengthSpec.js +++ b/packages/yoastseo/spec/languageProcessing/helpers/sentence/sentencesLengthSpec.js @@ -35,7 +35,7 @@ describe( "A test to count sentence lengths.", function() { expect( lengths ).toEqual( [ { sentence: "自然おのずから存在しているもの", sentenceLength: 15 }, - { sentence: "歩くさわやかな森 自然 ", sentenceLength: 11 }, + { sentence: "歩くさわやかな森 自然 ", sentenceLength: 10 }, ] ); } ); } ); diff --git a/packages/yoastseo/spec/languageProcessing/languages/ja/helpers/countCharactersSpec.js b/packages/yoastseo/spec/languageProcessing/languages/ja/helpers/countCharactersSpec.js index 69cc0a18e6e..a601da67476 100644 --- a/packages/yoastseo/spec/languageProcessing/languages/ja/helpers/countCharactersSpec.js +++ b/packages/yoastseo/spec/languageProcessing/languages/ja/helpers/countCharactersSpec.js @@ -1,4 +1,3 @@ -import { doesWordMatchRegex } from "../../../../../src/languageProcessing/helpers/morphology/regexHelpers"; import countCharactersFunction from "../../../../../src/languageProcessing/languages/ja/helpers/countCharacters.js"; describe( "counts characters in a string", function() { @@ -13,9 +12,9 @@ describe( "counts characters in a string", function() { "東京オリンピック開会直前の1964年(昭和39年)10月1日に開業した。" ) ).toBe( 136 ); } ); it( "makes sure the countCharacters function still works when the input is a non-Japanese string", function() { - expect( countCharactersFunction( "this is a string" ) ).toBe( 16 ); + expect( countCharactersFunction( "this is a string" ) ).toBe( 13 ); expect( countCharactersFunction( "Низът в компютърните науки е крайна поредица от символи " + - "(представляващи краен брой знаци)." ) ).toBe( 90 ); + "(представляващи краен брой знаци)." ) ).toBe( 78 ); } ); it( "makes sure that the table of contents is excluded from the calculation", function() { const text = "

目次