Skip to content

Commit 09461c4

Browse files
committed
iss1171 - Rest of metadata JS tests
1 parent 61ba70b commit 09461c4

10 files changed

Lines changed: 1306 additions & 88 deletions

File tree

.vscode/launch.json

Lines changed: 0 additions & 88 deletions
This file was deleted.

tests/jest/__mocks__/core/modal.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default class Modal {
2+
constructor(..._args) {}
3+
static create = jest.fn().mockResolvedValue(null);
4+
}
5+
6+
// Prototype methods so all instances share the same spy target.
7+
Modal.prototype.hide = jest.fn();
8+
Modal.prototype.show = jest.fn();
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,21 @@
11
export class Reactive {}
2+
3+
export class BaseComponent {
4+
constructor({element, reactive, selectors} = {}) {
5+
this.element = element ?? null;
6+
this.reactive = reactive ?? null;
7+
if (selectors) {
8+
this.selectors = selectors;
9+
}
10+
if (typeof this.create === 'function') {
11+
this.create();
12+
}
13+
}
14+
}
15+
16+
// Prototype stubs — shared across instances; reset with jest.resetAllMocks() in beforeEach.
17+
BaseComponent.prototype.getElement = jest.fn();
18+
BaseComponent.prototype.getElements = jest.fn(() => []);
19+
BaseComponent.prototype.addEventListener = jest.fn();
20+
BaseComponent.prototype.renderComponent = jest.fn().mockResolvedValue(undefined);
21+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const notifyFieldValidationFailure = jest.fn();
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default {
2+
init: jest.fn(),
3+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
export const metadata = {
2+
lib: {
3+
user: {
4+
firstname: 'Jane',
5+
lastname: 'Doe',
6+
institution: 'Test University',
7+
},
8+
licenses: [
9+
{value: 'cc-by', text: 'CC BY'},
10+
{value: 'cc-by-sa', text: 'CC BY-SA'},
11+
],
12+
placeholder: 'Select a license',
13+
},
14+
container: {update: jest.fn()},
15+
jsonStringify: jest.fn(),
16+
jsonToState: jest.fn(),
17+
state: {},
18+
loadState: jest.fn(),
19+
};

0 commit comments

Comments
 (0)