Skip to content

Commit

Permalink
test: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinperaza committed Mar 21, 2024
1 parent d670f62 commit ba14c7e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
7 changes: 5 additions & 2 deletions test/elements/CardExpirationDateElement.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ describe('CardExpirationDateElement', () => {
const chance = new Chance();
const refArray = [React.createRef<ICardExpirationDateElement>(), undefined];

const valueRef = React.createRef<ICardExpirationDateElement>();

let id: string;
let wrapperDiv: HTMLDivElement;
let style: ElementStyle;
Expand Down Expand Up @@ -93,7 +95,7 @@ describe('CardExpirationDateElement', () => {
style={style}
validateOnChange={validateOnChange}
value={value}
valueRef={React.createRef()}
valueRef={valueRef}
/>
);

Expand All @@ -117,7 +119,8 @@ describe('CardExpirationDateElement', () => {
},
undefined,
// eslint-disable-next-line unicorn/no-null
typeof ref === 'undefined' ? null : ref // undefined ref gets forwarded as null
typeof ref === 'undefined' ? null : ref, // undefined ref gets forwarded as null,
valueRef // undefined ref gets forwarded as null
);
expect(useListener).toHaveBeenCalledWith('ready', element, onReady);
expect(useListener).toHaveBeenCalledWith('change', element, onChange);
Expand Down
7 changes: 5 additions & 2 deletions test/elements/CardNumberElement.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ describe('CardNumberElement', () => {
const chance = new Chance();
const refArray = [React.createRef<ICardNumberElement>(), undefined];

const valueRef = React.createRef<ICardNumberElement>();

let id: string;
let wrapperDiv: HTMLDivElement;
let style: ElementStyle;
Expand Down Expand Up @@ -93,7 +95,7 @@ describe('CardNumberElement', () => {
style={style}
validateOnChange={validateOnChange}
value={value}
valueRef={React.createRef()}
valueRef={valueRef}
/>
);

Expand All @@ -119,7 +121,8 @@ describe('CardNumberElement', () => {
},
undefined,
// eslint-disable-next-line unicorn/no-null
typeof ref === 'undefined' ? null : ref // undefined ref gets forwarded as null
typeof ref === 'undefined' ? null : ref, // undefined ref gets forwarded as null
valueRef // undefined ref gets forwarded as null
);
expect(useListener).toHaveBeenCalledWith('ready', element, onReady);
expect(useListener).toHaveBeenCalledWith('change', element, onChange);
Expand Down
7 changes: 5 additions & 2 deletions test/elements/CardVerificationCodeElement.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ describe('CardVerificationCodeElement', () => {
const chance = new Chance();
const refArray = [React.createRef<ICardVerificationCodeElement>(), undefined];

const valueRef = React.createRef<ICardVerificationCodeElement>();

let id: string;
let wrapperDiv: HTMLDivElement;
let style: ElementStyle;
Expand Down Expand Up @@ -91,7 +93,7 @@ describe('CardVerificationCodeElement', () => {
style={style}
validateOnChange={validateOnChange}
value={value}
valueRef={React.createRef()}
valueRef={valueRef}
/>
);

Expand All @@ -116,7 +118,8 @@ describe('CardVerificationCodeElement', () => {
},
undefined,
// eslint-disable-next-line unicorn/no-null
typeof ref === 'undefined' ? null : ref // undefined ref gets forwarded as null
typeof ref === 'undefined' ? null : ref, // undefined ref gets forwarded as null
valueRef
);
expect(useListener).toHaveBeenCalledWith('ready', element, onReady);
expect(useListener).toHaveBeenCalledWith('change', element, onChange);
Expand Down
7 changes: 5 additions & 2 deletions test/elements/TextElement.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ describe('TextElement', () => {
const chance = new Chance();
const refArray = [React.createRef<ITextElement>(), undefined];

const valueRef = React.createRef<ITextElement>();

let id: string;
let wrapperDiv: HTMLDivElement;
let style: ElementStyle;
Expand Down Expand Up @@ -99,7 +101,7 @@ describe('TextElement', () => {
transform={transform}
validation={validation}
value={value}
valueRef={React.createRef()}
valueRef={valueRef}
/>
);

Expand All @@ -125,7 +127,8 @@ describe('TextElement', () => {
},
undefined,
// eslint-disable-next-line unicorn/no-null
typeof ref === 'undefined' ? null : ref // undefined ref gets forwarded as null
typeof ref === 'undefined' ? null : ref, // undefined ref gets forwarded as null
valueRef
);
expect(useListener).toHaveBeenCalledWith('ready', element, onReady);
expect(useListener).toHaveBeenCalledWith('change', element, onChange);
Expand Down

0 comments on commit ba14c7e

Please sign in to comment.