-
-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(unlock-app): skipping recipients if all fields are hidden (#14583)
skipping recipients if all fields are hidden
- Loading branch information
Showing
4 changed files
with
111 additions
and
24 deletions.
There are no files selected for viewing
89 changes: 89 additions & 0 deletions
89
unlock-app/src/__tests__/components/interface/checkout/main/utils.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { it, describe, expect } from 'vitest' | ||
import { shouldSkip } from '~/components/interface/checkout/main/utils' | ||
|
||
describe('shouldSkip', () => { | ||
it('it should skip if skipRecipient is set at the root level', () => { | ||
expect( | ||
shouldSkip({ | ||
lock: { maxRecipients: 1 }, | ||
paywallConfig: { | ||
skipRecipient: true, | ||
locks: { | ||
'0x123': { maxRecipients: 1 }, | ||
}, | ||
}, | ||
}).skipRecipient | ||
).toBe(true) | ||
}) | ||
it('it should not skip if skipRecipient is set to true but if there are metadataInputs', () => { | ||
expect( | ||
shouldSkip({ | ||
lock: { maxRecipients: 1 }, | ||
paywallConfig: { | ||
skipRecipient: true, | ||
metadataInputs: [ | ||
{ | ||
type: 'email', | ||
name: 'email', | ||
required: true, | ||
public: false, | ||
}, | ||
], | ||
locks: { | ||
'0x123': { maxRecipients: 1 }, | ||
}, | ||
}, | ||
}).skipRecipient | ||
).toBe(false) | ||
}) | ||
|
||
it('it should skip if skipRecipient is set to true and if there are only hidden metadataInputs', () => { | ||
expect( | ||
shouldSkip({ | ||
lock: { maxRecipients: 1 }, | ||
paywallConfig: { | ||
skipRecipient: true, | ||
metadataInputs: [ | ||
{ | ||
type: 'hidden', | ||
name: 'email', | ||
required: true, | ||
public: false, | ||
}, | ||
], | ||
locks: { | ||
'0x123': { maxRecipients: 1 }, | ||
}, | ||
}, | ||
}).skipRecipient | ||
).toBe(true) | ||
}) | ||
|
||
it('it should not skip if skipRecipient is set to true and if there are non-hidden metadataInputs', () => { | ||
expect( | ||
shouldSkip({ | ||
lock: { maxRecipients: 1 }, | ||
paywallConfig: { | ||
skipRecipient: true, | ||
metadataInputs: [ | ||
{ | ||
type: 'hidden', | ||
name: 'email', | ||
required: true, | ||
public: false, | ||
}, | ||
{ | ||
type: 'text', | ||
name: 'name', | ||
required: true, | ||
public: false, | ||
}, | ||
], | ||
locks: { | ||
'0x123': { maxRecipients: 1 }, | ||
}, | ||
}, | ||
}).skipRecipient | ||
).toBe(false) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters