-
Notifications
You must be signed in to change notification settings - Fork 89
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
663/mk/standardize op client requests #971
Conversation
const openApiValidators = mockOpenApiResponseValidators() | ||
|
||
describe('createOutgoingPaymentRoutes', (): void => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed, since routes
describe block takes care of this
jest | ||
.spyOn(openApi, 'createResponseValidator') | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
.mockImplementation(mockResponseValidator as any) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we check that the spy is called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's already testing this (albeit indirectly): if the createResponseValidator
doesn't get the proper path
and method
when its called, the test will fail based on the expectation of true
on L57
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, the true
! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not the easiest to see when first reading it, but that was the best solution I could come up with to test the correct validator was passed in
interface RequestWithUrlArgs { | ||
url: string | ||
accessToken: string | ||
} | ||
|
||
interface PostArgs<T = undefined> { | ||
url: string | ||
body?: T | ||
accessToken: string | ||
} | ||
|
||
interface ListGetArgs { | ||
interface RequestWithPaymentPointerArgs { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of (Sub)ResourceRequestArgs
and CollectionRequestArgs
?
That might also somewhat future-proof this for
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, I like that better
@@ -41,6 +41,20 @@ export interface RouteDeps extends BaseDeps { | |||
logger: Logger | |||
} | |||
|
|||
export interface UnauthenticatedResourceRequestArgs { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a bit wordy given what this contains, but I like how the types read in the grant.ts
, where the first method (to create a grant) has UnauthenticatedResourceRequestArgs
, while all the other ones are ResourceRequestArgs
with the explicit accessToken
export interface ResourceRequestArgs { | ||
url: string | ||
accessToken: string | ||
} | ||
|
||
export interface CollectionRequestArgs { | ||
paymentPointer: string | ||
accessToken: string | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export interface ResourceRequestArgs { | |
url: string | |
accessToken: string | |
} | |
export interface CollectionRequestArgs { | |
paymentPointer: string | |
accessToken: string | |
} | |
interface AuthenticatedRequestArgs { | |
accessToken: string | |
} | |
export interface ResourceRequestArgs | |
extends UnauthenticatedResourceRequestArgs, | |
AuthenticatedRequestArgs {} | |
export interface CollectionRequestArgs extends AuthenticatedRequestArgs { | |
paymentPointer: string | |
} |
for (const key in override) { | ||
process.env[key] = override[key] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (const key in override) { | |
process.env[key] = override[key] | |
} | |
Object.assign(process.env, override) |
# Conflicts: # packages/open-payments/src/client/quote.ts # packages/open-payments/src/test/helpers.ts
@@ -35,29 +35,6 @@ describe('quote', (): void => { | |||
const paymentPointer = 'http://localhost:1000/.well-known/pay' | |||
const accessToken = 'accessToken' | |||
|
|||
describe('createQuoteRoutes', (): void => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
already tested via routes
describe block lower in the file
Changes proposed in this pull request
list
create
complete
requests to usepaymentPointer
as an argument instead ofurl
, e.g.:Context
Checklist
fixes #number