UNPKG

blow-query

Version:

Programmatically build queries which can be returned as JSON Object and used to fetch data from many sources.

43 lines (36 loc) 992 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?) { describe('init', () => { 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]); }); }) }); }); }); }