Skip to content

Commit a37b4bc

Browse files
committed
chore(next): add test for confirm overwrite usage
1 parent 56441c7 commit a37b4bc

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

__tests__/commands/openapi/upload.test.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import nock from 'nock';
22
import prompts from 'prompts';
33
import slugify from 'slugify';
4-
import { describe, beforeAll, beforeEach, afterEach, it, expect } from 'vitest';
4+
import { afterEach, beforeAll, beforeEach, describe, expect, it } from 'vitest';
55

66
import Command from '../../../src/commands/openapi/upload.js';
77
import petstore from '../../__fixtures__/petstore-simple-weird-version.json' with { type: 'json' };
@@ -401,4 +401,26 @@ describe('rdme openapi upload', () => {
401401
fileMock.done();
402402
});
403403
});
404+
405+
describe('given that the confirm overwrite flag is passed', () => {
406+
it('should overwrite an existing API definition without asking for confirmation', async () => {
407+
const mock = getAPIv2Mock({ authorization: `Bearer ${key}` })
408+
.get(`/versions/${version}/apis`)
409+
.reply(200, { data: [{ filename: slugifiedFilename }] })
410+
.put(`/versions/${version}/apis/${slugifiedFilename}`, body =>
411+
body.match(`form-data; name="schema"; filename="${slugifiedFilename}"`),
412+
)
413+
.reply(200, {
414+
data: {
415+
upload: { status: 'done' },
416+
uri: `/versions/${version}/apis/${slugifiedFilename}`,
417+
},
418+
});
419+
420+
const result = await run(['--version', version, filename, '--key', key, '--confirm-overwrite']);
421+
expect(result.stdout).toContain('was successfully updated in ReadMe!');
422+
423+
mock.done();
424+
});
425+
});
404426
});

0 commit comments

Comments
 (0)