Skip to content

Commit

Permalink
chore: fix typo for modal event
Browse files Browse the repository at this point in the history
  • Loading branch information
leangseu-edx committed Nov 29, 2023
1 parent bce25c4 commit 2fd5e92
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const stateKeys = StrictDict({

export const DEFAULT_HEIGHT = '100vh';

const useModalIFrameBehavior = () => {
const useModalIFrameData = () => {
const [isOpen, setIsOpen] = useKeyedState(stateKeys.isOpen, false);
const [options, setOptions] = useKeyedState(stateKeys.options, { height: DEFAULT_HEIGHT });

Expand Down Expand Up @@ -42,4 +42,4 @@ const useModalIFrameBehavior = () => {
};
};

export default useModalIFrameBehavior;
export default useModalIFrameData;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { mockUseKeyedState } from '@edx/react-unit-test-utils';
import { useEventListener } from '../../../../../generic/hooks';
import { messageTypes } from '../constants';

import useModalIFrameBehavior, { stateKeys, DEFAULT_HEIGHT } from './useModalIFrameData';
import useModalIFrameData, { stateKeys, DEFAULT_HEIGHT } from './useModalIFrameData';

jest.mock('react', () => ({
...jest.requireActual('react'),
Expand All @@ -14,7 +14,7 @@ jest.mock('../../../../../generic/hooks', () => ({

const state = mockUseKeyedState(stateKeys);

describe('useModalIFrameBehavior', () => {
describe('useModalIFrameData', () => {
beforeEach(() => {
jest.clearAllMocks();
state.mock();
Expand All @@ -28,17 +28,17 @@ describe('useModalIFrameBehavior', () => {
};
describe('behavior', () => {
it('initializes isOpen to false', () => {
useModalIFrameBehavior();
useModalIFrameData();
state.expectInitializedWith(stateKeys.isOpen, false);
});
it('initializes options with default height', () => {
useModalIFrameBehavior();
useModalIFrameData();
state.expectInitializedWith(stateKeys.options, { height: DEFAULT_HEIGHT });
});
describe('eventListener', () => {
const oldOptions = { some: 'old', options: 'yeah' };
const prepareListener = () => {
useModalIFrameBehavior();
useModalIFrameData();
expect(useEventListener).toHaveBeenCalled();
const call = useEventListener.mock.calls[0][1];
expect(call.prereqs).toEqual([]);
Expand Down Expand Up @@ -80,15 +80,15 @@ describe('useModalIFrameBehavior', () => {
});
describe('output', () => {
test('returns handleModalClose callback', () => {
testHandleModalClose({ trigger: useModalIFrameBehavior().handleModalClose });
testHandleModalClose({ trigger: useModalIFrameData().handleModalClose });
});
it('forwards modalOptions from state values', () => {
const modalOptions = { test: 'options' };
state.mockVals({
[stateKeys.options]: modalOptions,
[stateKeys.isOpen]: true,
});
expect(useModalIFrameBehavior().modalOptions).toEqual({
expect(useModalIFrameData().modalOptions).toEqual({
...modalOptions,
isOpen: true,
});
Expand Down

0 comments on commit 2fd5e92

Please sign in to comment.