UNPKG

@schukai/monster

Version:

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

63 lines (38 loc) 1.34 kB
import {expect} from "chai" import {Factory} from "../../../../source/dom/worker/factory.mjs"; import {getGlobal} from "../../../../source/types/global.mjs"; import {initJSDOM, isNode} from "../../../util/jsdom.mjs"; const global = getGlobal(); describe('Worker', function () { before(function (done) { if (isNode()) { Object.defineProperty(global['URL'], 'createObjectURL', { writable: true, value: () => { return "/example.mjs" } }) global['Worker'] = class { terminate() { } onerror() { } onmessage() { } } let a = typeof global['Worker']; let a1 = typeof Worker; } const jsdom = initJSDOM().then(() => { done(); }); }) describe('Factory', function () { it('create worker', function () { const factory = new Factory(); const worker = factory.createFromScript('console.log("hello world");') expect(worker).is.instanceof(Worker); expect(factory.terminate(worker)).is.instanceof(Factory) }); }); });