-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: handle relative images present in articles
- Loading branch information
1 parent
c8424e5
commit df066c3
Showing
5 changed files
with
103 additions
and
12 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,11 @@ | ||
![Adriana Varejão Gallery](../images/varejao.jpeg) | ||
|
||
_Adriana Varejão Gallery_ | ||
|
||
![Valeska Soares Gallery](http://valeskasoares.net/wp-content/uploads/2009/10/DSC8218.jpg) | ||
|
||
_Valeska Soares Gallery_ | ||
|
||
![Sonic Pavillion](https://www.inhotim.org.br/wp-content/webp-express/webp-images/uploads/2021/02/CAPA_02042021DSC07311Joao_Kehl_.jpg.webp) | ||
|
||
_Sonic Pavillion_ |
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,32 @@ | ||
const path = require('path'); | ||
const configService = require('./config'); | ||
const { fileService } = require('./file'); | ||
const articleService = require('./article'); | ||
|
||
describe('Articles Service', () => { | ||
function mockTrivenConfig(){ | ||
const config = { | ||
sourceDirectory: path.join(__dirname, '../mocks'), | ||
outputDirectory: path.join(process.cwd(), './triven') | ||
}; | ||
configService.get = jest.fn(() => config); | ||
return config; | ||
} | ||
|
||
beforeEach(() => { | ||
fileService.copySync = jest.fn(); | ||
}); | ||
|
||
it('should copy relative images to assets directory and update its source in markup', () => { | ||
const { outputDirectory } = mockTrivenConfig(); | ||
const filepath = path.join(__dirname, '../mocks/images.md'); | ||
const { article } = articleService.build(filepath); | ||
const expectedFilename = 'varejao-a8774002d2f7fef27b27f665c7e7227c.jpeg'; | ||
expect(article).toContain(`<img src="assets/${expectedFilename}" alt="Adriana Varejão Gallery">`); | ||
expect(fileService.copySync).toHaveBeenCalledTimes(1); | ||
expect(fileService.copySync).toHaveBeenCalledWith( | ||
`${path.join(__dirname, '../images/varejao.jpeg')}`, | ||
`${outputDirectory}/assets/${expectedFilename}` | ||
); | ||
}); | ||
}); |
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