test: add helper toDeepEqual for strict html equal
This commit is contained in:
parent
1ddf982aa3
commit
fbbdcc8dd5
@ -1,5 +1,6 @@
|
||||
const marked = require('../../src/marked.js');
|
||||
const htmlDiffer = require('./html-differ.js');
|
||||
const assert = require('assert').strict;
|
||||
|
||||
beforeEach(() => {
|
||||
marked.setOptions(marked.getDefaults());
|
||||
@ -37,6 +38,21 @@ beforeEach(() => {
|
||||
return result;
|
||||
}
|
||||
};
|
||||
},
|
||||
toDeepEqual: () => ({
|
||||
compare: async(spec, expected) => {
|
||||
const result = {};
|
||||
const actual = marked(spec.markdown, spec.options);
|
||||
result.pass = assert.deepStrictEqual(expected, actual) === undefined;
|
||||
|
||||
if (result.pass) {
|
||||
result.message = `${spec.markdown}\n------\n\nExpected: Should Fail`;
|
||||
} else {
|
||||
const diff = await htmlDiffer.firstDiff(actual, expected);
|
||||
result.message = `Expected: ${diff.expected}\n Actual: ${diff.actual}`;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user