webpack/test/ProfilingPlugin.unittest.js

63 lines
1.4 KiB
JavaScript
Raw Normal View History

2017-12-26 11:12:08 +08:00
"use strict";
require("should");
const ProfilingPlugin = require("../lib/debug/ProfilingPlugin");
describe("Profiling Plugin", () => {
it("should persist the passed outpath", () => {
const plugin = new ProfilingPlugin({
outPath: "invest_in_doge_coin"
});
plugin.outPath.should.equal("invest_in_doge_coin");
});
it("should handle no options", () => {
const plugin = new ProfilingPlugin();
plugin.outPath.should.equal("events.json");
});
it("should handle when unable to require the inspector", (done) => {
const profiler = new ProfilingPlugin.Profiler();
profiler.startProfiling().then(() => {
done();
}).catch(e => {
done(e);
});
});
it("should handle when unable to start a profiling session", (done) => {
const profiler = new ProfilingPlugin.Profiler({
Session() {
throw new Error("Sean Larkin was here.");
}
});
profiler.startProfiling().then(() => {
done();
}).catch(e => {
done(e);
});
});
it("handles sending a profiling message when no session", (done) => {
const profiler = new ProfilingPlugin.Profiler();
profiler.sendCommand("randy", "is a puppers").then(() => {
done();
}).catch(e => {
done(e);
});
});
it("handles destroying when no session", (done) => {
const profiler = new ProfilingPlugin.Profiler();
profiler.destroy().then(() => {
done();
}).catch(e => {
done(e);
});
});
});