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
Creates wrapper for endpoint /post/sale #12
Conversation
@andremw I know that you will refactor my points! Take care, prefer use Remember to assign a return type for every function. nice job <3 |
Codecov Report
@@ Coverage Diff @@
## master #12 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 1 3 +2
Lines 2 26 +24
Branches 0 3 +3
=====================================
+ Hits 2 26 +24
Continue to review full report at Codecov.
|
I can't stand 4 spaces anymore in JS lol sry
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.
Man I still thinking that is best we move sales stuff to src/sales
and inside create types and index, but it's a minor! <3
orderBy: 0, | ||
}; | ||
|
||
const api = ({ |
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.
Why u not use ApiInstance previously?
it('POST to create a sale', async () => { | ||
const api = ({ | ||
post: jest.fn(), | ||
} as unknown) as ApiInstance; |
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.
why as unkown as ApiInstance?
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.
Because the compiler complains if I try to convert directly to ApiInstance, and it suggests that I first convert to unknown :(
test/index.spec.ts
Outdated
post: jest.fn(), | ||
} as unknown) as ApiInstance; | ||
|
||
await createSale(api)({ |
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.
all this guys was required? I think that this kind of test should test only one think:
Throws when something is required
Set default values when we need
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.
We can either test it like this or export the mapSale function and write a test for it.. But since mapSale doesn't make sense as a "public" function I think we can keep testing createSale like this.
I'm still waiting for the guys @ eNotas to tell me what the possible values for "quandoEmitirNFe", "meioPagamento", "deducoes" and their corresponding meaning so that we create better types for it instead of using type number.
Closes #3