chore: cleaned up repetative testing for dom
parent
f3b1fefba6
commit
cc734c7e7d
@ -1,3 +1,17 @@
|
||||
import assert from 'assert'
|
||||
import cheerio from 'cheerio'
|
||||
import HTML from '../fixtures/html'
|
||||
|
||||
export function clean(string) {
|
||||
return string.trim().replace(/\r?\n|\r/g, '').replace(/\s+/g, ' ')
|
||||
}
|
||||
|
||||
export function assertBeforeAndAfter(key, fn) {
|
||||
const $ = cheerio.load(HTML[key].before)
|
||||
assert.equal(clean(fn($).html()), clean(HTML[key].after))
|
||||
}
|
||||
|
||||
export function assertClean(a, b) {
|
||||
assert.equal(clean(a), clean(b))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue