2019-03-09 23:39:50 -06:00
|
|
|
const marked = require('../../');
|
2019-03-13 08:50:11 -05:00
|
|
|
const htmlDiffer = require('./html-differ.js');
|
2019-03-11 11:20:33 -05:00
|
|
|
|
2019-03-11 11:12:46 -05:00
|
|
|
beforeEach(() => {
|
2018-04-10 07:53:59 -05:00
|
|
|
marked.setOptions(marked.getDefaults());
|
2019-03-09 23:39:50 -06:00
|
|
|
|
|
|
|
jasmine.addMatchers({
|
2019-03-11 11:12:46 -05:00
|
|
|
toRender: () => {
|
2019-03-09 23:39:50 -06:00
|
|
|
return {
|
2019-03-11 11:12:46 -05:00
|
|
|
compare: (spec, expected) => {
|
2019-03-09 23:39:50 -06:00
|
|
|
const result = {};
|
|
|
|
const actual = marked(spec.markdown, spec.options);
|
|
|
|
result.pass = htmlDiffer.isEqual(expected, actual);
|
|
|
|
|
|
|
|
if (result.pass) {
|
|
|
|
result.message = spec.markdown + '\n------\n\nExpected: Should Fail';
|
|
|
|
} else {
|
2019-03-13 08:50:11 -05:00
|
|
|
const diff = htmlDiffer.firstDiff(actual, expected);
|
|
|
|
result.message = 'Expected: ' + diff.expected + '\n Actual: ' + diff.actual;
|
2019-03-09 23:39:50 -06:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
});
|
2018-04-09 21:45:37 -05:00
|
|
|
});
|