Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions js/widgets/__tests__/oscilloscope.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,7 @@ function createMockWidgetWindow() {
};
}

// Load the Oscilloscope class by reading the source and wrapping it
// so the class is assigned to global (class declarations are block-scoped)
const fs = require("fs");
const path = require("path");
const oscilloscopeSource = fs.readFileSync(path.resolve(__dirname, "../oscilloscope.js"), "utf-8");
const Oscilloscope = require("../oscilloscope.js");

let mockWidgetWindow;

Expand All @@ -96,10 +92,6 @@ window.widgetWindows = {
windowFor: jest.fn(() => mockWidgetWindow)
};

// Wrap source: execute the class definition and assign to global
const wrappedSource = oscilloscopeSource + "\nglobal.Oscilloscope = Oscilloscope;\n";
new Function(wrappedSource)();

beforeEach(() => {
mockWidgetWindow = createMockWidgetWindow();

Expand Down
4 changes: 4 additions & 0 deletions js/widgets/oscilloscope.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,3 +326,7 @@ class Oscilloscope {
}
}
}

if (typeof module !== "undefined") {
module.exports = Oscilloscope;
}
Loading