1.0.0 • Published 8 years ago

tournesol v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

Tournesol

Build Status

A Hapi-Glue-Lab-Code tool that could only be created by a crazy scientist.

$ npm install tournesol

Purpose

This package aims at making api tests using Hapi, Lab and Code easier. The idea is to focus on what the tests mean rather than how to perform them.

Usage

const Lcrud = require( 'tournesol' ).Lcrud;

var request = new Lcrud(baseURL, getPayload, getHeaders);
const Tournesol = require( 'tournesol' );
const Lcrud = require( 'tournesol' ).Lcrud;
const Lab = require( 'lab' );
const lab = exports.lab = Lab.script();

const Server = require( 'A Hapi server' ); // require the hapi server to test or build it within the test file. 

const definition = {
        title: 'Title of the test with value of {pre.half1} + {input.itemId}',
        pre: [
            {
                assign: 'half1',
                name: 'half1 ( = 5)',
                method: function ( reply ) {

                    // no err
                    reply( null, 5 );
                }
            }
        ],
        paramSets: [
            {
                titleComplement: 'hello mommy',
                input: {
                    itemId: 5
                },
                output: {
                    statusCode: 200
                }
            },
            {
                input: {
                    itemId: 10
                },
                output: {
                    statusCode: 404
                }
            }
        ],
        inject: function ( pre, input ) {

            const request = new Lcrud( '/items', null, null );
            return request.get( null, null, input.itemId + pre.half1 );
        }
    };

    Tournesol.runTests(definition, Server, lab);

Doc

Please refer to:

  • Lcrud: List + CRUD, to generates requests for tests.
  • runTests: to run tests from a nice definition object.

About the name

Tournesol is the french name of the crazy professor in The Adventures of Tintin. You may know him by the name of Professor Calculus. This name was chosen since this package turns Lab into the home of a mad scientist.

1.0.0

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago

0.0.0

8 years ago