webpack/test/ProfilingPlugin.unittest.js

43 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-12-26 11:12:08 +08:00
"use strict";
const ProfilingPlugin = require("../lib/debug/ProfilingPlugin");
describe("Profiling Plugin", () => {
it("should persist the passed outpath", () => {
const plugin = new ProfilingPlugin({
outPath: "invest_in_doge_coin"
});
2018-01-24 20:17:21 +08:00
expect(plugin.outPath).toBe("invest_in_doge_coin");
2017-12-26 11:12:08 +08:00
});
it("should handle no options", () => {
const plugin = new ProfilingPlugin();
2018-01-24 20:17:21 +08:00
expect(plugin.outPath).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();
2018-01-24 20:17:21 +08:00
return profiler.sendCommand("randy", "is a puppers");
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
});
});