lawrencec / Unroll

A helper tool to easily run the same tests against multiple data with verbose output.
16 stars 5 forks source link

Accept null or undefined as value. #52

Closed Blackbaud-IsaacAggrey closed 6 years ago

Blackbaud-IsaacAggrey commented 6 years ago

Current behavior:

unroll('should be okay with value being null or undefined when id is #id', (done, testArgs) => {
    let object = { id: testArgs.id };
    expect(object.id).toEqual(testArgs.id);
    done();
},
`
    where:
    id
    someRandomText
    ${null}
    ${undefined}
`
);

// Output:
    ✖ encountered a declaration exception
    Error: title not expanded as incorrect args passed in

Expected behavior:

✔ should be okay with value being null or undefined when id is null
✔ should be okay with value being null or undefined when id is undefined

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"), but I think the dataArray method should work as long as we are okay with stringifying those two values (in the general sense, not JSON.stringify as undefined is not a valid value).

Blackbaud-IsaacAggrey commented 6 years ago

Going to re-open as different account.