-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: automatically remap local images to remote ones when publishing
- Loading branch information
1 parent
41ca271
commit c0b1797
Showing
8 changed files
with
136 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Article } from './article'; | ||
import { Repository } from './dev-to-git.interface'; | ||
|
||
describe(`Article`, () => { | ||
let article: Article; | ||
const repository: Repository = { username: `maxime1992`, name: 'dev-to-git' }; | ||
const relativePathToArticle = `./test/article.md`; | ||
|
||
beforeEach(() => { | ||
article = new Article({ | ||
id: 0, | ||
relativePathToArticle, | ||
repository, | ||
}); | ||
}); | ||
|
||
describe(`Read`, () => { | ||
let articleRead: string; | ||
|
||
beforeEach(() => { | ||
articleRead = article.readArticleOnDisk(); | ||
}); | ||
|
||
it(`should read an article from the configuration`, () => { | ||
expect(articleRead).toContain(`This is my awesome article!`); | ||
expect(articleRead).toContain(`Hey, some text!`); | ||
}); | ||
|
||
it(`should rewrite the local images URLs to match the raw file on github`, () => { | ||
expect(articleRead).toContain( | ||
`Image 1: ![alt text 1](https://raw.githubusercontent.com/${repository.username}/${repository.name}/master/test/image-1.png 'Title image 1')`, | ||
); | ||
|
||
expect(articleRead).toContain( | ||
`Image 2: ![alt text 2](https://raw.githubusercontent.com/${repository.username}/${repository.name}/master/test/image-2.png 'Title image 2')`, | ||
); | ||
|
||
expect(articleRead).toContain( | ||
`Image 3: ![alt text 3](https://raw.githubusercontent.com/${repository.username}/${repository.name}/master/test/image-3.png)`, | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters