Skip to content

Commit

Permalink
Add support for the useIndianSeparators property (#784)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmarkelov committed Mar 11, 2023
1 parent 6783ad0 commit c9c7b31
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/__tests__/CountUp.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,18 @@ describe('CountUp component', () => {
expect(container).toMatchSnapshot();
});

it('renders with useIndianSeparators prop correctly', (done) => {
const { container } = render(
<CountUp duration={1} end={100000} useIndianSeparators />,
);

setTimeout(() => {
const span = container.firstChild;
expect(span.textContent).toEqual('1,00,000');
done();
}, 1200);
})

it('renders with delay as a render prop component correctly', () => {
const { container } = render(
<CountUp delay={1} end={10}>
Expand Down
5 changes: 4 additions & 1 deletion src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export const createCountUpInstance = (
start,
suffix,
useEasing,
useGrouping,
useIndianSeparators,
enableScrollSpy,
scrollSpyDelay,
scrollSpyOnce,
Expand All @@ -35,7 +37,8 @@ export const createCountUpInstance = (
prefix,
suffix,
useEasing,
useGrouping: !!separator,
useIndianSeparators,
useGrouping,
enableScrollSpy,
scrollSpyDelay,
scrollSpyOnce,
Expand Down
4 changes: 4 additions & 0 deletions src/useCountUp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@ export interface useCountUpProps extends CommonProps, CallbackProps {

const DEFAULTS = {
decimal: '.',
separator: ',',
delay: null,
prefix: '',
suffix: '',
duration: 2,
start: 0,
decimals: 0,
startOnMount: true,
enableReinitialize: true,
useEasing: true,
useGrouping: true,
useIndianSeparators: false,
};

const useCountUp = (props: useCountUpProps): CountUpApi => {
Expand Down

0 comments on commit c9c7b31

Please sign in to comment.