Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/yoastseo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"clean": "rm -rf build",
"pretest": "grunt get-premium-configuration",
"test": "jest",
"lint": "eslint src",
"lint": "eslint src spec --max-warnings 12",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now I set the maximum warnings to 12. But it can also be changed later

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to lower it to 10, given that we currently have 10 warnings! 👍

"prepublishOnly": "yarn build"
},
"engines": {
Expand Down
10 changes: 5 additions & 5 deletions packages/yoastseo/spec/appSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe( "Creating an App", function() {
expect( function() {
new App( {
callbacks: {
getData: function() {
getData: () => {
return {};
},
},
Expand All @@ -60,7 +60,7 @@ describe( "Creating an App", function() {
output: "outputID",
},
callbacks: {
getData: function() {
getData: () => {
return {};
},
},
Expand All @@ -74,7 +74,7 @@ describe( "Creating an App", function() {
output: "outputID",
},
callbacks: {
getData: function() {
getData: () => {
return {};
},
},
Expand All @@ -90,7 +90,7 @@ describe( "Creating an App", function() {
snippet: "snippetID",
},
callbacks: {
getData: function() {
getData: () => {
return {};
},
},
Expand All @@ -104,7 +104,7 @@ describe( "Creating an App", function() {
output: "outputID",
},
callbacks: {
getData: function() {
getData: () => {
return {};
},
},
Expand Down
22 changes: 22 additions & 0 deletions packages/yoastseo/spec/config/getTransliterationsSpec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import getTransliterations, { transliterations } from "../../src/config/getTransliterations";

describe( "A test for retrieving transliterations for a specific locale", () => {
it( "should return the transliteration object for `nbnn` when the locale is either 'nb_NO' or 'nn_NO'", () => {
expect( getTransliterations( "nb_NO" ) ).toEqual( transliterations.nbnn );
expect( getTransliterations( "nn_NO" ) ).toEqual( transliterations.nbnn );
} );
it( "should return the transliteration object for `ca` when the locale is either 'bal' or 'ca'", () => {
expect( getTransliterations( "bal" ) ).toEqual( transliterations.ca );
expect( getTransliterations( "ca" ) ).toEqual( transliterations.ca );
} );
it( "should return the transliteration object from the array when the key for the specific locale is available in the array", () => {
expect( getTransliterations( "es_AR" ) ).toEqual( transliterations.es );
expect( getTransliterations( "pt_PT" ) ).toEqual( transliterations.pt );
} );
it( "should return an empty array when the key for the specific locale is not available in the array", () => {
expect( getTransliterations( "jv_ID" ) ).toEqual( [] );
} );
it( "should return an empty array when no locale is passed", () => {
expect( getTransliterations() ).toEqual( [] );
} );
} );
1 change: 1 addition & 0 deletions packages/yoastseo/spec/helpers/formatNumberSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import formatNumberSpec from "../../src/helpers/formatNumber.js";

describe( "a test to round numbers to two decimal places", function() {
it( "returns a rounded number", function() {
// eslint-disable-next-line no-loss-of-precision
expect( formatNumberSpec( 9.7895437583789573 ) ).toBe( 9.8 );
expect( formatNumberSpec( 3.032434432432 ) ).toBe( 3.0 );
expect( formatNumberSpec( 4.5600000000000005 ) ).toBe( 4.6 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ describe( "A test for topic phrase objects", function() {
new StemOriginalPair( "movie", "movies" ),
new StemOriginalPair( "work", "work" ),
],
false,
false
);

it( "constructs a topic phrase", () => {
Expand Down Expand Up @@ -206,7 +206,7 @@ describe( "A test for topic phrase objects", function() {
new StemOriginalPair( "movie", "movie" ),
new StemOriginalPair( "work", "work" ),
],
true,
true
);
expect( exactMatchTopicPhrase.getStems() ).toEqual( [] );
} );
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
/* eslint-disable no-irregular-whitespace */
import createWordRegex from "../../../../src/languageProcessing/helpers/regex/createWordRegex.js";

describe( "creates regex from keyword", function() {
it( "returns a regex", function() {
expect( createWordRegex( "keyword" ) ).toEqual(
// eslint-disable-next-line max-len
/(^|[ \u00a0\u2014\u06d4\u061f\u060C\u061B\n\r\t.,()”“〝〞〟‟„"+\-;!¡?¿:/»«‹›<>'‘’‛`])keyword($|([ \u00a0\u2014\u06d4\u061f\u060C\u061B\n\r\t.,()”“〝〞〟‟„"+\-;!¡?¿:/»«‹›<>])|((['‘’‛`])([ \u00a0\u2014\u06d4\u061f\u060C\u061B\n\r\t.,()”“〝〞〟‟„"+\-;!¡?¿:/»«‹›<>])))/gi
);
} );
it( "returns a regex - words with diacritics", function() {
expect( createWordRegex( "maïs", "", false ) ).toEqual(
// eslint-disable-next-line max-len
/(^|[ \u00a0\u2014\u06d4\u061f\u060C\u061B\n\r\t.,()”“〝〞〟‟„"+\-;!¡?¿:/»«‹›<>'‘’‛`])maïs($|([ \u00a0\u2014\u06d4\u061f\u060C\u061B\n\r\t.,()”“〝〞〟‟„"+\-;!¡?¿:/»«‹›<>])|((['‘’‛`])([ \u00a0\u2014\u06d4\u061f\u060C\u061B\n\r\t.,()”“〝〞〟‟„"+\-;!¡?¿:/»«‹›<>])))/gi
);
expect( createWordRegex( "Slovníček pojmû", "", false ) ).toEqual(
// eslint-disable-next-line max-len
/(^|[ \u00a0\u2014\u06d4\u061f\u060C\u061B\n\r\t.,()”“〝〞〟‟„"+\-;!¡?¿:/»«‹›<>'‘’‛`])Slovníček pojmû($|([ \u00a0\u2014\u06d4\u061f\u060C\u061B\n\r\t.,()”“〝〞〟‟„"+\-;!¡?¿:/»«‹›<>])|((['‘’‛`])([ \u00a0\u2014\u06d4\u061f\u060C\u061B\n\r\t.,()”“〝〞〟‟„"+\-;!¡?¿:/»«‹›<>])))/gi
);
} );
it( "returns a regex - words with characters that break regexes", function() {
expect( createWordRegex( "keyword*" ) ).toEqual(
// eslint-disable-next-line max-len
/(^|[ \u00a0\u2014\u06d4\u061f\u060C\u061B\n\r\t.,()”“〝〞〟‟„"+\-;!¡?¿:/»«‹›<>'‘’‛`])keyword\*($|([ \u00a0\u2014\u06d4\u061f\u060C\u061B\n\r\t.,()”“〝〞〟‟„"+\-;!¡?¿:/»«‹›<>])|((['‘’‛`])([ \u00a0\u2014\u06d4\u061f\u060C\u061B\n\r\t.,()”“〝〞〟‟„"+\-;!¡?¿:/»«‹›<>])))/gi
);
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import regexMatchFunction from "../../../../src/languageProcessing/helpers/regex
describe( "Matches text with a regex", function() {
it( "returns the number of matches", function() {
expect( regexMatchFunction( "<p>1</p><p>2</p>", new RegExp( "<p(?:[^>]+)?>(.*?)</p>", "ig" ) ) ).toEqual( [ "<p>1</p>", "<p>2</p>" ] );
expect( regexMatchFunction( "<img class=\"alignnone size-medium wp-image-9\" src=\"test.png\" alt=\"image1\" width=\"300\" height=\"36\" />",
// eslint-disable-next-line max-len
new RegExp( "<img(?:[^>]+)?>", "ig" ) ) ).toEqual( [ "<img class=\"alignnone size-medium wp-image-9\" src=\"test.png\" alt=\"image1\" width=\"300\" height=\"36\" />" ] );
expect( regexMatchFunction(
"<img class=\"alignnone size-medium wp-image-9\" src=\"test.png\" alt=\"image1\" width=\"300\" height=\"36\" />",
new RegExp( "<img(?:[^>]+)?>", "ig" ) )
).toEqual( [ "<img class=\"alignnone size-medium wp-image-9\" src=\"test.png\" alt=\"image1\" width=\"300\" height=\"36\" />" ] );
} );
it( "returns an empty array if there is no matches", function() {
// eslint-disable-next-line max-len,no-useless-escape
expect( regexMatchFunction( "<img class=\"alignnone size-medium wp-image-9", "<p(?:[^>]+)?>(.*?)<\/p>" ) ).toEqual( [] );
expect( regexMatchFunction( "<img class=\"alignnone size-medium wp-image-9", "<p(?:[^>]+)?>(.*?)</p>" ) ).toEqual( [] );
} );
} );

Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,10 @@ describe( "A test for tokenizing a (html) text into sentences", function() {
{ type: "sentence", src: '" in The Musical Times in , who commented "Praise is due to Mr Mercer' },
{ type: "full-stop", src: "." },
];
// eslint-disable-next-line max-len
expect( mockTokenizer.getSentencesFromTokens( tokens ) ).toEqual( [ "The reprint was favourably reviewed by \"A. B.\" in The Musical Times in , who commented \"Praise is due to Mr Mercer." ] );
expect( mockTokenizer.getSentencesFromTokens( tokens ) ).toEqual(
[
"The reprint was favourably reviewed by \"A. B.\" in The Musical Times in , who commented \"Praise is due to Mr Mercer.",
] );
} );

it( "recognizes sentence boundary when a sentence starts with initials", function() {
Expand All @@ -288,8 +290,9 @@ describe( "A test for tokenizing a (html) text into sentences", function() {
{ type: "full-stop", src: "." },

];
// eslint-disable-next-line max-len
expect( mockTokenizer.getSentencesFromTokens( tokens ) ).toEqual( [ "This is a sentence.", "E.F. is a good writer.", "G. H. is a very very great personality." ] );
expect( mockTokenizer.getSentencesFromTokens( tokens ) ).toEqual(
[ "This is a sentence.", "E.F. is a good writer.", "G. H. is a very very great personality." ]
);
} );

it( "recognizes sentence boundary when a sentence ends with initials", function() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line max-len
import { detectAndStemRegularParticiple } from "../../../../../../src/languageProcessing/languages/de/helpers/internal/detectAndStemRegularParticiple";
import getMorphologyData from "../../../../../specHelpers/getMorphologyData";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ describe( "a test checking if the word is complex in Spanish", function() {
expect( checkIfWordIsComplex( wordComplexityConfig, "original", premiumData ) ).toEqual( false );
} );

// eslint-disable-next-line max-len
it( "returns plural word form as non-complex if its singular form is found in the list when the singular word form ends with a consonant", function() {
expect( checkIfWordIsComplex( wordComplexityConfig, "originales", premiumData ) ).toEqual( false );
} );

// eslint-disable-next-line max-len
it( "returns plural word form as non-complex if its singular form is found in the list when the singular word form ends with a vowel", function() {
expect( checkIfWordIsComplex( wordComplexityConfig, "parecidos", premiumData ) ).toEqual( false );
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ const morphologyDataJA = getMorphologyData( "ja" );
const paper = new Paper( "これは日本語のテキストです。", { keyword: "日本語のテキスト", locale: "ja" } );

describe( "Test for getting the helper to return a canonical stem for Japanese word", () => {
const mockResearcher = new Researcher( paper );
it( "returns the stem when the Japanese morphology data is available", function() {
const mockResearcher = new Researcher( paper );
mockResearcher.addResearchData( "morphology", morphologyDataJA );
expect( customGetStemmer( mockResearcher )( "日帰り" ) ).toEqual( "日帰っ" );
} );

it( "returns the input word if no morphology data is available", () => {
const mockResearcher = new Researcher( paper );
expect( customGetStemmer( mockResearcher )( "食べる" ) ).toBe( "食べる" );
} );
} );
Original file line number Diff line number Diff line change
Expand Up @@ -305,15 +305,12 @@ describe( "A test for getting positions of sentences", () => {
} );

it.skip( "should get the correct sentence position for a sentence in an image caption", function() {
/* eslint-disable max-len */
// html: "<p>
// <img class='size-medium wp-image-33' src='http://basic.wordpress.test/wp-content/uploads/2021/08/cat-3957861_1280-211x300.jpeg' alt='a different cat with toy' width='211' height='300'>
// </img>
// A flamboyant cat with a toy<br></br>\n
// </p>
/* eslint-enable max-len */

// eslint-disable-next-line max-len
const html = "<p><img class='size-medium wp-image-33' src='http://basic.wordpress.test/wp-content/uploads/2021/08/cat-3957861_1280-211x300.jpeg' alt='a different cat with toy' width='211' height='300'></img>A flamboyant cat with a toy<br></br>\n</p>";

const tree = adapt( parseFragment( html, { sourceCodeLocationInfo: true } ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,9 @@ describe( "a test for the inclusive language assessor when run in Shopify", () =
const assessor = new InclusiveLanguageAssessor( researcher, options );
assessor._assessments.forEach( assessment => {
if ( assessment.isApplicable( mockPaper, researcher ) ) {
// eslint-disable-next-line max-len
expect( assessment.learnMoreUrl ).toEqual( `<a href='https://yoa.st/inclusive-language-${ assessment.category }-shopify' target='_blank'>` );
expect( assessment.learnMoreUrl ).toEqual(
`<a href='https://yoa.st/inclusive-language-${ assessment.category }-shopify' target='_blank'>`
);
}
} );
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ describe( "test hasEnoughContentForAssessment", () => {

it( "should return false if text is 49 chars and an image and no specification for contentNeededForAssessment", () => {
const mockPaper = new Paper( "This text contains forty-nine characterssssssssss" +
// eslint-disable-next-line max-len
"<figure class=\"wp-block-image size-large\"><img src=\"http://basic.wordpress.test/wp-content/uploads/2022/05/70860665-c6b2-4b40-82e9-37b4bea5648e-3-1024x682.jpeg\" alt=\"\" class=\"wp-image-148\"/></figure>" );
const mockAssessment = new Assessment();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// eslint-disable-next-line max-len
import { isFollowedAndPrecededByException, isNotFollowedAndPrecededByException } from "../../../../../src/scoring/assessments/inclusiveLanguage/helpers/isFollowedAndPrecededByException";
import {
isFollowedAndPrecededByException,
isNotFollowedAndPrecededByException,
} from "../../../../../src/scoring/assessments/inclusiveLanguage/helpers/isFollowedAndPrecededByException";

describe( "Test isFollowedAndPrecededByException", () => {
it( "returns true when a term is both followed and preceded by an exception", () => {
Expand Down
Loading