Skip to content

Commit

Permalink
[DLT-1110] Add mocha config, correct prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
AronPerez committed Jan 6, 2025
1 parent 1567afb commit c8672c0
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 9 deletions.
33 changes: 33 additions & 0 deletions web/.mocharc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Mocha configuration file.
*
* This configuration file sets up various options for running Mocha tests.
*
* @property {boolean} diff - Show diff on failure.
* @property {boolean} recursive - Include subdirectories.
* @property {boolean} exit - Force Mocha to quit after tests complete.
* @property {string[]} extension - File extensions to include.
* @property {string} package - Path to the package.json file.
* @property {string} reporter - Reporter to use.
* @property {number} timeout - Test-case timeout in milliseconds.
* @property {string} ui - User interface to use (e.g., BDD, TDD).
* @property {string[]} require - Modules to require before running tests.
* @property {string[]} watch-files - Files to watch for changes.
* @property {string[]} watch-ignore - Files to ignore when watching.
* @property {string[]} spec - Test files to run.
*/
module.exports = {
diff: true,
recursive: true,
exit: true,
loader: "mock-import/register",
extension: ["js"],
package: "./package.json",
reporter: "spec",
timeout: 2000,
ui: "bdd",
require: ["test/setup.js"],
"watch-files": ["test/**/*.js", "static/**/*.js"],
"watch-ignore": ["node_modules", "coverage"],
spec: ["test/**/*.test.js"],
};
10 changes: 7 additions & 3 deletions web/package.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"sanitize-html": "^2.11.0"
},
"scripts": {
"test": "mocha"
"test": "mocha --config .mocharc.cjs",
},
"repository": {
"type": "git",
Expand All @@ -37,10 +37,14 @@
"homepage": "https://github.com/ORNL/DataFed#readme",
"devDependencies": {
"chai": "^4",
"sinon": "^15.2.0",
"esm": "^3.2.25",
"jsdom": "^25.0.1",
"jsdom-global": "^3.0.2",
"mocha": "^10.8.2",
"pug": "^3.0.3"
"mock-import": "^4.2.0",
"prettier": "3.4.2",
"pug": "^3.0.3",
"sinon": "^15.2.0"
},
"type": "module"
}
12 changes: 6 additions & 6 deletions web/test/components/transfer/transfer-ui-manager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ describe("TransferUIManager", () => {
model: {
mode: model.TT_DATA_GET,
records: [],
getRecordInfo: sinon.stub()
getRecordInfo: sinon.stub(),
},
endpointManager: {
currentEndpoint: {
id: "test-endpoint",
name: "test-endpoint",
default_directory: "/default"
default_directory: "/default",
},
currentSearchToken: "test-token",
searchCounter: 0
}
searchCounter: 0,
},
};

// Create a real DOM element
Expand All @@ -41,7 +41,7 @@ describe("TransferUIManager", () => {
on: sinon.stub(),
show: sinon.stub(),
checkboxradio: sinon.stub(),
hasClass: sinon.stub().returns(false)
hasClass: sinon.stub().returns(false),
});

uiManager = new TransferUIManager(mockDialog);
Expand Down Expand Up @@ -196,7 +196,7 @@ describe("TransferUIManager", () => {

it("should get selected IDs correctly", () => {
uiManager.recordTree = {
getSelectedNodes: () => [{ key: "id1" }, { key: "id2" }]
getSelectedNodes: () => [{ key: "id1" }, { key: "id2" }],
};
const selectedIds = uiManager.getSelectedIds();
expect(selectedIds).to.deep.equal(["id1", "id2"]);
Expand Down

0 comments on commit c8672c0

Please sign in to comment.