UNPKG

blow-data-service

Version:

Observable data service for Blow.

52 lines (40 loc) 1.23 kB
/// <reference path="../typings/tsd.d.ts" /> 'use strict'; import * as chai from 'chai'; import {DataService} from '../src/DataService'; const expect = chai.expect; describe('DataService', () => { it('be class', () => { expect(DataService).to.be.an('function'); expect(new DataService({ default: { connector: 'memory' }})).to.be.instanceof(DataService); }); it('have static create()', () => { expect(DataService.create({ default: { connector: 'memory' }})).to.be.instanceof(DataService); }); describe('connectors by id', () => { let ds; before(() => { ds = DataService.create({}); ds.gc = function(n) { return this._getConnector(n); }; }); ['memory', 'mongodb'].forEach(id => { it(id, () => { expect(ds.gc(id)).to.be.an('function'); }); }); }); describe('get collection', () => { let ds; before(() => { ds = DataService.create({default: {connector: 'memory'}, second: {connector: 'memory'}}); }); it('for default connection', () => { expect(ds.collection('test')).to.be.ok; }); it('for connection by name', () => { expect(ds.collection('test', 'second')).to.be.ok; }); }); });