Skip to content

Commit

Permalink
Add initial unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaSBrown committed Nov 11, 2024
1 parent 7b40e5b commit e93f98c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
11 changes: 9 additions & 2 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": "echo \"Error: no test specified\" && exit 1"
"test": "mocha"
},
"repository": {
"type": "git",
Expand All @@ -34,5 +34,12 @@
"bugs": {
"url": "https://github.com/ORNL/DataFed/issues"
},
"homepage": "https://github.com/ORNL/DataFed#readme"
"homepage": "https://github.com/ORNL/DataFed#readme",
"devDependencies": {
"chai": "^4",
"esm": "^3.2.25",
"mocha": "^10.8.2",
"pug": "^3.0.3"
},
"type": "module"
}
23 changes: 23 additions & 0 deletions web/test/util.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { expect } from 'chai';
import { isObjEmpty } from '../static/util.js';

describe('isObjEmpty', function () {
it('should return true for an empty object', function () {
const emptyObj = {};
expect(isObjEmpty(emptyObj)).to.be.true;
});

it('should return false for an object with properties', function () {
const objWithProps = { key: 'value' };
expect(isObjEmpty(objWithProps)).to.be.false;
});

it('should return true if a non-object is passed (like null)', function () {
expect(isObjEmpty(null)).to.be.true;
});

it('should return true if a non-object is passed (like undefined)', function () {
expect(isObjEmpty(undefined)).to.be.true;
});
});

0 comments on commit e93f98c

Please sign in to comment.