Files
elink-test-master/ApiTestManager/src/index.js
T
2024-02-19 12:59:05 +09:00

53 lines
1.6 KiB
JavaScript

import APITester from './APITester';
import APIScenario from './APIScenario';
import LoadTestManager from './LoadTestManager';
window.MonacoEnvironment = {
getWorkerUrl: function(moduleId, label) {
let contextPath = document.querySelector(
'meta[name="context-path"]').getAttribute('content');
if (!contextPath) {
contextPath = '/';
}
if (!contextPath.endsWith('/')) {
contextPath += '/';
}
if (label === 'json') {
return contextPath + 'plugins/apitestmanager/json.worker.bundle.js';
}
if (label === 'css' || label === 'scss' || label === 'less') {
return contextPath + 'plugins/apitestmanager/css.worker.bundle.js';
}
if (label === 'html' || label === 'handlebars' || label === 'razor') {
return contextPath + 'plugins/apitestmanager/html.worker.bundle.js';
}
if (label === 'typescript' || label === 'javascript') {
return contextPath + 'plugins/apitestmanager/ts.worker.bundle.js';
}
return contextPath + 'plugins/apitestmanager/editor.worker.bundle.js';
}
};
export default class APITestManager {
constructor(options = {}) {
if (options.type === undefined) {
options.type = 'api';
}
if (options.type === 'api') {
this.apiTester = new APITester(options.contextPath);
this.apiTester.init(options.servers);
this.apiScenario = new APIScenario(this.apiTester, options.contextPath);
this.apiScenario.init();
} else if (options.type === 'load') {
this.loadTesterManager = new LoadTestManager(options.contextPath);
this.loadTesterManager.init();
}
}
}