Skip to content
Merged
Changes from all 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
13 changes: 10 additions & 3 deletions cypress/integration/contentful_banners_spec.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
const YAML = require('yamljs')
const utf8 = require('utf8')

const allBannersYaml = 'source/_data/banners.yml'

function emojiStrip (string, utf16Encoded = true) {
if (!utf16Encoded) {
return string.replace(/\\u[\dA-F]{8}/gi, '')
}

return string.replace(/([\uE000-\uF8FF]|\uD83C[\uDF00-\uDFFF]|\uD83D[\uDC00-\uDDFF])/g, '')
}

describe('Contentful driven banners', () => {
it('displays all current banners with proper info', function () {
cy.task('readFileMaybe', allBannersYaml)
.then((yamlString) => {
if (typeof yamlString === 'undefined' || yamlString === null) return this.skip()

const yamlObject = YAML.parse(yamlString)
const yamlObject = YAML.parse(emojiStrip(yamlString, false))

// remove all outdated or future banners
const setMyTimezoneToDate = (date) => new Date(Date.parse(date))
Expand All @@ -35,7 +42,7 @@ describe('Contentful driven banners', () => {
.should((bannerText) => {
const yamlText = Cypress.$(banners[i].text).text().trim()

expect(utf8.encode(bannerText), `Banner #${i + 1} text is proper`).to.eq(yamlText)
expect(emojiStrip(bannerText), `Banner #${i + 1} text is proper`).to.eq(yamlText)
})

cy.wrap(banner)
Expand Down