Skip to content

Commit

Permalink
feat: add method $getOAuth2Response to javascript context (#499)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnWeber committed Jul 14, 2023
1 parent 7098487 commit 289f821
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 17 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [unreleased]

### Features

- add method `$getOAuth2Response` to javascript context (#499)

## [6.5.1] (2023-06-13)

### Fixes
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"filesize": "^10.0.7",
"globby": "^13.2.2",
"got": "^11.8.6",
"hookpoint": "^3.2.0",
"hookpoint": "3.2.1",
"http-proxy-agent": "^7.0.0",
"https-proxy-agent": "^7.0.1",
"inquirer": "^9.2.8",
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/oauth2/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import * as models from '../../models';
import { oauth2VariableReplacer } from './oauth2VariableReplacer';
import { oauth2VariableReplacer, getOAuth2Response } from './oauth2VariableReplacer';

export function registerOAuth2Plugin(api: models.HttpyacHooksApi) {
api.hooks.replaceVariable.addHook('oauth2', oauth2VariableReplacer);
api.hooks.provideVariables.addHook('oauth2', () => ({
$getOAuth2Response: getOAuth2Response,
}));
}
16 changes: 5 additions & 11 deletions src/test/variables/pick.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('variables.pick', () => {
it('pick', async () => {
initFileProvider();
const spy = jest.spyOn(userInteractionProvider, 'showListPrompt');
const variables = {};
const variables: Record<string, unknown> = {};

await sendHttp(
`
Expand All @@ -17,15 +17,12 @@ describe('variables.pick', () => {
);

expect(spy).toHaveBeenCalledWith('pick me?', ['foo', 'bar']);
expect(variables).toEqual({
$global: {},
var1: 'foo',
});
expect(variables.var1).toBe('foo');
});
it('pick-askonce', async () => {
initFileProvider();
const spy = jest.spyOn(userInteractionProvider, 'showListPrompt');
const variables = {};
const variables: Record<string, unknown> = {};

await sendHttp(
`
Expand All @@ -36,10 +33,7 @@ describe('variables.pick', () => {
);

expect(spy).toHaveBeenCalledWith('ask-once?', ['foo', 'bar']);
expect(variables).toEqual({
$global: {},
var1: 'foo',
var2: 'foo',
});
expect(variables.var1).toEqual('foo');
expect(variables.var2).toEqual('foo');
});
});

0 comments on commit 289f821

Please sign in to comment.