Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const expectedResults = {
textParagraphTooLong: {
isApplicable: true,
score: 9,
resultText: "<a href='https://yoa.st/35d' target='_blank'>Paragraph length</a>: None of the paragraphs are too long. Great job!",
resultText: "<a href='https://yoa.st/35d' target='_blank'>Paragraph length</a>: There are no paragraphs that are too long. Great job!",
},
textSentenceLength: {
isApplicable: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const expectedResults = {
textParagraphTooLong: {
isApplicable: true,
score: 9,
resultText: "<a href='https://yoa.st/35d' target='_blank'>Paragraph length</a>: None of the paragraphs are too long. " +
resultText: "<a href='https://yoa.st/35d' target='_blank'>Paragraph length</a>: There are no paragraphs that are too long. " +
"Great job!",
},
textSentenceLength: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const expectedResults = {
textParagraphTooLong: {
isApplicable: true,
score: 9,
resultText: "<a href='https://yoa.st/35d' target='_blank'>Paragraph length</a>: None of the paragraphs are too long. Great job!",
resultText: "<a href='https://yoa.st/35d' target='_blank'>Paragraph length</a>: There are no paragraphs that are too long. Great job!",
},
textSentenceLength: {
isApplicable: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const expectedResults = {
textParagraphTooLong: {
isApplicable: true,
score: 9,
resultText: "<a href='https://yoa.st/35d' target='_blank'>Paragraph length</a>: None of the paragraphs are too long. Great job!",
resultText: "<a href='https://yoa.st/35d' target='_blank'>Paragraph length</a>: There are no paragraphs that are too long. Great job!",
},
textSentenceLength: {
isApplicable: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const expectedResults = {
textParagraphTooLong: {
isApplicable: true,
score: 9,
resultText: "<a href='https://yoa.st/35d' target='_blank'>Paragraph length</a>: None of the paragraphs are too long. Great job!",
resultText: "<a href='https://yoa.st/35d' target='_blank'>Paragraph length</a>: There are no paragraphs that are too long. Great job!",
},
textSentenceLength: {
isApplicable: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const expectedResults = {
textParagraphTooLong: {
isApplicable: true,
score: 9,
resultText: "<a href='https://yoa.st/35d' target='_blank'>Paragraph length</a>: None of the paragraphs are too long. Great job!",
resultText: "<a href='https://yoa.st/35d' target='_blank'>Paragraph length</a>: There are no paragraphs that are too long. Great job!",
},
textSentenceLength: {
isApplicable: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const expectedResults = {
textParagraphTooLong: {
isApplicable: true,
score: 9,
resultText: "<a href='https://yoa.st/35d' target='_blank'>Paragraph length</a>: None of the paragraphs are too long. Great job!",
resultText: "<a href='https://yoa.st/35d' target='_blank'>Paragraph length</a>: There are no paragraphs that are too long. Great job!",
},
textSentenceLength: {
isApplicable: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const expectedResults = {
textParagraphTooLong: {
isApplicable: true,
score: 9,
resultText: "<a href='https://yoa.st/35d' target='_blank'>Paragraph length</a>: None of the paragraphs are too long. Great job!",
resultText: "<a href='https://yoa.st/35d' target='_blank'>Paragraph length</a>: There are no paragraphs that are too long. Great job!",
},
textSentenceLength: {
isApplicable: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const expectedResults = {
textParagraphTooLong: {
isApplicable: true,
score: 9,
resultText: "<a href='https://yoa.st/35d' target='_blank'>Paragraph length</a>: None of the paragraphs are too long. Great job!",
resultText: "<a href='https://yoa.st/35d' target='_blank'>Paragraph length</a>: There are no paragraphs that are too long. Great job!",
},
textSentenceLength: {
isApplicable: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,17 @@ const expectedResults = {
textParagraphTooLong: {
isApplicable: true,
score: 9,
resultText: "<a href='https://yoa.st/35d' target='_blank'>Paragraph length</a>: None of the paragraphs are too long. Great job!",
resultText: "<a href='https://yoa.st/35d' target='_blank'>Paragraph length</a>: There are no paragraphs that are too long. Great job!",
},
textSentenceLength: {
isApplicable: true,
score: 9,
resultText: "<a href='https://yoa.st/34v' target='_blank'>Sentence length</a>: Great!",
},
textTransitionWords: {
// This assessment is not applicable to this paper as the text contains less than 200 words.
isApplicable: false,
isApplicable: true,
score: 9,
resultText: "<a href='https://yoa.st/34z' target='_blank'>Transition words</a>: Well done!",
},
passiveVoice: {
isApplicable: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import buildTree from "../../../specHelpers/parse/buildTree";
const listAssessment = new ListAssessment();

describe( "a test for an assessment that checks whether a paper contains a list or not", function() {
it( "assesses when there are no lists", function() {
it( "returns a bad score when there are no lists", function() {
const mockPaper = new Paper( "text with no list" );
const mockResearcher = new EnglishResearcher( mockPaper );
buildTree( mockPaper, mockResearcher );
Expand All @@ -17,6 +17,17 @@ describe( "a test for an assessment that checks whether a paper contains a list
expect( assessment.getText() ).toEqual( "<a href='https://yoa.st/shopify38' target='_blank'>Lists</a>: " +
"No lists appear on this page. <a href='https://yoa.st/shopify39' target='_blank'>Add at least one ordered or unordered list</a>!" );
} );
it( "returns a bad score when there are is no text", function() {
const mockPaper = new Paper( "" );
const mockResearcher = new EnglishResearcher( mockPaper );
buildTree( mockPaper, mockResearcher );

const assessment = listAssessment.getResult( mockPaper );

expect( assessment.getScore() ).toEqual( 3 );
expect( assessment.getText() ).toEqual( "<a href='https://yoa.st/shopify38' target='_blank'>Lists</a>: " +
"No lists appear on this page. <a href='https://yoa.st/shopify39' target='_blank'>Add at least one ordered or unordered list</a>!" );
} );
it( "assesses when there is a list inside an element we want to exclude from the analysis", function() {
const mockPaper = new Paper( "<blockquote>These are the most important things in life:\n" +
"<ul>\n" +
Expand Down Expand Up @@ -91,26 +102,6 @@ describe( "a test for an assessment that checks whether a paper contains a list
} );
} );

describe( "tests for the assessment applicability.", function() {
it( "returns false when the paper is empty.", function() {
const paper = new Paper( "" );
expect( listAssessment.isApplicable( paper ) ).toBe( false );
} );

it( "returns true when the paper is not empty.", function() {
const paper = new Paper( "sample keyword containing a minimum of fifty characters.", {
slug: "sample-with-keyword",
keyword: "kéyword",
} );
expect( listAssessment.isApplicable( paper ) ).toBe( true );
} );

it( "returns false if the text is too short", function() {
const paper = new Paper( "hallo" );
expect( listAssessment.isApplicable( paper ) ).toBe( false );
} );
} );

describe( "a test for retrieving the feedback texts", () => {
it( "should return the custom feedback texts when `callbacks.getResultTexts` is provided", () => {
const assessment = new ListAssessment( {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ describe( "An assessment for scoring too long paragraphs.", function() {
it( "should score 1 paragraph with ok length", function() {
const assessment = paragraphTooLongAssessment.getResult( paper, Factory.buildMockResearcher( [ { paragraphLength: 60 } ] ) );
expect( assessment.getScore() ).toBe( 9 );
expect( assessment.getText() ).toBe( "<a href='https://yoa.st/35d' target='_blank'>Paragraph length</a>: None of the paragraphs" +
" are too long. Great job!" );
expect( assessment.getText() ).toBe( "<a href='https://yoa.st/35d' target='_blank'>Paragraph length</a>:" +
" There are no paragraphs that are too long. Great job!" );
expect( assessment.hasMarks() ).toBe( false );
} );
it( "should score 1 slightly too long paragraph", function() {
Expand All @@ -41,8 +41,8 @@ describe( "An assessment for scoring too long paragraphs.", function() {
const assessment = paragraphTooLongAssessment.getResult( paper, Factory.buildMockResearcher( [ { paragraphLength: 60 },
{ paragraphLength: 71 }, { paragraphLength: 83 } ] ) );
expect( assessment.getScore() ).toBe( 9 );
expect( assessment.getText() ).toBe( "<a href='https://yoa.st/35d' target='_blank'>Paragraph length</a>: None of the paragraphs" +
" are too long. Great job!" );
expect( assessment.getText() ).toBe( "<a href='https://yoa.st/35d' target='_blank'>Paragraph length</a>: " +
"There are no paragraphs that are too long. Great job!" );
expect( assessment.hasMarks() ).toBe( false );
} );
it( "should score 3 paragraphs, one of which is too long", function() {
Expand All @@ -63,10 +63,12 @@ describe( "An assessment for scoring too long paragraphs.", function() {
" <a href='https://yoa.st/35e' target='_blank'>Shorten your paragraphs</a>!" );
expect( assessment.hasMarks() ).toBe( true );
} );
it( "should return an empty assessment result for a paper without paragraphs.", function() {
it( "should return a good result for a paper without paragraphs.", function() {
const assessment = paragraphTooLongAssessment.getResult( paper, Factory.buildMockResearcher( [ ] ) );
expect( assessment.getScore() ).toBe( 0 );
expect( assessment.getText() ).toBe( "" );
expect( assessment.getScore() ).toBe( 9 );
expect( assessment.getText() ).toBe( "<a href='https://yoa.st/35d' target='_blank'>Paragraph length</a>: " +
"There are no paragraphs that are too long. Great job!" );
expect( assessment.hasMarks() ).toBe( false );
} );
} );

Expand Down Expand Up @@ -113,29 +115,6 @@ describe( "An assessment for scoring too long paragraphs in Japanese in which ch
} );
} );

describe( "Applicability of the assessment.", function() {
it( "should return true for isApplicable on a paper with text.", function() {
const paper = new Paper( "This is a very interesting paper. With at least fifty characters." );
expect( paragraphTooLongAssessment.isApplicable( paper ) ).toBe( true );
} );
it( "should return false for isApplicable on a paper without text.", function() {
const paper = new Paper( "" );
expect( paragraphTooLongAssessment.isApplicable( paper ) ).toBe( false );
} );
it( "should return false for isApplicable for a paper with only an image.", function() {
const paper = new Paper( "<img src='https://example.com/image.png' alt='test'>" );
expect( paragraphTooLongAssessment.isApplicable( paper ) ).toBe( false );
} );
it( "should return false for isApplicable for a paper with only spaces.", function() {
const paper = new Paper( " " );
expect( paragraphTooLongAssessment.isApplicable( paper ) ).toBe( false );
} );
it( "returns false if the text is too short", function() {
const paper = new Paper( "hallo" );
expect( paragraphTooLongAssessment.isApplicable( paper ) ).toBe( false );
} );
} );

describe( "A test for marking the sentences", function() {
it( "should return markers for a default text", function() {
const paper = new Paper( "<p>You just got Yoast SEO, and you are ready to get the most out of it! Or, have you already been using it for a " +
Expand Down Expand Up @@ -335,7 +314,7 @@ describe( "test for paragraph too long assessment when is used in product page a
] ) );
expect( result.getScore() ).toEqual( 9 );
expect( result.getText() ).toEqual( "<a href='https://yoa.st/35d' target='_blank'>Paragraph length</a>: " +
"None of the paragraphs are too long. Great job!" );
"There are no paragraphs that are too long. Great job!" );
} );
it( "should assess a paper on a product page with paragraphs that contain more than 100 words", function() {
const paper = new Paper( "" );
Expand Down Expand Up @@ -390,7 +369,7 @@ describe( "test for paragraph too long assessment for languages that have langua
const result = new ParagraphTooLongAssessment().getResult( paper, mockResearcher );
expect( result.getScore() ).toEqual( 9 );
expect( result.getText() ).toEqual( "<a href='https://yoa.st/35d' target='_blank'>Paragraph length</a>: " +
"None of the paragraphs are too long. Great job!" );
"There are no paragraphs that are too long. Great job!" );
} );
it( "should assess a paper with two paragraphs that contain more than 400 characters (red bullet)", function() {
const paper = new Paper( "" );
Expand Down Expand Up @@ -440,7 +419,7 @@ describe( "test for paragraph too long assessment for languages that have langua
const result = new ParagraphTooLongAssessment( {}, true ).getResult( paper, mockResearcher );
expect( result.getScore() ).toEqual( 9 );
expect( result.getText() ).toEqual( "<a href='https://yoa.st/35d' target='_blank'>Paragraph length</a>: " +
"None of the paragraphs are too long. Great job!" );
"There are no paragraphs that are too long. Great job!" );
} );
it( "should assess a paper with three paragraphs that contain more than 200 characters (red bullet)", function() {
const paper = new Paper( "" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,38 +67,13 @@ describe( "An assessment for scoring passive voice.", function() {
} );

describe( "A test for checking the applicability", function() {
it( "returns true for isApplicable for an English paper with text.", function() {
const paper = new Paper( "This is a very interesting paper. With at least 50 characters.", { locale: "en_US" } );
it( "returns true if the researcher has the passive voice research.", function() {
const paper = new Paper( "This is a very interesting paper.", { locale: "en_US" } );
expect( new PassiveVoiceAssessment().isApplicable( paper, new EnglishResearcher( paper ) ) ).toBe( true );
} );

it( "should return false for isApplicable for a paper with only an image.", function() {
const paper = new Paper( "<img src='https://example.com/image.png' alt='test'>" );
expect( new PassiveVoiceAssessment().isApplicable( paper, new EnglishResearcher( paper ) ) ).toBe( false );
} );

it( "should return false for isApplicable for a paper with only spaces.", function() {
const paper = new Paper( " " );
expect( new PassiveVoiceAssessment().isApplicable( paper, new EnglishResearcher( paper ) ) ).toBe( false );
} );

it( "returns false if the text is too short", function() {
const paper = new Paper( "hallo" );
expect( new PassiveVoiceAssessment().isApplicable( paper, new EnglishResearcher( paper ) ) ).toBe( false );
} );

it( "returns false for isApplicable for an Afrikaans paper with text.", function() {
const paper = new Paper( "Hierdie is 'n interessante papier.", { locale: "af_ZA" } );
expect( new PassiveVoiceAssessment().isApplicable( paper, new DefaultResearcher( paper ) ) ).toBe( false );
} );

it( "returns false for isApplicable for an English paper without text.", function() {
const paper = new Paper( "", { locale: "en_US" } );
expect( new PassiveVoiceAssessment().isApplicable( paper, new EnglishResearcher( paper ) ) ).toBe( false );
} );

it( "returns false for isApplicable for an Afrikaans paper without text.", function() {
const paper = new Paper( "", { locale: "af_ZA" } );
it( "returns false if the researcher doesn't have the passive voice research.", function() {
const paper = new Paper( "This is a very interesting paper.' alt='test'>" );
expect( new PassiveVoiceAssessment().isApplicable( paper, new DefaultResearcher( paper ) ) ).toBe( false );
} );
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,34 +40,20 @@ describe( "An assessment for scoring repeated sentence beginnings.", function()
"There is enough variety in your sentences. That's great!" );
} );

it( "is not applicable for a paper without text and a researcher that has the getSentenceBeginnings research.", function() {
paper = new Paper( "", { locale: "it_IT" } );
const assessment = new SentenceBeginningsAssessment().isApplicable( paper, new ItalianResearcher( paper ) );
expect( assessment ).toBe( false );
it( "returns a good score when there are no words in the text.", function() {
const assessment = new SentenceBeginningsAssessment().getResult( paper, Factory.buildMockResearcher( [] ) );
expect( assessment.getScore() ).toBe( 9 );
expect( assessment.getText() ).toBe( "<a href='https://yoa.st/35f' target='_blank'>Consecutive sentences</a>: " +
"There is enough variety in your sentences. That's great!" );
} );

it( "is applicable for an paper with text and a researcher that has the getSentenceBeginnings research.", function() {
paper = new Paper( "Era una gatta, assai trita, e non era d’alcuno, e, vecchia, aveva un suo gattino.", { locale: "it_IT" } );
it( "is applicable when the researcher that has the getSentenceBeginnings research.", function() {
paper = new Paper( "", { locale: "it_IT" } );
const assessment = new SentenceBeginningsAssessment().isApplicable( paper, new ItalianResearcher( paper ) );
expect( assessment ).toBe( true );
} );

it( "returns false if the text is too short", function() {
paper = new Paper( "hallo" );
expect( new SentenceBeginningsAssessment().isApplicable( paper, new EnglishResearcher( paper ) ) ).toBe( false );
} );

it( "should return false for isApplicable for a paper with only an image.", function() {
paper = new Paper( "<img src='https://example.com/image.png' alt='test'>" );
expect( new SentenceBeginningsAssessment().isApplicable( paper, new EnglishResearcher( paper ) ) ).toBe( false );
} );

it( "should return false for isApplicable for a paper with only spaces.", function() {
paper = new Paper( " " );
expect( new SentenceBeginningsAssessment().isApplicable( paper, new EnglishResearcher( paper ) ) ).toBe( false );
} );

it( "is not applicable for a paper with text and a researcher without sentence beginning support.", function() {
it( "is not applicable when the researcher doesn't have the sentence beginning support.", function() {
paper = new Paper( "hello", { locale: "jv_ID" } );
const assessment = new SentenceBeginningsAssessment().isApplicable( paper, new DefaultResearcher( paper ) );
expect( assessment ).toBe( false );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ describe( "An assessment for sentence length", function() {
expect( assessment.hasMarks() ).toBe( false );
} );

it( "returns a good score if there is no text", function() {
const mockPaper = new Paper( "" );
const mockResearcher = new DefaultResearcher( mockPaper );
buildTree( mockPaper, mockResearcher );

const assessment = new SentenceLengthInTextAssessment().getResult( mockPaper, mockResearcher );

expect( assessment.hasScore() ).toBe( true );
expect( assessment.getScore() ).toEqual( 9 );
expect( assessment.getText() ).toEqual( "<a href='https://yoa.st/34v' target='_blank'>Sentence length</a>: Great!" );
expect( assessment.hasMarks() ).toBe( false );
} );

it( "returns the score for 50% long sentences using the default config", function() {
const mockPaper = new Paper( shortSentenceDefault + longSentenceDefault );
const mockResearcher = new DefaultResearcher( mockPaper );
Expand Down Expand Up @@ -310,24 +323,6 @@ describe( "An assessment for sentence length", function() {
expect( assessment.getText() ).toEqual( "<a href='https://yoa.st/34v' target='_blank'>Sentence length</a>: Great!" );
expect( assessment.hasMarks() ).toBe( true );
} );

it( "is not applicable for empty papers", function() {
const mockPaper = new Paper();
const assessment = new SentenceLengthInTextAssessment().isApplicable( mockPaper );
expect( assessment ).toBe( false );
} );

it( "returns false if the text is too short", function() {
const paper = new Paper( "hallo" );
const assessment = new SentenceLengthInTextAssessment().isApplicable( paper );
expect( assessment ).toBe( false );
} );

it( "returns true if the text is long enough", function() {
const paper = new Paper( "hallo".repeat( 100 ) );
const assessment = new SentenceLengthInTextAssessment().isApplicable( paper );
expect( assessment ).toBe( true );
} );
} );

describe( "A test for getting the right scoring config", function() {
Expand Down
Loading