UNPKG

@schukai/monster

Version:

Monster is a simple library for creating fast, robust and lightweight websites.

60 lines (42 loc) 1.78 kB
"use strict"; import {expect} from "chai" import {Datasource} from "../../../source/data/datasource.mjs"; describe('Datasource', function () { it('should instance of Datasource ', function () { expect(new Datasource()).to.be.instanceof(Datasource) }); describe('Options', function () { it('setOption should change value', function () { const datasource = new Datasource(); expect(datasource.getOption('default')).to.be.undefined datasource.setOption('default', true) expect(datasource.getOption('default')).to.be.true }); it('setOptions should set all values', function () { const datasource = new Datasource(); expect(datasource.getOption('default')).to.be.undefined datasource.setOptions({default: true}) expect(datasource.getOption('default')).to.be.true }); }) describe('rw', function () { const datasource = new Datasource(); it('read should throw exeption', function () { expect(() => datasource.read()).to.throw(Error); }); it('write should throw exeption', function () { expect(() => datasource.read()).to.throw(Error); }); }) describe('get/set', function () { const datasource = new Datasource(); it('get should return undefined', function () { expect( datasource.get()).to.be.eql({}); }); it('write should throw exeption', function () { expect( datasource.get()).to.be.eql({}); expect( datasource.set({a:'myvalue'})).to.be.instanceof(Datasource); expect( datasource.get()).to.be.eql({a:'myvalue'}); }); }) })