File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 11const YAML = require ( 'yamljs' )
2- const utf8 = require ( 'utf8' )
32
43const allBannersYaml = 'source/_data/banners.yml'
54
5+ function emojiStrip ( string , utf16Encoded = true ) {
6+ if ( ! utf16Encoded ) {
7+ return string . replace ( / \\ u [ \d A - F ] { 8 } / gi, '' )
8+ }
9+
10+ return string . replace ( / ( [ \uE000 - \uF8FF ] | \uD83C [ \uDF00 - \uDFFF ] | \uD83D [ \uDC00 - \uDDFF ] ) / g, '' )
11+ }
12+
613describe ( 'Contentful driven banners' , ( ) => {
714 it ( 'displays all current banners with proper info' , function ( ) {
815 cy . task ( 'readFileMaybe' , allBannersYaml )
916 . then ( ( yamlString ) => {
1017 if ( typeof yamlString === 'undefined' || yamlString === null ) return this . skip ( )
1118
12- const yamlObject = YAML . parse ( yamlString )
19+ const yamlObject = YAML . parse ( emojiStrip ( yamlString , false ) )
1320
1421 // remove all outdated or future banners
1522 const setMyTimezoneToDate = ( date ) => new Date ( Date . parse ( date ) )
@@ -35,7 +42,7 @@ describe('Contentful driven banners', () => {
3542 . should ( ( bannerText ) => {
3643 const yamlText = Cypress . $ ( banners [ i ] . text ) . text ( ) . trim ( )
3744
38- expect ( utf8 . encode ( bannerText ) , `Banner #${ i + 1 } text is proper` ) . to . eq ( yamlText )
45+ expect ( emojiStrip ( bannerText ) , `Banner #${ i + 1 } text is proper` ) . to . eq ( yamlText )
3946 } )
4047
4148 cy . wrap ( banner )
You can’t perform that action at this time.
0 commit comments