• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

fkhadra / react-toastify / 12362857581

16 Dec 2024 11:01PM UTC coverage: 81.398% (-7.6%) from 88.998%
12362857581

push

github

fkhadra
chore: bump dependencies

320 of 423 branches covered (75.65%)

Branch coverage included in aggregate %.

437 of 507 relevant lines covered (86.19%)

580.66 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
/src/utils/mapper.ts
1
import { Toast, ToastContentProps, ToastItem, ToastItemStatus, ToastProps } from '../types';
2
import { cloneElement, isValidElement, ReactElement } from 'react';
3
import { isFn, isStr } from './propValidator';
4

5
export function toToastItem(toast: Toast, status: ToastItemStatus): ToastItem {
6
  return {
776✔
7
    content: renderContent(toast.content, toast.props),
8
    containerId: toast.props.containerId,
9
    id: toast.props.toastId,
10
    theme: toast.props.theme,
11
    type: toast.props.type,
12
    data: toast.props.data || {},
727✔
13
    isLoading: toast.props.isLoading,
14
    icon: toast.props.icon,
15
    reason: toast.removalReason,
16
    status
17
  };
18
}
19

20
export function renderContent(content: unknown, props: ToastProps, isPaused: boolean = false) {
388✔
21
  if (isValidElement(content) && !isStr(content.type)) {
3,110!
22
    return cloneElement<ToastContentProps>(content as ReactElement<any>, {
×
23
      closeToast: props.closeToast,
24
      toastProps: props,
25
      data: props.data,
26
      isPaused
27
    });
28
  } else if (isFn(content)) {
3,110✔
29
    return content({
128✔
30
      closeToast: props.closeToast,
31
      toastProps: props,
32
      data: props.data,
33
      isPaused
34
    });
35
  }
36

37
  return content;
2,982✔
38
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc