Skip to content

Commit

Permalink
test: should prepend root to image path
Browse files Browse the repository at this point in the history
  • Loading branch information
curbengh committed Sep 8, 2019
1 parent 454081a commit 00fc61a
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,43 @@ describe('Marked renderer', () => {
].join('\n'));
});
});

describe('prependRoot option tests', () => {
const body = [
'![](/bar/baz.jpg)',
'![foo](/aaa/bbb.jpg)',
].join('\n');

const renderer = require('../lib/renderer');

const ctx = {
config: {
marked: {
prependRoot: false
},
root: '/blog/'
}
};

it('should not modify image path with default option', () => {
const r = renderer.bind(ctx);
const result = r({text: body});

result.should.eql([
'<p><img src="/bar/baz.jpg" alt="">',
'<img src="/aaa/bbb.jpg" alt="foo"></p>\n',
].join('\n'));
});

it('should prepend image path with root', () => {
ctx.config.marked.prependRoot = true;
const r = renderer.bind(ctx);
const result = r({text: body});

result.should.eql([
'<p><img src="/blog/bar/baz.jpg" alt="">',
'<img src="/blog/aaa/bbb.jpg" alt="foo"></p>\n',
].join('\n'));
});
});
});

0 comments on commit 00fc61a

Please sign in to comment.