File: helpers.js

package info (click to toggle)
node-marked 0.8.0%2Bds%2Brepack-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,948 kB
  • sloc: javascript: 3,640; sh: 16; makefile: 16
file content (26 lines) | stat: -rw-r--r-- 787 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const marked = require('../../src/marked.js');
const htmlDiffer = require('./html-differ.js');

beforeEach(() => {
  marked.setOptions(marked.getDefaults());

  jasmine.addAsyncMatchers({
    toRender: () => {
      return {
        compare: async(spec, expected) => {
          const result = {};
          const actual = marked(spec.markdown, spec.options);
          result.pass = await htmlDiffer.isEqual(expected, actual);

          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;
        }
      };
    }
  });
});