Skip to content

Commit

Permalink
topic edit modal: Modify webview unit tests to accomdate feature update.
Browse files Browse the repository at this point in the history
  • Loading branch information
Leslie Ngo authored and Leslie Ngo committed Sep 25, 2022
1 parent daa4b6f commit 3b81cb0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
7 changes: 4 additions & 3 deletions src/boot/TopicModalProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,20 @@ type Props = $ReadOnly<{|
children: Node,
|}>;

type TopicModalContext = {|
type TopicModalContext = $ReadOnly<{|
startEditTopic: (
streamId: number,
topic: string,
streamsById: Map<number, Stream>,
_: GetText,
) => Promise<void>,
closeEditTopicModal: () => void,
|};
|}>;

// $FlowIssue[incompatible-type]
const TopicModal: Context<TopicModalContext> = createContext(undefined);

export const useTopicModalHandler = () => useContext(TopicModal);
export const useTopicModalHandler = (): TopicModalContext => useContext(TopicModal);

export default function TopicModalProvider(props: Props): Node {
const { children } = props;
Expand Down
2 changes: 1 addition & 1 deletion src/streams/TopicItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default function TopicItem(props: Props): Node {
useActionSheet().showActionSheetWithOptions;
const _ = useContext(TranslationContext);
const dispatch = useDispatch();
const startEditTopic = useTopicModalHandler();
const { startEditTopic } = useTopicModalHandler();
const backgroundData = useSelector(state => ({
auth: getAuth(state),
mute: getMute(state),
Expand Down
8 changes: 0 additions & 8 deletions src/webview/MessageList.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,6 @@ export type Props = $ReadOnly<{|

// From `withGetText`.
_: GetText,

// From 'TopicModalProvider'.
startEditTopic: (
streamId: number,
topic: string,
streamsById: Map<number, Stream>,
_: GetText,
) => Promise<void>,
|}>;

/**
Expand Down
1 change: 1 addition & 0 deletions src/webview/__tests__/generateInboundEvents-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe('generateInboundEvents', () => {
narrow: HOME_NARROW,
showMessagePlaceholders: false,
startEditMessage: jest.fn(),
startEditTopic: jest.fn(),
dispatch: jest.fn(),
...baseSelectorProps,
showActionSheetWithOptions: jest.fn(),
Expand Down

0 comments on commit 3b81cb0

Please sign in to comment.