Skip to content

Commit

Permalink
fix: fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowusr committed Aug 20, 2024
1 parent bd6f9e6 commit f0b22fd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/static/components/details.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function Details(props) {
const newIsOpened = !isOpened;

setIsOpened(newIsOpened);
props.onClick?.(newIsOpened);
props.onClick?.({isOpened: newIsOpened});
};

const getContent = () => {
Expand Down
12 changes: 11 additions & 1 deletion test/unit/lib/static/components/section/body/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import userEvent from '@testing-library/user-event';
describe('<Body />', () => {
const sandbox = sinon.sandbox.create();
let Body, Result, RetrySwitcher, actionsStub;
const originalResizeObserver = window.ResizeObserver;

const mkBodyComponent = (props = {}, initialState = {}) => {
props = defaults(props, {
Expand All @@ -35,9 +36,18 @@ describe('<Body />', () => {
'./result': {default: Result},
'../../retry-switcher': {default: RetrySwitcher}
}).default;

window.ResizeObserver = sinon.stub();
window.ResizeObserver.prototype.observe = sinon.stub();
window.ResizeObserver.prototype.unobserve = sinon.stub();
window.ResizeObserver.prototype.disconnect = sinon.stub();
});

afterEach(() => sandbox.restore());
afterEach(() => {
window.ResizeObserver = originalResizeObserver;

sandbox.restore();
});

describe('"Retry" button', () => {
it('should render if "gui" is running', () => {
Expand Down
8 changes: 0 additions & 8 deletions test/unit/lib/static/components/suites.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ describe('<Suites/>', () => {
let Suites, getVisibleRootSuiteIds;
const originalOffsetHeight = Object.getOwnPropertyDescriptor(global.HTMLElement.prototype, 'offsetHeight');
const originalOffsetWidth = Object.getOwnPropertyDescriptor(global.HTMLElement.prototype, 'offsetWidth');
const originalResizeObserver = window.ResizeObserver;

const mkSuitesComponent = (initialState = {}) => {
initialState = defaultsDeep(initialState, {
Expand All @@ -27,11 +26,6 @@ describe('<Suites/>', () => {
Object.defineProperty(global.HTMLElement.prototype, 'offsetHeight', {configurable: true, value: 50});
Object.defineProperty(global.HTMLElement.prototype, 'offsetWidth', {configurable: true, value: 50});

window.ResizeObserver = sinon.stub();
window.ResizeObserver.prototype.observe = sinon.stub();
window.ResizeObserver.prototype.unobserve = sinon.stub();
window.ResizeObserver.prototype.disconnect = sinon.stub();

getVisibleRootSuiteIds = sinon.stub().returns([]);

Suites = proxyquire('lib/static/components/suites', {
Expand All @@ -43,8 +37,6 @@ describe('<Suites/>', () => {
Object.defineProperty(global.HTMLElement.prototype, 'offsetHeight', originalOffsetHeight);
Object.defineProperty(global.HTMLElement.prototype, 'offsetWidth', originalOffsetWidth);

window.ResizeObserver = originalResizeObserver;

sandbox.restore();
});

Expand Down

0 comments on commit f0b22fd

Please sign in to comment.