@schukai/monster
Version:
Monster is a simple library for creating fast, robust and lightweight websites.
59 lines (45 loc) • 1.79 kB
JavaScript
;
import {getDocumentFragmentFromString} from "../../../source/dom/util.mjs";
import {initJSDOM} from "../../util/jsdom.mjs";
import {expect} from "chai"
import {Theme, getDocumentTheme} from "../../../source/dom/theme.mjs";
describe('Theme', function () {
before(function (done) {
initJSDOM().then(() => {
done()
});
});
describe('new Theme()', function () {
it('should return Theme object', function () {
expect(new Theme('my-theme')).is.a.instanceOf(Theme);
});
it('should return Theme-Name', function () {
expect(new Theme('my-theme').getName()).is.equal('my-theme');
});
it('should throw Error because empty argument', function () {
expect(() => new Theme()).to.throw(TypeError)
});
it('should throw Error because no string argument', function () {
expect(() => new Theme(2)).to.throw(TypeError)
});
});
describe('getDocumentTheme()', function () {
it('should return Theme object', function () {
expect(getDocumentTheme()).is.a.instanceOf(Theme);
});
it('should return Default Theme name', function () {
expect(getDocumentTheme().getName()).is.equal('monster');
});
});
describe('getDocumentTheme()', function () {
beforeEach(() => {
document.querySelector('html').setAttribute('data-monster-theme-name', 'testtheme');
})
afterEach(() => {
document.querySelector('html').removeAttribute('data-monster-theme-name');
})
it('should return testtheme Theme name', function () {
expect(getDocumentTheme().getName()).is.equal('testtheme');
});
});
});