Skip to content

Commit 3eb9fa3

Browse files
chore: lint fixes
1 parent 767d4b4 commit 3eb9fa3

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/courseware/course/sequence/Unit/hooks/useIFrameBehavior.test.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,13 @@ const setShowError = jest.fn();
9999
const setWindowTopOffset = jest.fn();
100100

101101
const mockState = (state) => {
102-
const { iframeHeight, hasLoaded, showError, windowTopOffset } = state;
103-
if ('iframeHeight' in state) jest.spyOn(iframeBehaviorState, 'iframeHeight').mockImplementation(() => [iframeHeight, setIframeHeight]);
104-
if ('hasLoaded' in state) jest.spyOn(iframeBehaviorState, 'hasLoaded').mockImplementation(() => [hasLoaded, setHasLoaded]);
105-
if ('showError' in state) jest.spyOn(iframeBehaviorState, 'showError').mockImplementation(() => [showError, setShowError]);
106-
if ('windowTopOffset' in state) jest.spyOn(iframeBehaviorState, 'windowTopOffset').mockImplementation(() => [windowTopOffset, setWindowTopOffset]);
102+
const {
103+
iframeHeight, hasLoaded, showError, windowTopOffset,
104+
} = state;
105+
if ('iframeHeight' in state) { jest.spyOn(iframeBehaviorState, 'iframeHeight').mockImplementation(() => [iframeHeight, setIframeHeight]); }
106+
if ('hasLoaded' in state) { jest.spyOn(iframeBehaviorState, 'hasLoaded').mockImplementation(() => [hasLoaded, setHasLoaded]); }
107+
if ('showError' in state) { jest.spyOn(iframeBehaviorState, 'showError').mockImplementation(() => [showError, setShowError]); }
108+
if ('windowTopOffset' in state) { jest.spyOn(iframeBehaviorState, 'windowTopOffset').mockImplementation(() => [windowTopOffset, setWindowTopOffset]); }
107109
};
108110

109111
describe('useIFrameBehavior hook', () => {
@@ -165,7 +167,7 @@ describe('useIFrameBehavior hook', () => {
165167
]);
166168
});
167169
describe('resize message', () => {
168-
const height = 23;
170+
const customHeight = 23;
169171
const resizeMessage = (height = 23) => ({
170172
data: { type: messageTypes.resize, payload: { height } },
171173
});
@@ -182,9 +184,9 @@ describe('useIFrameBehavior hook', () => {
182184
mockState({ ...defaultStateVals, hasLoaded: true });
183185
renderHook(() => useIFrameBehavior(props));
184186
const { cb } = useEventListener.mock.calls[0][1];
185-
cb(resizeMessage(height));
187+
cb(resizeMessage(customHeight));
186188
expect(setIframeHeight).toHaveBeenCalledWith(0);
187-
expect(setIframeHeight).toHaveBeenCalledWith(height);
189+
expect(setIframeHeight).toHaveBeenCalledWith(customHeight);
188190
});
189191
});
190192
describe('payload height is 0', () => {
@@ -194,7 +196,7 @@ describe('useIFrameBehavior hook', () => {
194196
const { cb } = useEventListener.mock.calls[0][1];
195197
cb(resizeMessage(0));
196198
expect(setIframeHeight).toHaveBeenCalledWith(0);
197-
expect(setIframeHeight).not.toHaveBeenCalledWith(height);
199+
expect(setIframeHeight).not.toHaveBeenCalledWith(customHeight);
198200
});
199201
});
200202
describe('payload is present but uninitialized', () => {
@@ -277,7 +279,7 @@ describe('useIFrameBehavior hook', () => {
277279
describe('visibility tracking', () => {
278280
it('sets up visibility tracking after iframe has loaded', () => {
279281
mockState({ ...defaultStateVals, hasLoaded: true });
280-
282+
281283
renderHook(() => useIFrameBehavior(props));
282284

283285
expect(global.window.addEventListener).toHaveBeenCalledTimes(2);

0 commit comments

Comments
 (0)