Skip to content
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

Enhancement: Added validation to include #84

Merged
merged 4 commits into from
Aug 28, 2016
Merged

Conversation

blacksun1
Copy link
Contributor

Added an extra assertion to check that the include expectation is always
called with just one argument.

Fixes: #83

Added an extra assertion to check that the include expectation is always
called with just one argument.

Fixes: hapijs#83
@@ -2297,7 +2320,8 @@ describe('incomplete()', () => {

const a = Code.expect(1).to;
Code.expect(2).to.equal(2);
Hoek.assert(Code.incomplete().length === 1);
const actual = Code.incomplete();
Hoek.assert(actual.length === 1, actual);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that just showing actual is any more meaningful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, didn't mean to make this change. I'll revert it.

Fix as per [Pull request 84](hapijs#84)
@@ -1124,6 +1124,52 @@ describe('expect()', () => {
Hoek.assert(!exception, exception);
done();
});

const tests = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't what I meant. One it() block. No tests array. No loop. You can just use curly braces to define a scope and do a simple test inside of it so you can reuse the same variable names. See https://github.com/nodejs/node/blob/4a408321d9c4a6964c9d89a0dd09067f36b4dbfc/test/parallel/test-vm-debug-context.js#L34-L72 as an example.

Second refactor to fix tests as per
[Pull request 84](hapijs#84)
Hoek.assert(exception.message === 'Can only assert include with a single parameter', exception);
}

{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this second test can be dropped, as the functionality is tested elsewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cjihrig Done.

@cjihrig
Copy link
Contributor

cjihrig commented Aug 27, 2016

One last comment, then this is good to go.

> I think this second test can be dropped, as the functionality is
> tested elsewhere.
> --cjihrig
@cjihrig cjihrig added the feature New functionality or improvement label Aug 28, 2016
@cjihrig cjihrig added this to the 4.0.0 milestone Aug 28, 2016
@cjihrig cjihrig self-assigned this Aug 28, 2016
@cjihrig cjihrig merged commit 4978bdd into hapijs:master Aug 28, 2016
@cjihrig cjihrig mentioned this pull request Sep 19, 2016
@lock
Copy link

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature New functionality or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include should validate number of arguments
2 participants