webextensions-api-mock
Version:
WebExtensions API as sinon stubs
27 lines (26 loc) • 936 B
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const sinon_1 = __importDefault(require("sinon"));
const stub_walker_1 = require("./stub-walker");
class BrowserGenerator {
constructor(namespaces) {
this.sandbox = sinon_1.default.createSandbox();
this.aliases = new Map();
this.browser = {
sinonSandbox: this.sandbox,
};
this.namespaces = namespaces;
}
out() {
const schemaWalker = new stub_walker_1.BrowserSchemaWalker(this.sandbox, this.aliases, this.browser);
schemaWalker.walk(this.namespaces);
this.aliases.forEach((to, from) => {
this.browser[from] = this.browser[to];
});
return this.browser;
}
}
exports.BrowserGenerator = BrowserGenerator;