Skip to content

Commit

Permalink
fix: remove paymentRequest and merchantInfo from invalidation properties
Browse files Browse the repository at this point in the history
This prevents the button from being recreated when these properties change.
  • Loading branch information
Soc Sieng committed Jun 25, 2020
1 parent 6972f4a commit ecafb34
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/lib/button-manager.test.ts
Expand Up @@ -508,7 +508,7 @@ describe('Google Pay client invalidation', () => {
expect(updateElementSpy).toBeCalledTimes(2);
});

it('invalidates client when paymentRequest changes', () => {
it('does not invalidate client when paymentRequest changes and is equivalent', () => {
const manager = new ButtonManager(managerOptions);
const config1: Config = {
...defaults,
Expand All @@ -523,7 +523,7 @@ describe('Google Pay client invalidation', () => {
manager.configure(config1);
manager.configure(config2);

expect(updateElementSpy).toBeCalledTimes(2);
expect(updateElementSpy).toBeCalledTimes(1);
});

it('does not invalidate client with the same configuration (shallow copy)', () => {
Expand All @@ -541,7 +541,7 @@ describe('Google Pay client invalidation', () => {
expect(updateElementSpy).toBeCalledTimes(1);
});

it('invalidates client with different paymentRequest', () => {
it('does not invalidate client when paymentRequest is equivalent', () => {
const manager = new ButtonManager(managerOptions);
const config1: Config = {
...defaults,
Expand All @@ -559,7 +559,7 @@ describe('Google Pay client invalidation', () => {
manager.configure(config1);
manager.configure(config2);

expect(updateElementSpy).toBeCalledTimes(2);
expect(updateElementSpy).toBeCalledTimes(1);
});

it('does not invalidate client when mutating transactionInfo', () => {
Expand All @@ -583,7 +583,7 @@ describe('Google Pay client invalidation', () => {
expect(updateElementSpy).toBeCalledTimes(1);
});

it('invalidates client when mutating merchantInfo', () => {
it('does not invalidate client when merchantInfo is equivalent', () => {
const manager = new ButtonManager(managerOptions);
const config: Config = {
...defaults,
Expand All @@ -601,7 +601,7 @@ describe('Google Pay client invalidation', () => {

manager.configure(config);

expect(updateElementSpy).toBeCalledTimes(2);
expect(updateElementSpy).toBeCalledTimes(1);
});

it('invalidates client when mutating merchantId', () => {
Expand Down
2 changes: 0 additions & 2 deletions src/lib/button-manager.ts
Expand Up @@ -393,8 +393,6 @@ export class ButtonManager {
!!config.onPaymentAuthorized,
config.buttonColor,
config.buttonType,
config.paymentRequest,
config.paymentRequest.merchantInfo,
config.paymentRequest.merchantInfo.merchantId,
config.paymentRequest.merchantInfo.merchantName,
config.paymentRequest.merchantInfo.softwareInfo?.id,
Expand Down

0 comments on commit ecafb34

Please sign in to comment.