webpack/test/ProfilingPlugin.unittest.js

45 lines
1.2 KiB
JavaScript
Raw Normal View History

2017-12-26 11:12:08 +08:00
"use strict";
const path = require("path");
2017-12-26 11:12:08 +08:00
const ProfilingPlugin = require("../lib/debug/ProfilingPlugin");
describe("Profiling Plugin", () => {
it("should persist the passed output path", () => {
const outputPath = path.join(__dirname, "invest_in_doge_coin");
2017-12-26 11:12:08 +08:00
const plugin = new ProfilingPlugin({
2025-04-22 19:09:25 +08:00
outputPath
2017-12-26 11:12:08 +08:00
});
expect(plugin.outputPath).toBe(outputPath);
2017-12-26 11:12:08 +08:00
});
it("should handle no options", () => {
const plugin = new ProfilingPlugin();
expect(plugin.outputPath).toBe("events.json");
2017-12-26 11:12:08 +08:00
});
2018-01-24 20:17:21 +08:00
it("should handle when unable to require the inspector", () => {
2017-12-26 11:12:08 +08:00
const profiler = new ProfilingPlugin.Profiler();
2018-01-24 20:17:21 +08:00
return profiler.startProfiling();
2017-12-26 11:12:08 +08:00
});
2018-01-24 20:17:21 +08:00
it("should handle when unable to start a profiling session", () => {
2017-12-26 11:12:08 +08:00
const profiler = new ProfilingPlugin.Profiler({
Session() {
throw new Error("Sean Larkin was here.");
}
});
2018-01-24 20:17:21 +08:00
return profiler.startProfiling();
2017-12-26 11:12:08 +08:00
});
2018-01-24 20:17:21 +08:00
it("handles sending a profiling message when no session", () => {
2017-12-26 11:12:08 +08:00
const profiler = new ProfilingPlugin.Profiler();
return profiler.sendCommand("randy", "is awesome");
2017-12-26 11:12:08 +08:00
});
2018-01-24 20:17:21 +08:00
it("handles destroying when no session", () => {
2017-12-26 11:12:08 +08:00
const profiler = new ProfilingPlugin.Profiler();
2018-01-24 20:17:21 +08:00
return profiler.destroy();
2017-12-26 11:12:08 +08:00
});
});