@faststore/core 4.3.0-dev.7 → 4.3.0-dev.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,57 @@
1
+ import { describe, expect, it } from 'vitest'
2
+
3
+ import { isUnlockResponse } from '../../src/utils/unlockResponse'
4
+
5
+ describe('isUnlockResponse', () => {
6
+ it('returns false for null', () => {
7
+ expect(isUnlockResponse(null)).toBe(false)
8
+ })
9
+
10
+ it('returns false for an array', () => {
11
+ expect(isUnlockResponse([])).toBe(false)
12
+ })
13
+
14
+ it('returns false for a string', () => {
15
+ expect(isUnlockResponse('ok')).toBe(false)
16
+ })
17
+
18
+ it('returns false for a number', () => {
19
+ expect(isUnlockResponse(42)).toBe(false)
20
+ })
21
+
22
+ it('returns false for an empty object', () => {
23
+ expect(isUnlockResponse({})).toBe(false)
24
+ })
25
+
26
+ it('returns true for a valid success payload', () => {
27
+ expect(isUnlockResponse({ success: true, redirectUrl: '/home' })).toBe(true)
28
+ })
29
+
30
+ it('returns true for a valid error payload', () => {
31
+ expect(
32
+ isUnlockResponse({ success: false, error: 'Invalid password' })
33
+ ).toBe(true)
34
+ })
35
+
36
+ it('returns false when success is not a boolean', () => {
37
+ expect(isUnlockResponse({ success: 'yes' })).toBe(false)
38
+ })
39
+
40
+ it('returns false when redirectUrl is not a string', () => {
41
+ expect(isUnlockResponse({ redirectUrl: 123 })).toBe(false)
42
+ })
43
+
44
+ it('returns false when error is not a string', () => {
45
+ expect(isUnlockResponse({ error: true })).toBe(false)
46
+ })
47
+
48
+ it('returns false when all fields are undefined', () => {
49
+ expect(
50
+ isUnlockResponse({
51
+ success: undefined,
52
+ redirectUrl: undefined,
53
+ error: undefined,
54
+ })
55
+ ).toBe(false)
56
+ })
57
+ })