Refactor EventModLookup and add tests#161
Conversation
bcd5593 to
16ae59a
Compare
|
|
||
| @module("assert") | ||
| external throws: (unit => 'a, ~error: Js.Exn.t, ~message: string=?) => unit = "throws" | ||
| external throws: (unit => 'a, ~error: Js.Exn.t=?, ~message: string=?) => unit = "throws" |
There was a problem hiding this comment.
I think this is correct? I didn't actually want to pass in the expected error.
There was a problem hiding this comment.
Yes, I think it's correct to have it optional. But the field is usually used to test error messages, which I think we should also do. But I'm not sure that the Js.Exn.t is correct here, for example in Ava.js I usually use you can pass a simple object with error assertions.
There was a problem hiding this comment.
Let's just type it 'error
https://nodejs.org/api/assert.html#assertthrowsfn-error-message
DZakh
left a comment
There was a problem hiding this comment.
Looks very good. And having tests for error messages will make it even better :)
| Event.handlerRegister->Types.HandlerTypes.Register.getEventOptions->(v => v.Types.HandlerTypes.wildcard) | ||
| Event.handlerRegister | ||
| ->Types.HandlerTypes.Register.getEventOptions | ||
| ->(v => v.Types.HandlerTypes.wildcard) |
There was a problem hiding this comment.
This is the first time I see the syntax 😁
There was a problem hiding this comment.
Haha, I don't really have too strong an opinion but thought it flows better than using round brackets around the whole statement and accessing .wildcard at the end. I might use it again.
|
|
||
| @module("assert") | ||
| external throws: (unit => 'a, ~error: Js.Exn.t, ~message: string=?) => unit = "throws" | ||
| external throws: (unit => 'a, ~error: Js.Exn.t=?, ~message: string=?) => unit = "throws" |
There was a problem hiding this comment.
Yes, I think it's correct to have it optional. But the field is usually used to test error messages, which I think we should also do. But I'm not sure that the Js.Exn.t is correct here, for example in Ava.js I usually use you can pass a simple object with error assertions.
|
|
||
| @module("assert") | ||
| external throws: (unit => 'a, ~error: Js.Exn.t, ~message: string=?) => unit = "throws" | ||
| external throws: (unit => 'a, ~error: Js.Exn.t=?, ~message: string=?) => unit = "throws" |
There was a problem hiding this comment.
Let's just type it 'error
https://nodejs.org/api/assert.html#assertthrowsfn-error-message
| Assert.throws( | ||
| () => { | ||
| Error({eventMod, errorKind})->EventModLookup.unwrapAddEventResponse(~chain=mockChain) | ||
| }, | ||
| ) |
There was a problem hiding this comment.
| Assert.throws( | |
| () => { | |
| Error({eventMod, errorKind})->EventModLookup.unwrapAddEventResponse(~chain=mockChain) | |
| }, | |
| ) | |
| Assert.throws( | |
| () => { | |
| Error({eventMod, errorKind})->EventModLookup.unwrapAddEventResponse(~chain=mockChain) | |
| }, | |
| ~error={ | |
| "message": "I don't know what, but it should be tested" | |
| } | |
| ) |
There was a problem hiding this comment.
Also, it'll require to remove forEach
3637044 to
dc60a23
Compare
Co-authored-by: Dmitry Zakharov <dzakh.dev@gmail.com>
dc60a23 to
222a817
Compare
Uh oh!
There was an error while loading. Please reload this page.