Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(breaking): always return array #225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/fixtures/runCustomFixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const runCustomFixtures = ({ targetId, clientId, tests }: CustomFixture)
}

const snippet = new HTTPSnippet(request, opts);
const result = snippet.convert(targetId, clientId, options);
const result = snippet.convert(targetId, clientId, options)[0];
const filePath = path.join(__dirname, '..', 'targets', targetId, clientId, 'fixtures', fixtureFile);
if (process.env.OVERWRITE_EVERYTHING) {
writeFileSync(filePath, String(result));
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,6 @@ export class HTTPSnippet {

const { convert } = target.clientsById[clientId || target.info.default];
const results = this.requests.map(request => convert(request, options));
return results.length === 1 ? results[0] : results;
return results;
}
}
10 changes: 5 additions & 5 deletions src/targets/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ describe('request validation', () => {
`${fixture}${extname(targetId, clientId)}`,
);

let result;
let expected;
let result: string[] | false;
let expected: string;

try {
const options: HTTPSnippetOptions = {};
Expand All @@ -88,7 +88,7 @@ describe('request validation', () => {
expected = readFileSync(expectedPath).toString();
const snippet = new HTTPSnippet(request, options);

result = snippet.convert(targetId, clientId);
result = snippet.convert(targetId, clientId)[0];

if (OVERWRITE_EVERYTHING && result) {
writeFileSync(expectedPath, String(result));
Expand Down Expand Up @@ -313,7 +313,7 @@ describe('addTargetClient', () => {

const snippet = new HTTPSnippet(short.log.entries[0].request as Request, {});

const result = snippet.convert('node', 'custom');
const result = snippet.convert('node', 'custom')[0];

expect(result).toBe('This was generated from a custom client.');
});
Expand Down Expand Up @@ -345,7 +345,7 @@ describe('addClientPlugin', () => {

const snippet = new HTTPSnippet(short.log.entries[0].request as Request, {});

const result = snippet.convert('node', 'custom');
const result = snippet.convert('node', 'custom')[0];

expect(result).toBe('This was generated from a custom client.');
});
Expand Down