Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
test: add Commonjs backwards compatibility test
  • Loading branch information
aminya committed Oct 16, 2023
commit ff24a0695da5b3168a1f6586a68821b1cf330afc
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"ignorePatterns": ["lib/*.cjs"],
"parser": "@babel/eslint-parser",
"rules": {
"import/no-commonjs": "error",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"prepare": "husky install && npm run build",
"version": "conventional-changelog -i changelog.md -s -r 0 && git add changelog.md",
"lint": "eslint --fix lib/*.mjs test/*.mjs",
"test": "npm run lint && c8 mocha",
"test": "npm run build && npm run lint && c8 mocha",
"docs:api": "jsdoc2md lib/api.js > docs/api.md",
"docs:core": "jsdoc2md lib/index.js > docs/core.md"
},
Expand Down
24 changes: 24 additions & 0 deletions test/test.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* eslint-disable import/no-commonjs */

const { it, describe } = require('mocha')
const { expect } = require('chai')

const posthtml = require('../lib/index.cjs')

const input = '<div class="button"><div class="button__text">Text</div></div>'

function test (html, done) {
posthtml()
.process(html)
.then(result => {
expect(input).to.eql(result.html)
done()
})
.catch(error => done(error))
}

describe('[Commonjs] Simple text', () => {
it('html eqval', done => {
test(input, done)
})
})