Skip to content

Commit

Permalink
chore: improve tests
Browse files Browse the repository at this point in the history
* realized that we should also check the arguments for the copy calls,
since those describe where images are, and where they need to go.
* as part of this, tests indicated the paths we were using had '//' in
them, so updated statements to use path.join().
  • Loading branch information
moonlight-komorebi committed Jun 21, 2021
1 parent b154ae7 commit 233d7ae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions scripts/actions/__tests__/fetch-and-deserialize.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ describe('writeFilesSync', () => {

it('should call copySync for each unique directory path', () => {
expect(fse.copySync).toHaveBeenCalledTimes(2);
expect(fse.copySync).toHaveBeenNthCalledWith(1, 'src/content/docs/fake_path_1/images', 'src/i18n/content/jp/docs/fake_path_1/images', { overwrite: true });
expect(fse.copySync).toHaveBeenNthCalledWith(2, 'src/content/docs/fake_path_2/images', 'src/i18n/content/jp/docs/fake_path_2/images', { overwrite: true });
});

it('should not copy directories that dont have images', () => {
Expand Down
6 changes: 3 additions & 3 deletions scripts/actions/fetch-and-deserialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ const writeFilesSync = (vfiles) => {
*/
if (
!(imageDirectory in copiedDirectories) &&
fse.existsSync(`src/content/${imageDirectory}`)
fse.existsSync(path.join('src/content/', imageDirectory))
) {
// sync 'src/content/docs/.../images' to 'src/i18n/content/.../docs/.../images'
fse.copySync(
`src/content/${imageDirectory}`,
`${path.dirname(file.path)}/images`,
path.join('src/content/', imageDirectory),
path.join(path.dirname(file.path), '/images'),
{
overwrite: true,
}
Expand Down

0 comments on commit 233d7ae

Please sign in to comment.