mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-16 15:45:13 +00:00
Update tests for relative images
This commit is contained in:
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
# Images Test
|
||||
|
||||
This is a test for images path calculation. It supposed this fiel is in a syntax/ folder
|
||||
|
||||
### #
|
||||
|
||||
[](./preview.png)
|
||||
|
||||
### 2
|
||||
|
||||
[](./preview2.png)
|
||||
|
||||
+30
-4
@@ -36,10 +36,6 @@ describe('Page parsing', function() {
|
||||
assert(LEXED[2].content);
|
||||
});
|
||||
|
||||
it('should make image URLs relative', function() {
|
||||
assert(LEXED[2].content.indexOf('_book/assets/my-pretty-picture.png') !== -1);
|
||||
});
|
||||
|
||||
it('should gen code and content for exercise sections', function() {
|
||||
assert(LEXED[1].content);
|
||||
assert(LEXED[1].code);
|
||||
@@ -94,3 +90,33 @@ describe('Relative links', function() {
|
||||
assert(LEXED[0].content.indexOf('https://github.com/GitBookIO/javascript/blob/src/something.cpp') !== -1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Relative images', function() {
|
||||
it('should keep image relative with considering output directory in site format', function() {
|
||||
var LEXED = loadPage('IMAGES', {
|
||||
// GitHub repo ID
|
||||
repo: 'GitBookIO/javascript',
|
||||
|
||||
// Imaginary folder of markdown file
|
||||
dir: 'syntax',
|
||||
outdir: 'syntax'
|
||||
});
|
||||
|
||||
assert(LEXED[0].content.indexOf('"preview.png"') !== -1);
|
||||
assert(LEXED[0].content.indexOf('"../preview2.png"') !== -1);
|
||||
});
|
||||
|
||||
it('should keep image relative with considering output directory in page format', function() {
|
||||
var LEXED = loadPage('IMAGES', {
|
||||
// GitHub repo ID
|
||||
repo: 'GitBookIO/javascript',
|
||||
|
||||
// Imaginary folder of markdown file
|
||||
dir: 'syntax',
|
||||
outdir: './'
|
||||
});
|
||||
|
||||
assert(LEXED[0].content.indexOf('"syntax/preview.png"') !== -1);
|
||||
assert(LEXED[0].content.indexOf('"preview2.png"') !== -1);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user