@@ -8,6 +8,7 @@ let sphinx = require('../../dist/index.js').buildSphinx(
88 test ,
99 expect ,
1010) ;
11+ let { isTextSimilar } = require ( '../../dist/index.js' ) ;
1112
1213sphinx . test ( 'Make sure to start your code with: <!doctype html>.' , ( ) => {
1314 openingTagIndex = htmlCode . indexOf ( '<!DOCTYPE html>' ) ;
@@ -56,13 +57,25 @@ sphinx.firstElementIsInsideSecond({
5657 secondElementName : 'p' ,
5758} ) ;
5859
59- // sphinx.elementTextIsSet({ elementName: 'h1' });
60- // sphinx.elementTextIsSet({ elementName: 'p' });
61- // sphinx.elementTextIsSet({ elementName: 'em' });
62- // sphinx.elementTextIsSet({ elementName: 'p', text: '3 votes' });
63- // sphinx.elementTextIsSet({ elementName: 'title', text: 'ab' });
60+ //test should pass if the user's text is equal to the sample text (for texts of length > 1)
61+ sphinx . elementTextIsSetLoose ( { elementName : 'title' , text : 'abc a\n d' } ) ;
62+ //test should pass if the user's text contains only the first and last words of the sample text
63+ sphinx . elementTextIsSetLoose ( { elementName : 'h2' , text : 'abc a\n d' } ) ;
64+ //test should pass if the user's text contains only the first word of the sample text, if the sample text's length is 1
65+ sphinx . elementTextIsSetLoose ( { elementName : 'span' , text : 'abc' } ) ;
6466
65- sphinx . elementTextIsSetLoose ( { elementName : 'title' , text : 'abc a d' } ) ;
67+ test ( 'Test should fail when the user\'s text doesn\'t contain the last word of the sample text' , ( ) => {
68+ expect ( isTextSimilar ( root , 'title' , 'abc a\n m' ) ) . toBe ( false ) ;
69+ } ) ;
70+ test ( 'Test should fail when the user\'s text doesn\'t contain the first word of the sample text' , ( ) => {
71+ expect ( isTextSimilar ( root , 'title' , 'ab a\n d' ) ) . toBe ( false ) ;
72+ } ) ;
73+ test ( 'Test should fail when the user\'s text doesn\'t contain the first and last words of the sample text' , ( ) => {
74+ expect ( isTextSimilar ( root , 'title' , 'ab a\n m' ) ) . toBe ( false ) ;
75+ } ) ;
76+ test ( 'Test should fail when the sample text\'s length is greater than one, but the user\'s text length is less than or equal to one' , ( ) => {
77+ expect ( isTextSimilar ( root , 'span' , 'abc d' ) ) . toBe ( false ) ;
78+ } ) ;
6679
6780sphinx . elementAttributeSetToCorrectValue ( {
6881 elementName : 'script' ,
0 commit comments