Skip to content

Commit

Permalink
Rename test flles
Browse files Browse the repository at this point in the history
To match with airbnb's expected path naming conversions. Solves the false possitive on the "import/no-extraneous-dependencies" rule
  • Loading branch information
vidhu committed Oct 25, 2021
1 parent 5420015 commit c1d4a03
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const mjml = require('../lib/index.js')
const chai = require('chai')
const cheerio = require('cheerio')
const { sortBy } = require('lodash')
const mjml = require('../lib')

const input = `
<mjml>
Expand Down Expand Up @@ -35,23 +35,31 @@ const input = `
</mjml>
`

const html = mjml(input).html
const { html } = mjml(input)
const $ = cheerio.load(html)

// should put the attributes at the right place
chai.expect(
$('.text div').map(function getAttr() {
return $(this).attr('data-id')
}).get(),
'Custom attributes added on texts',
).to.eql(['42', '42'])
chai
.expect(
$('.text div')
.map(function getAttr() {
return $(this).attr('data-id')
})
.get(),
'Custom attributes added on texts',
)
.to.eql(['42', '42'])

chai.expect(
$('.image td').map(function getAttr() {
return $(this).attr('data-name')
}).get(),
'Custom attributes added on image',
).to.eql(['43'])
chai
.expect(
$('.image td')
.map(function getAttr() {
return $(this).attr('data-name')
})
.get(),
'Custom attributes added on image',
)
.to.eql(['43'])

// should not alter templating syntax, or move the content that is outside any tag (mj-raws)
const expected = [
Expand All @@ -63,14 +71,8 @@ const expected = [
'{ end if }',
'{ item + 1 }',
]
const indexes = expected.map(str => html.indexOf(str))
const indexes = expected.map((str) => html.indexOf(str))

chai.expect(
indexes,
'Templating syntax unaltered',
).to.not.include(-1)
chai.expect(indexes, 'Templating syntax unaltered').to.not.include(-1)

chai.expect(
sortBy(indexes),
'Mj-raws kept same positions',
).to.deep.eql(indexes)
chai.expect(sortBy(indexes), 'Mj-raws kept same positions').to.deep.eql(indexes)
4 changes: 2 additions & 2 deletions packages/mjml/test/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
require('./test-html-attributes')
require('./test-lazy-head-style')
require('./html-attributes.test')
require('./lazy-head-style.test')
File renamed without changes.

0 comments on commit c1d4a03

Please sign in to comment.