@xivdyetools/test-utils 1.0.0
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.
- package/LICENSE +37 -0
- package/README.md +144 -0
- package/dist/assertions/index.d.ts +7 -0
- package/dist/assertions/index.d.ts.map +1 -0
- package/dist/assertions/index.js +7 -0
- package/dist/assertions/index.js.map +1 -0
- package/dist/assertions/response.d.ts +84 -0
- package/dist/assertions/response.d.ts.map +1 -0
- package/dist/assertions/response.js +125 -0
- package/dist/assertions/response.js.map +1 -0
- package/dist/auth/context.d.ts +55 -0
- package/dist/auth/context.d.ts.map +1 -0
- package/dist/auth/context.js +95 -0
- package/dist/auth/context.js.map +1 -0
- package/dist/auth/headers.d.ts +64 -0
- package/dist/auth/headers.d.ts.map +1 -0
- package/dist/auth/headers.js +101 -0
- package/dist/auth/headers.js.map +1 -0
- package/dist/auth/index.d.ts +10 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +10 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/jwt.d.ts +76 -0
- package/dist/auth/jwt.d.ts.map +1 -0
- package/dist/auth/jwt.js +77 -0
- package/dist/auth/jwt.js.map +1 -0
- package/dist/auth/signature.d.ts +64 -0
- package/dist/auth/signature.d.ts.map +1 -0
- package/dist/auth/signature.js +75 -0
- package/dist/auth/signature.js.map +1 -0
- package/dist/cloudflare/analytics.d.ts +55 -0
- package/dist/cloudflare/analytics.d.ts.map +1 -0
- package/dist/cloudflare/analytics.js +44 -0
- package/dist/cloudflare/analytics.js.map +1 -0
- package/dist/cloudflare/d1.d.ts +101 -0
- package/dist/cloudflare/d1.d.ts.map +1 -0
- package/dist/cloudflare/d1.js +148 -0
- package/dist/cloudflare/d1.js.map +1 -0
- package/dist/cloudflare/fetcher.d.ts +72 -0
- package/dist/cloudflare/fetcher.d.ts.map +1 -0
- package/dist/cloudflare/fetcher.js +136 -0
- package/dist/cloudflare/fetcher.js.map +1 -0
- package/dist/cloudflare/index.d.ts +12 -0
- package/dist/cloudflare/index.d.ts.map +1 -0
- package/dist/cloudflare/index.js +12 -0
- package/dist/cloudflare/index.js.map +1 -0
- package/dist/cloudflare/kv.d.ts +85 -0
- package/dist/cloudflare/kv.d.ts.map +1 -0
- package/dist/cloudflare/kv.js +138 -0
- package/dist/cloudflare/kv.js.map +1 -0
- package/dist/cloudflare/r2.d.ts +88 -0
- package/dist/cloudflare/r2.d.ts.map +1 -0
- package/dist/cloudflare/r2.js +127 -0
- package/dist/cloudflare/r2.js.map +1 -0
- package/dist/constants/index.d.ts +8 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +8 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/pkce.d.ts +89 -0
- package/dist/constants/pkce.d.ts.map +1 -0
- package/dist/constants/pkce.js +107 -0
- package/dist/constants/pkce.js.map +1 -0
- package/dist/constants/secrets.d.ts +72 -0
- package/dist/constants/secrets.d.ts.map +1 -0
- package/dist/constants/secrets.js +73 -0
- package/dist/constants/secrets.js.map +1 -0
- package/dist/dom/canvas.d.ts +108 -0
- package/dist/dom/canvas.d.ts.map +1 -0
- package/dist/dom/canvas.js +125 -0
- package/dist/dom/canvas.js.map +1 -0
- package/dist/dom/fetch.d.ts +69 -0
- package/dist/dom/fetch.d.ts.map +1 -0
- package/dist/dom/fetch.js +107 -0
- package/dist/dom/fetch.js.map +1 -0
- package/dist/dom/index.d.ts +12 -0
- package/dist/dom/index.d.ts.map +1 -0
- package/dist/dom/index.js +12 -0
- package/dist/dom/index.js.map +1 -0
- package/dist/dom/localStorage.d.ts +80 -0
- package/dist/dom/localStorage.d.ts.map +1 -0
- package/dist/dom/localStorage.js +124 -0
- package/dist/dom/localStorage.js.map +1 -0
- package/dist/dom/matchMedia.d.ts +51 -0
- package/dist/dom/matchMedia.d.ts.map +1 -0
- package/dist/dom/matchMedia.js +120 -0
- package/dist/dom/matchMedia.js.map +1 -0
- package/dist/dom/resizeObserver.d.ts +68 -0
- package/dist/dom/resizeObserver.d.ts.map +1 -0
- package/dist/dom/resizeObserver.js +99 -0
- package/dist/dom/resizeObserver.js.map +1 -0
- package/dist/factories/category.d.ts +74 -0
- package/dist/factories/category.d.ts.map +1 -0
- package/dist/factories/category.js +99 -0
- package/dist/factories/category.js.map +1 -0
- package/dist/factories/dye.d.ts +76 -0
- package/dist/factories/dye.d.ts.map +1 -0
- package/dist/factories/dye.js +211 -0
- package/dist/factories/dye.js.map +1 -0
- package/dist/factories/index.d.ts +13 -0
- package/dist/factories/index.d.ts.map +1 -0
- package/dist/factories/index.js +14 -0
- package/dist/factories/index.js.map +1 -0
- package/dist/factories/preset.d.ts +105 -0
- package/dist/factories/preset.d.ts.map +1 -0
- package/dist/factories/preset.js +170 -0
- package/dist/factories/preset.js.map +1 -0
- package/dist/factories/user.d.ts +74 -0
- package/dist/factories/user.d.ts.map +1 -0
- package/dist/factories/user.js +115 -0
- package/dist/factories/user.js.map +1 -0
- package/dist/factories/vote.d.ts +55 -0
- package/dist/factories/vote.d.ts.map +1 -0
- package/dist/factories/vote.js +68 -0
- package/dist/factories/vote.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/counters.d.ts +35 -0
- package/dist/utils/counters.d.ts.map +1 -0
- package/dist/utils/counters.js +53 -0
- package/dist/utils/counters.js.map +1 -0
- package/dist/utils/crypto.d.ts +42 -0
- package/dist/utils/crypto.d.ts.map +1 -0
- package/dist/utils/crypto.js +72 -0
- package/dist/utils/crypto.js.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +88 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dye factory functions and mock data for testing
|
|
3
|
+
*
|
|
4
|
+
* Provides mock dye data and factory functions for testing
|
|
5
|
+
* dye-related functionality.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { mockDyes, createMockDye } from '@xivdyetools/test-utils/factories';
|
|
10
|
+
*
|
|
11
|
+
* // Use predefined mock dyes
|
|
12
|
+
* const dyes = mockDyes;
|
|
13
|
+
*
|
|
14
|
+
* // Create a custom mock dye
|
|
15
|
+
* const dye = createMockDye({ name: 'Custom Dye', hex: '#FF0000' });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
import { nextId } from '../utils/counters.js';
|
|
19
|
+
/**
|
|
20
|
+
* Sample mock dyes for testing
|
|
21
|
+
*
|
|
22
|
+
* A small set of dyes covering different categories and properties.
|
|
23
|
+
*/
|
|
24
|
+
export const mockDyes = [
|
|
25
|
+
{
|
|
26
|
+
itemID: 5729,
|
|
27
|
+
id: 1,
|
|
28
|
+
name: 'Snow White',
|
|
29
|
+
hex: '#FFFFFF',
|
|
30
|
+
rgb: { r: 255, g: 255, b: 255 },
|
|
31
|
+
hsv: { h: 0, s: 0, v: 100 },
|
|
32
|
+
category: 'White',
|
|
33
|
+
acquisition: 'Vendor',
|
|
34
|
+
cost: 216,
|
|
35
|
+
isMetallic: false,
|
|
36
|
+
isPastel: false,
|
|
37
|
+
isDark: false,
|
|
38
|
+
isCosmic: false,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
itemID: 5730,
|
|
42
|
+
id: 2,
|
|
43
|
+
name: 'Soot Black',
|
|
44
|
+
hex: '#000000',
|
|
45
|
+
rgb: { r: 0, g: 0, b: 0 },
|
|
46
|
+
hsv: { h: 0, s: 0, v: 0 },
|
|
47
|
+
category: 'Black',
|
|
48
|
+
acquisition: 'Vendor',
|
|
49
|
+
cost: 216,
|
|
50
|
+
isMetallic: false,
|
|
51
|
+
isPastel: false,
|
|
52
|
+
isDark: true,
|
|
53
|
+
isCosmic: false,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
itemID: 5731,
|
|
57
|
+
id: 3,
|
|
58
|
+
name: 'Dalamud Red',
|
|
59
|
+
hex: '#FF0000',
|
|
60
|
+
rgb: { r: 255, g: 0, b: 0 },
|
|
61
|
+
hsv: { h: 0, s: 100, v: 100 },
|
|
62
|
+
category: 'Red',
|
|
63
|
+
acquisition: 'Crafted',
|
|
64
|
+
cost: 500,
|
|
65
|
+
isMetallic: false,
|
|
66
|
+
isPastel: false,
|
|
67
|
+
isDark: false,
|
|
68
|
+
isCosmic: false,
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
itemID: 5732,
|
|
72
|
+
id: 4,
|
|
73
|
+
name: 'Royal Blue',
|
|
74
|
+
hex: '#0000FF',
|
|
75
|
+
rgb: { r: 0, g: 0, b: 255 },
|
|
76
|
+
hsv: { h: 240, s: 100, v: 100 },
|
|
77
|
+
category: 'Blue',
|
|
78
|
+
acquisition: 'Crafted',
|
|
79
|
+
cost: 500,
|
|
80
|
+
isMetallic: false,
|
|
81
|
+
isPastel: false,
|
|
82
|
+
isDark: false,
|
|
83
|
+
isCosmic: false,
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
itemID: 5733,
|
|
87
|
+
id: 5,
|
|
88
|
+
name: 'Metallic Gold',
|
|
89
|
+
hex: '#FFD700',
|
|
90
|
+
rgb: { r: 255, g: 215, b: 0 },
|
|
91
|
+
hsv: { h: 51, s: 100, v: 100 },
|
|
92
|
+
category: 'Yellow',
|
|
93
|
+
acquisition: 'Special',
|
|
94
|
+
cost: 1000,
|
|
95
|
+
isMetallic: true,
|
|
96
|
+
isPastel: false,
|
|
97
|
+
isDark: false,
|
|
98
|
+
isCosmic: false,
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
itemID: 5734,
|
|
102
|
+
id: 6,
|
|
103
|
+
name: 'Pastel Pink',
|
|
104
|
+
hex: '#FFB6C1',
|
|
105
|
+
rgb: { r: 255, g: 182, b: 193 },
|
|
106
|
+
hsv: { h: 351, s: 29, v: 100 },
|
|
107
|
+
category: 'Red',
|
|
108
|
+
acquisition: 'Vendor',
|
|
109
|
+
cost: 216,
|
|
110
|
+
isMetallic: false,
|
|
111
|
+
isPastel: true,
|
|
112
|
+
isDark: false,
|
|
113
|
+
isCosmic: false,
|
|
114
|
+
},
|
|
115
|
+
];
|
|
116
|
+
/**
|
|
117
|
+
* Creates a mock dye with custom properties
|
|
118
|
+
*
|
|
119
|
+
* @param overrides - Optional overrides for the default values
|
|
120
|
+
* @returns A Dye object
|
|
121
|
+
*/
|
|
122
|
+
export function createMockDye(overrides = {}) {
|
|
123
|
+
const id = overrides.id ?? nextId('dye');
|
|
124
|
+
const itemID = overrides.itemID ?? 5700 + id;
|
|
125
|
+
return {
|
|
126
|
+
itemID,
|
|
127
|
+
id,
|
|
128
|
+
name: `Test Dye ${id}`,
|
|
129
|
+
hex: '#888888',
|
|
130
|
+
rgb: { r: 136, g: 136, b: 136 },
|
|
131
|
+
hsv: { h: 0, s: 0, v: 53 },
|
|
132
|
+
category: 'Grey',
|
|
133
|
+
acquisition: 'Vendor',
|
|
134
|
+
cost: 216,
|
|
135
|
+
isMetallic: false,
|
|
136
|
+
isPastel: false,
|
|
137
|
+
isDark: false,
|
|
138
|
+
isCosmic: false,
|
|
139
|
+
...overrides,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Creates multiple mock dyes
|
|
144
|
+
*
|
|
145
|
+
* @param count - Number of dyes to create
|
|
146
|
+
* @param overrides - Optional overrides to apply to all dyes
|
|
147
|
+
* @returns Array of Dye objects
|
|
148
|
+
*/
|
|
149
|
+
export function createMockDyes(count, overrides = {}) {
|
|
150
|
+
return Array.from({ length: count }, () => createMockDye(overrides));
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Creates a metallic dye
|
|
154
|
+
*
|
|
155
|
+
* @param overrides - Optional overrides
|
|
156
|
+
* @returns A metallic Dye object
|
|
157
|
+
*/
|
|
158
|
+
export function createMetallicDye(overrides = {}) {
|
|
159
|
+
return createMockDye({
|
|
160
|
+
isMetallic: true,
|
|
161
|
+
...overrides,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Creates a pastel dye
|
|
166
|
+
*
|
|
167
|
+
* @param overrides - Optional overrides
|
|
168
|
+
* @returns A pastel Dye object
|
|
169
|
+
*/
|
|
170
|
+
export function createPastelDye(overrides = {}) {
|
|
171
|
+
return createMockDye({
|
|
172
|
+
isPastel: true,
|
|
173
|
+
...overrides,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Creates a dark dye
|
|
178
|
+
*
|
|
179
|
+
* @param overrides - Optional overrides
|
|
180
|
+
* @returns A dark Dye object
|
|
181
|
+
*/
|
|
182
|
+
export function createDarkDye(overrides = {}) {
|
|
183
|
+
return createMockDye({
|
|
184
|
+
isDark: true,
|
|
185
|
+
hex: '#333333',
|
|
186
|
+
rgb: { r: 51, g: 51, b: 51 },
|
|
187
|
+
hsv: { h: 0, s: 0, v: 20 },
|
|
188
|
+
...overrides,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Get a dye by ID from the mock dyes
|
|
193
|
+
*
|
|
194
|
+
* @param id - The dye ID
|
|
195
|
+
* @returns The Dye object or undefined
|
|
196
|
+
*/
|
|
197
|
+
export function getMockDyeById(id) {
|
|
198
|
+
return mockDyes.find((dye) => dye.id === id);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Get dyes by IDs from the mock dyes
|
|
202
|
+
*
|
|
203
|
+
* @param ids - Array of dye IDs
|
|
204
|
+
* @returns Array of Dye objects (missing IDs are filtered out)
|
|
205
|
+
*/
|
|
206
|
+
export function getMockDyesByIds(ids) {
|
|
207
|
+
return ids
|
|
208
|
+
.map((id) => getMockDyeById(id))
|
|
209
|
+
.filter((dye) => dye !== undefined);
|
|
210
|
+
}
|
|
211
|
+
//# sourceMappingURL=dye.js.map
|
|
@@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,cAAc,CAAC,EAAE,CAAC,CAAC;SAC/B,MAAM,CAAC,CAAC,GAAG,EAAc,EAAE,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain object factories for testing
|
|
3
|
+
*
|
|
4
|
+
* Provides factory functions to create mock domain objects
|
|
5
|
+
* with sensible defaults and auto-incrementing IDs.
|
|
6
|
+
*/
|
|
7
|
+
export * from './preset.js';
|
|
8
|
+
export * from './category.js';
|
|
9
|
+
export * from './vote.js';
|
|
10
|
+
export * from './user.js';
|
|
11
|
+
export * from './dye.js';
|
|
12
|
+
export { resetCounters, resetCounter, getCounterValue } from '../utils/counters.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/factories/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AAGzB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain object factories for testing
|
|
3
|
+
*
|
|
4
|
+
* Provides factory functions to create mock domain objects
|
|
5
|
+
* with sensible defaults and auto-incrementing IDs.
|
|
6
|
+
*/
|
|
7
|
+
export * from './preset.js';
|
|
8
|
+
export * from './category.js';
|
|
9
|
+
export * from './vote.js';
|
|
10
|
+
export * from './user.js';
|
|
11
|
+
export * from './dye.js';
|
|
12
|
+
// Re-export counter utilities for test setup
|
|
13
|
+
export { resetCounters, resetCounter, getCounterValue } from '../utils/counters.js';
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/factories/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AAEzB,6CAA6C;AAC7C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Preset factory functions for testing
|
|
3
|
+
*
|
|
4
|
+
* Provides functions to create mock presets, preset rows, and submissions.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* // Create a mock preset
|
|
9
|
+
* const preset = createMockPreset({ name: 'Custom Name' });
|
|
10
|
+
*
|
|
11
|
+
* // Create a database row
|
|
12
|
+
* const row = createMockPresetRow({ status: 'pending' });
|
|
13
|
+
*
|
|
14
|
+
* // Create a submission
|
|
15
|
+
* const submission = createMockSubmission({ dyes: [1, 2, 3, 4, 5] });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
import type { CommunityPreset, PresetSubmission, PresetStatus } from '@xivdyetools/types/preset';
|
|
19
|
+
/**
|
|
20
|
+
* Preset database row type (as stored in D1)
|
|
21
|
+
* Note: dyes and tags are JSON strings, is_curated is 0 or 1
|
|
22
|
+
*/
|
|
23
|
+
export interface PresetRow {
|
|
24
|
+
id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
description: string;
|
|
27
|
+
category_id: string;
|
|
28
|
+
dyes: string;
|
|
29
|
+
tags: string;
|
|
30
|
+
author_discord_id: string | null;
|
|
31
|
+
author_name: string | null;
|
|
32
|
+
vote_count: number;
|
|
33
|
+
status: string;
|
|
34
|
+
is_curated: number;
|
|
35
|
+
created_at: string;
|
|
36
|
+
updated_at: string;
|
|
37
|
+
dye_signature: string | null;
|
|
38
|
+
previous_values: string | null;
|
|
39
|
+
}
|
|
40
|
+
export type { CommunityPreset, PresetSubmission, PresetStatus };
|
|
41
|
+
/**
|
|
42
|
+
* Creates a mock preset submission
|
|
43
|
+
*
|
|
44
|
+
* @param overrides - Optional overrides for the default values
|
|
45
|
+
* @returns A PresetSubmission object
|
|
46
|
+
*/
|
|
47
|
+
export declare function createMockSubmission(overrides?: Partial<PresetSubmission>): PresetSubmission;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a mock preset row (as returned from database)
|
|
50
|
+
*
|
|
51
|
+
* Note: In the database, `dyes` and `tags` are JSON strings,
|
|
52
|
+
* and `is_curated` is a number (0 or 1).
|
|
53
|
+
*
|
|
54
|
+
* @param overrides - Optional overrides for the default values
|
|
55
|
+
* @returns A PresetRow object
|
|
56
|
+
*/
|
|
57
|
+
export declare function createMockPresetRow(overrides?: Partial<PresetRow>): PresetRow;
|
|
58
|
+
/**
|
|
59
|
+
* Creates a mock CommunityPreset (domain object)
|
|
60
|
+
*
|
|
61
|
+
* Note: In domain objects, `dyes` and `tags` are arrays,
|
|
62
|
+
* and `is_curated` is a boolean.
|
|
63
|
+
*
|
|
64
|
+
* @param overrides - Optional overrides for the default values
|
|
65
|
+
* @returns A CommunityPreset object
|
|
66
|
+
*/
|
|
67
|
+
export declare function createMockPreset(overrides?: Partial<CommunityPreset>): CommunityPreset;
|
|
68
|
+
/**
|
|
69
|
+
* Creates multiple mock presets
|
|
70
|
+
*
|
|
71
|
+
* @param count - Number of presets to create
|
|
72
|
+
* @param overrides - Optional overrides to apply to all presets
|
|
73
|
+
* @returns Array of CommunityPreset objects
|
|
74
|
+
*/
|
|
75
|
+
export declare function createMockPresets(count: number, overrides?: Partial<CommunityPreset>): CommunityPreset[];
|
|
76
|
+
/**
|
|
77
|
+
* Creates a preset with specific status
|
|
78
|
+
*
|
|
79
|
+
* @param status - The preset status
|
|
80
|
+
* @param overrides - Optional additional overrides
|
|
81
|
+
* @returns A CommunityPreset object
|
|
82
|
+
*/
|
|
83
|
+
export declare function createPresetWithStatus(status: PresetStatus, overrides?: Partial<CommunityPreset>): CommunityPreset;
|
|
84
|
+
/**
|
|
85
|
+
* Creates a curated preset
|
|
86
|
+
*
|
|
87
|
+
* @param overrides - Optional overrides
|
|
88
|
+
* @returns A curated CommunityPreset object
|
|
89
|
+
*/
|
|
90
|
+
export declare function createCuratedPreset(overrides?: Partial<CommunityPreset>): CommunityPreset;
|
|
91
|
+
/**
|
|
92
|
+
* Converts a CommunityPreset to a PresetRow (for database mocking)
|
|
93
|
+
*
|
|
94
|
+
* @param preset - The CommunityPreset to convert
|
|
95
|
+
* @returns A PresetRow object
|
|
96
|
+
*/
|
|
97
|
+
export declare function presetToRow(preset: CommunityPreset): PresetRow;
|
|
98
|
+
/**
|
|
99
|
+
* Converts a PresetRow to a CommunityPreset (for domain logic)
|
|
100
|
+
*
|
|
101
|
+
* @param row - The PresetRow to convert
|
|
102
|
+
* @returns A CommunityPreset object
|
|
103
|
+
*/
|
|
104
|
+
export declare function rowToPreset(row: PresetRow): CommunityPreset;
|
|
105
|
+
//# sourceMappingURL=preset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preset.d.ts","sourceRoot":"","sources":["../../src/factories/preset.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAChB,YAAY,EAEb,MAAM,2BAA2B,CAAC;AAGnC;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,WAAW,EAAE,MAAM,GAAG,IAAI,CA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functions to create mock presets, preset rows, and submissions.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* // Create a mock preset
|
|
9
|
+
* const preset = createMockPreset({ name: 'Custom Name' });
|
|
10
|
+
*
|
|
11
|
+
* // Create a database row
|
|
12
|
+
* const row = createMockPresetRow({ status: 'pending' });
|
|
13
|
+
*
|
|
14
|
+
* // Create a submission
|
|
15
|
+
* const submission = createMockSubmission({ dyes: [1, 2, 3, 4, 5] });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
import { nextStringId } from '../utils/counters.js';
|
|
19
|
+
/**
|
|
20
|
+
* Creates a mock preset submission
|
|
21
|
+
*
|
|
22
|
+
* @param overrides - Optional overrides for the default values
|
|
23
|
+
* @returns A PresetSubmission object
|
|
24
|
+
*/
|
|
25
|
+
export function createMockSubmission(overrides = {}) {
|
|
26
|
+
return {
|
|
27
|
+
name: 'Test Preset',
|
|
28
|
+
description: 'A test preset description that is long enough.',
|
|
29
|
+
category_id: 'aesthetics',
|
|
30
|
+
dyes: [1, 2, 3],
|
|
31
|
+
tags: ['test', 'mock'],
|
|
32
|
+
...overrides,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates a mock preset row (as returned from database)
|
|
37
|
+
*
|
|
38
|
+
* Note: In the database, `dyes` and `tags` are JSON strings,
|
|
39
|
+
* and `is_curated` is a number (0 or 1).
|
|
40
|
+
*
|
|
41
|
+
* @param overrides - Optional overrides for the default values
|
|
42
|
+
* @returns A PresetRow object
|
|
43
|
+
*/
|
|
44
|
+
export function createMockPresetRow(overrides = {}) {
|
|
45
|
+
const id = overrides.id ?? nextStringId('preset');
|
|
46
|
+
const now = new Date().toISOString();
|
|
47
|
+
return {
|
|
48
|
+
id,
|
|
49
|
+
name: 'Test Preset',
|
|
50
|
+
description: 'A test preset description',
|
|
51
|
+
category_id: 'aesthetics',
|
|
52
|
+
dyes: JSON.stringify([1, 2, 3]),
|
|
53
|
+
tags: JSON.stringify(['test', 'mock']),
|
|
54
|
+
author_discord_id: '123456789',
|
|
55
|
+
author_name: 'TestUser',
|
|
56
|
+
vote_count: 0,
|
|
57
|
+
status: 'approved',
|
|
58
|
+
is_curated: 0,
|
|
59
|
+
created_at: now,
|
|
60
|
+
updated_at: now,
|
|
61
|
+
dye_signature: JSON.stringify([1, 2, 3]),
|
|
62
|
+
previous_values: null,
|
|
63
|
+
...overrides,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Creates a mock CommunityPreset (domain object)
|
|
68
|
+
*
|
|
69
|
+
* Note: In domain objects, `dyes` and `tags` are arrays,
|
|
70
|
+
* and `is_curated` is a boolean.
|
|
71
|
+
*
|
|
72
|
+
* @param overrides - Optional overrides for the default values
|
|
73
|
+
* @returns A CommunityPreset object
|
|
74
|
+
*/
|
|
75
|
+
export function createMockPreset(overrides = {}) {
|
|
76
|
+
const id = overrides.id ?? nextStringId('preset');
|
|
77
|
+
const now = new Date().toISOString();
|
|
78
|
+
return {
|
|
79
|
+
id,
|
|
80
|
+
name: 'Test Preset',
|
|
81
|
+
description: 'A test preset description',
|
|
82
|
+
category_id: 'aesthetics',
|
|
83
|
+
dyes: [1, 2, 3],
|
|
84
|
+
tags: ['test', 'mock'],
|
|
85
|
+
author_discord_id: '123456789',
|
|
86
|
+
author_name: 'TestUser',
|
|
87
|
+
vote_count: 0,
|
|
88
|
+
status: 'approved',
|
|
89
|
+
is_curated: false,
|
|
90
|
+
created_at: now,
|
|
91
|
+
updated_at: now,
|
|
92
|
+
...overrides,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Creates multiple mock presets
|
|
97
|
+
*
|
|
98
|
+
* @param count - Number of presets to create
|
|
99
|
+
* @param overrides - Optional overrides to apply to all presets
|
|
100
|
+
* @returns Array of CommunityPreset objects
|
|
101
|
+
*/
|
|
102
|
+
export function createMockPresets(count, overrides = {}) {
|
|
103
|
+
return Array.from({ length: count }, (_, i) => createMockPreset({
|
|
104
|
+
name: `Test Preset ${i + 1}`,
|
|
105
|
+
...overrides,
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Creates a preset with specific status
|
|
110
|
+
*
|
|
111
|
+
* @param status - The preset status
|
|
112
|
+
* @param overrides - Optional additional overrides
|
|
113
|
+
* @returns A CommunityPreset object
|
|
114
|
+
*/
|
|
115
|
+
export function createPresetWithStatus(status, overrides = {}) {
|
|
116
|
+
return createMockPreset({ status, ...overrides });
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Creates a curated preset
|
|
120
|
+
*
|
|
121
|
+
* @param overrides - Optional overrides
|
|
122
|
+
* @returns A curated CommunityPreset object
|
|
123
|
+
*/
|
|
124
|
+
export function createCuratedPreset(overrides = {}) {
|
|
125
|
+
return createMockPreset({
|
|
126
|
+
is_curated: true,
|
|
127
|
+
status: 'approved',
|
|
128
|
+
...overrides,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Converts a CommunityPreset to a PresetRow (for database mocking)
|
|
133
|
+
*
|
|
134
|
+
* @param preset - The CommunityPreset to convert
|
|
135
|
+
* @returns A PresetRow object
|
|
136
|
+
*/
|
|
137
|
+
export function presetToRow(preset) {
|
|
138
|
+
return {
|
|
139
|
+
...preset,
|
|
140
|
+
dyes: JSON.stringify(preset.dyes),
|
|
141
|
+
tags: JSON.stringify(preset.tags),
|
|
142
|
+
is_curated: preset.is_curated ? 1 : 0,
|
|
143
|
+
dye_signature: JSON.stringify(preset.dyes),
|
|
144
|
+
previous_values: null,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Converts a PresetRow to a CommunityPreset (for domain logic)
|
|
149
|
+
*
|
|
150
|
+
* @param row - The PresetRow to convert
|
|
151
|
+
* @returns A CommunityPreset object
|
|
152
|
+
*/
|
|
153
|
+
export function rowToPreset(row) {
|
|
154
|
+
return {
|
|
155
|
+
id: row.id,
|
|
156
|
+
name: row.name,
|
|
157
|
+
description: row.description,
|
|
158
|
+
category_id: row.category_id,
|
|
159
|
+
dyes: JSON.parse(row.dyes),
|
|
160
|
+
tags: JSON.parse(row.tags),
|
|
161
|
+
author_discord_id: row.author_discord_id,
|
|
162
|
+
author_name: row.author_name,
|
|
163
|
+
vote_count: row.vote_count,
|
|
164
|
+
status: row.status,
|
|
165
|
+
is_curated: row.is_curated === 1,
|
|
166
|
+
created_at: row.created_at,
|
|
167
|
+
updated_at: row.updated_at,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=preset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preset.js","sourceRoot":"","sources":["../../src/factories/preset.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAQH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AA2BpD;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,YAAuC,EAAE;IAC5E,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,gDAAgD;QAC7D,WAAW,EAAE,YAAY;QACzB,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACf,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;QACtB,GAAG,SAAS;KACb,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CAAC,YAAgC,EAAE;IACpE,MAAM,EAAE,GAAG,SAAS,CAAC,EAAE,IAAI,YAAY,CAAC,QAAQ,CAAC,CAAC;IAClD,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAErC,OAAO;QACL,EAAE;QACF,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,2BAA2B;QACxC,WAAW,EAAE,YAAY;QACzB,IAAI,EAAE,IAAI,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AAG,CAAC,IAAI,CAAC;QAC1B,iBAAiB,EAAE,GAAG,CAAC,iBAAiB;QACxC,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,MAAM,EAAE,GAAG,CAAC,MAAsB;QAClC,UAAU,EAAE,GAAG,CAAC,UAAU,KAAK,CAAC;QAChC,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,UAAU,EAAE,GAAG,CAAC,UAAU;KAC3B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User factory functions for testing
|
|
3
|
+
*
|
|
4
|
+
* Provides functions to create mock users for OAuth and auth testing.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* const user = createMockUser({ username: 'TestPlayer' });
|
|
9
|
+
* const row = createMockUserRow({ auth_provider: 'discord' });
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
import type { AuthUser } from '@xivdyetools/types/auth';
|
|
13
|
+
export type { AuthUser };
|
|
14
|
+
/**
|
|
15
|
+
* User database row type
|
|
16
|
+
*/
|
|
17
|
+
export interface UserRow {
|
|
18
|
+
id: string;
|
|
19
|
+
discord_id: string | null;
|
|
20
|
+
xivauth_id: string | null;
|
|
21
|
+
auth_provider: string;
|
|
22
|
+
username: string;
|
|
23
|
+
avatar_url: string | null;
|
|
24
|
+
created_at: string;
|
|
25
|
+
updated_at: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Creates a mock user row (as returned from database)
|
|
29
|
+
*
|
|
30
|
+
* @param overrides - Optional overrides for the default values
|
|
31
|
+
* @returns A UserRow object
|
|
32
|
+
*/
|
|
33
|
+
export declare function createMockUserRow(overrides?: Partial<UserRow>): UserRow;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a mock AuthUser (domain object)
|
|
36
|
+
*
|
|
37
|
+
* @param overrides - Optional overrides for the default values
|
|
38
|
+
* @returns An AuthUser object
|
|
39
|
+
*/
|
|
40
|
+
export declare function createMockUser(overrides?: Partial<AuthUser>): AuthUser;
|
|
41
|
+
/**
|
|
42
|
+
* Creates multiple mock users
|
|
43
|
+
*
|
|
44
|
+
* @param count - Number of users to create
|
|
45
|
+
* @param overrides - Optional overrides to apply to all users
|
|
46
|
+
* @returns Array of AuthUser objects
|
|
47
|
+
*/
|
|
48
|
+
export declare function createMockUsers(count: number, overrides?: Partial<AuthUser>): AuthUser[];
|
|
49
|
+
/**
|
|
50
|
+
* Creates a Discord-authenticated user
|
|
51
|
+
*
|
|
52
|
+
* @param discordId - Discord user ID
|
|
53
|
+
* @param overrides - Optional additional overrides
|
|
54
|
+
* @returns An AuthUser object
|
|
55
|
+
*/
|
|
56
|
+
export declare function createDiscordUser(discordId: string, overrides?: Partial<AuthUser>): AuthUser;
|
|
57
|
+
/**
|
|
58
|
+
* Creates an XIVAuth-authenticated user
|
|
59
|
+
*
|
|
60
|
+
* @param xivauthId - XIVAuth user ID
|
|
61
|
+
* @param overrides - Optional additional overrides
|
|
62
|
+
* @returns An AuthUser object
|
|
63
|
+
*/
|
|
64
|
+
export declare function createXIVAuthUser(xivauthId: string, overrides?: Partial<AuthUser>): AuthUser;
|
|
65
|
+
/**
|
|
66
|
+
* Converts an AuthUser to a UserRow
|
|
67
|
+
*
|
|
68
|
+
* @param user - The AuthUser to convert
|
|
69
|
+
* @param discordId - Discord ID (if auth_provider is 'discord')
|
|
70
|
+
* @param xivauthId - XIVAuth ID (if auth_provider is 'xivauth')
|
|
71
|
+
* @returns A UserRow object
|
|
72
|
+
*/
|
|
73
|
+
export declare function userToRow(user: AuthUser, discordId?: string | null, xivauthId?: string | null): UserRow;
|
|
74
|
+
//# sourceMappingURL=user.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/factories/user.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;A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