-
-
Notifications
You must be signed in to change notification settings - Fork 113
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
remove requirement for providing a message #260
Conversation
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.
This looks great. Just one comment on the test and we should be good!
set(service, 'defaultPreventDuplicates', true); | ||
|
||
assert.throws((() => { | ||
service.add({ }); |
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.
I think assert.throws
is the right solution to test this. However, you seem to be getting a false positive. If you change this line to service.add({ message: 'foo' })
your test will still pass. I think this is due to the wrapped function.
I think you will want something like this:
assert.throws(() => {
service.add({ });
},
({ message }) => {
return message == 'Assertion Failed: The flash message cannot be empty when preventDuplicates is enabled.';
},
'Error is thrown'
);
assert.throws
can take 3 arguments. If you pass it only 2, the second is simply the assertion description, so it was not matching the error text here.
The second argument should be a function that accepts the error object and returns true or false. Give the above example a try and you should see it passes with no message and fails with one.
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, thanks for catching that. Should all be fixed now :)
customProperty: 'ohai' | ||
}); | ||
|
||
assert.equal(get(service, 'queue.0.customProperty'), 'ohai'); |
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.
Minor nitpick, but rather than queue.0
could we do queue.firstObject
? I feel it reads just a bit more clear
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, done :)
Awesome! |
fixes #259
I figured it would be reasonable to keep the
message
property required whenpreventDuplicates
is enabled as that feature relies on the message string.Please let me know or feel free to modify the added test, if you know of any better way to assert a thrown error than that: