Skip to content

Commit

Permalink
Merge pull request #585 from paulRbr/parse-version-with-diff-properly
Browse files Browse the repository at this point in the history
diff: make sure to parse versions API response with any format diff
  • Loading branch information
paulRbr authored Nov 1, 2024
2 parents 8a77759 + d842447 commit 85531a7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/core/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ export class Diff {
isVersionWithDiff(
result: (VersionResponse & WithDiff) | DiffResponse,
): result is VersionResponse & WithDiff {
return (result as VersionResponse & WithDiff).diff_summary !== undefined;
const { diff_summary, diff_markdown, diff_details } = result as VersionResponse &
WithDiff;
return (diff_summary || diff_markdown || diff_details) !== undefined;
}

extractDiff(versionWithDiff: VersionResponse & WithDiff): DiffResponse {
Expand Down
34 changes: 34 additions & 0 deletions test/commands/diff.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,40 @@ describe('diff subcommand', () => {
},
);

test
.nock('https://bump.sh', (api) => {
api
.post(
'/api/v1/versions',
(body) => body.documentation === 'coucou' && !body.branch_name,
)
.once()
.reply(201, { id: '123', doc_public_url: 'http://localhost/doc/1' })
.get('/api/v1/versions/123')
.once()
.reply(202)
.get('/api/v1/versions/123')
.once()
.reply(200, { diff_details: [] });
})
.stdout()
.stderr()
.command([
'diff',
'examples/valid/openapi.v3.json',
'--doc',
'coucou',
'--format',
'json',
])
.it(
'asks for a diff to Bump and returns the newly created version (no content change)',
async ({ stdout, stderr }) => {
expect(stderr).to.eq('');
expect(stdout).to.contain('[]');
},
);

test
.nock('https://bump.sh', (api) => {
api
Expand Down

0 comments on commit 85531a7

Please sign in to comment.