UNPKG

blow-collection

Version:

Simple in memory collection with Rx / Observable interface.

41 lines (34 loc) 947 B
'use strict'; import {isArray, isUndefined} from 'util'; import * as chai from 'chai'; const expect = chai.expect; export function getInstance(cls, args?) { if(!isUndefined(args)) { args = isArray(args) ? args : [args]; } else { args = []; } return new cls(...args); } export function checkClassExport(cls, args?) { it('export class', () => { expect(cls).to.be.an('function'); }); it('create instance', () => { expect(getInstance(cls, args)).to.be.instanceof(cls); }); } export function checkAttributes(cls, options) { describe('attributes', () => { Object.keys(options).forEach(type => { describe(type, () => { const instance = getInstance(cls, options[type].args); Object.keys(options[type].expected).forEach(attr => { it(attr, () => { expect(instance[attr]).to.be.equal(options[type].expected[attr]); }); }) }); }); }); }