1.0.0 • Published 8 years ago

chai-method v1.0.0

Weekly downloads
3
License
ISC
Repository
github
Last release
8 years ago

chai-method

Add new methods to help call methods from objects

var chai = require( 'chai' );
chai.use( require( 'chai-method' ) );

// Expect - Minimal usage
expect( obj )
	.method( 'method' )
	// .call( 'ok' ).result.equals( 'ok' )
	.args( 'ok' ).not.throw().result.equals( 'ok' )
	.args( 'Invalid argument' ).throws( Error );
	
// Expect - Long usage
expect( obj )
	.to.have.method( 'method' )
	// .that.calls( 'ok' ).with.result.that.equals( 'ok' )
	.that.with.args( 'ok' ).does.not.throw().and.has.a.result.that.equals('ok')
	.but.with.args( 'Invalid argument' ).throws( Error );

Methods

method( name )

Sets the property name of the object as a method to be called

args( ... )

Sets the arguments to the method saved

call( ... )

calls( ... )

Calls the saved method with the arguments given

result

Sets the current object as the result of the previous call

1.0.0

8 years ago