Skip to content

Instantly share code, notes, and snippets.

@wcravens
Last active July 18, 2019 23:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wcravens/8cebda50c572e7fc13765fba710980bc to your computer and use it in GitHub Desktop.
Save wcravens/8cebda50c572e7fc13765fba710980bc to your computer and use it in GitHub Desktop.
module test
/* jshint expr:true */
/* globals describe, it, beforeEach */
var chai = require( 'chai' )
, expect = chai.expect
;
var moduleNames = ['lib/recurringDateObjects'];
var moduleMethods = [];
moduleNames.map( ( moduleName ) => {
describe( 'Module Pattern: ' + moduleName, function () {
describe( 'initialization', () => {
var myTestModule = require( moduleName );
it( 'should have a messages property', () => {
expect( myTestModule ).to.have.property( 'messages' );
} );
it( 'should be an init function', () => {
expect( myTestModule ).to.be.a( 'function' );
} );
it( 'should throw if missing configuration on initialization', () => {
expect( () => myTestModule() ).to.throw( myTestModule.messages.mustProvideAnInitObject );
} );
it.skip( 'should be ok if object is passed on initialization.', function () {
//noinspection BadExpressionStatementJS
expect( require( moduleName )( {} ) ).to.be.ok;
} );
} );
describe.skip( 'initialized', () => {
before( function() {
var myTestModule = require( moduleName )( {} );
} );
moduleMethods.forEach( name => {
it( 'should provide a ' + name + ' function',
() => expect( myTestModule[name] ).to.be.a( 'function' ) );
} );
} );
} );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment