-
Notifications
You must be signed in to change notification settings - Fork 5
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
Accept null or undefined as value #53
Comments
Hey @isaacaggrey, Thanks for reporting the bug! I agree this should be supported. I have a fix for both the array and datatable notations using Symbols. So for example, your dataTable example will look like this: unroll('should be okay with id being #id', (done, testArgs) => {
let object = { id: testArgs.id };
expect(object.id).toEqual(testArgs.id);
done();
},
`
where:
id
${Symbol.keyFor(unroll.NULL)}
${Symbol.keyFor(unroll.UNDEFINED)}
`
); and the array notation: unroll('should be okay with id being #id', (done, testArgs) => {
let object = { id: testArgs.id };
expect(object.id).toEqual(testArgs.id);
done();
},
[
['id']
[null],
[undefined],
[Unroll.NULL],
[Unroll.UNDEFINED],
] Admittedly, the dataTable example is ugly (though one could argue it's a little messy anyway cos of the need for JSON.stringify), this is because unroll needs to know that the undefined is intentional so a placeholder replacement has to be used as an identifier. And I'd like to keep functional parity between the two notations; I wouldn't want to be able to use But I don't think there is an easier way of representing Would be interested in your thoughts and preferences as an end user. AFAIK, I'm the main user of the util so would be good to get other users opinion before I push this. |
@lawrencec any plans to merge this PR? |
Current behavior:
Expected behavior:
Granted, I understand with the dataTable method this is a bit tricky since it is a template literal (i.e., what if someone wants to test the string "null" or "undefined", not sure what is expected behavior), but I think the dataArray method should be valid.
The text was updated successfully, but these errors were encountered: