Skip to content

Rework "requires" helper to support context and seeding of additional parameters #126

@jonathandavidson

Description

@jonathandavidson

In order to accommodate testing functions with more than one parameter, as well as functions that need to be called in a specific context, the requires helper will be modified to be used in the following way:

const assertions = requires( subject.functionUnderTest, subject )
    .arg(1).set( 'seed value 1'  )
    .arg(2).set( 'seed value 2'  )
    .arg(3).accepts( ‘object’, ‘array’ );

With the above example, the return value would be something similar to:

[
    { passed: true, message: 'object should not be accepted' },
    { passed: false, message: 'array should be accepted' },
    { passed: false, message: 'string should be accepted' }
]

This return value can then be iterated to form the assertions in whatever testing library is being used.

Closes #58
Closes #66

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions