BDD Tests
describe( "Tests of TestBox behaviour", () => {
it( "rejects 5 as being between 1 and 10", () => {
expect( () => {
expect( 5 ).notToBeBetween( 1, 10 );
} ).toThrow();
} );
it( "rejects 10 as being between 1 and 10", () => {
expect( () => {
expect( 10 ).notToBeBetween( 1, 10 );
} ).toThrow();
} );
} );
feature( "Given-When-Then test language support", () => {
scenario( "I want to be able to write tests using Given-When-Then language", () => {
given( "I am using TestBox", () => {
when( "I run this test suite", () => {
then( "it should be supported", () => {
expect( true ).toBe( true );
} );
} );
} );
} );
} );
story( "I want to list all authors", () => {
given( "no options", () => {
then( "it can display all active system authors", () => {
var event = this.get( "/cbapi/v1/authors" );
expect( event.getResponse() ).toHaveStatus( 200 );
expect( event.getResponse().getData() ).toBeArray().notToBeEmpty();
event
.getResponse()
.getData()
.each( function( thisItem ){
expect( thisItem.isActive ).toBeTrue( thisItem.toString() );
} );
} );
} );
given( "isActive = false", () => {
then( "it should display inactive users", () => {
var event = this.get( "/cbapi/v1/authors?isActive=false" );
expect( event.getResponse() ).toHaveStatus( 200 );
expect( event.getResponse().getData() ).toBeArray().notToBeEmpty();
event
.getResponse()
.getData()
.each( function( thisItem ){
expect( thisItem.isActive ).toBeFalse( thisItem.toString() );
} );
} );
} );
given( "a search criteria", () => {
then( "it should display searched users", () => {
var event = this.get( "/cbapi/v1/authors?search=tester" );
expect( event.getResponse() ).toHaveStatus( 200 );
expect( event.getResponse().getData() ).toBeArray().notToBeEmpty();
} );
} );
} );Was this helpful?