Skip to content

Commit 6e9c361

Browse files
committed
prettier
1 parent af589e5 commit 6e9c361

File tree

1 file changed

+36
-24
lines changed

1 file changed

+36
-24
lines changed

packages/router-core/tests/built.test.ts

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,11 @@ describe('work in progress', () => {
166166
const rebuildPath = (leaf: ReturnType<typeof parsePathname>) =>
167167
`/${leaf
168168
.slice(1)
169-
.map((s) => (s.value === '/' ? '' : `${s.prefixSegment ?? ''}${s.prefixSegment || s.suffixSegment ? '{' : ''}${s.value}${s.prefixSegment || s.suffixSegment ? '}' : ''}${s.suffixSegment ?? ''}`))
169+
.map((s) =>
170+
s.value === '/'
171+
? ''
172+
: `${s.prefixSegment ?? ''}${s.prefixSegment || s.suffixSegment ? '{' : ''}${s.value}${s.prefixSegment || s.suffixSegment ? '}' : ''}${s.suffixSegment ?? ''}`,
173+
)
170174
.join('/')}`
171175

172176
const initialDepth = 1
@@ -182,7 +186,12 @@ describe('work in progress', () => {
182186
for (const routeSegments of parsedRoutes) {
183187
if (resolved.has(routeSegments)) continue // already resolved
184188
console.log('\n')
185-
console.log('resolving: depth=', depth, 'parsed=', logParsed(routeSegments))
189+
console.log(
190+
'resolving: depth=',
191+
depth,
192+
'parsed=',
193+
logParsed(routeSegments),
194+
)
186195
console.log('\u001b[34m' + fn + '\u001b[0m')
187196
const currentSegment = routeSegments[depth]
188197
if (!currentSegment) {
@@ -230,28 +239,28 @@ describe('work in progress', () => {
230239
)
231240
if (skipDepth === -1) skipDepth = routeSegments.length - depth - 1
232241
const lCondition =
233-
skipDepth || depth > initialDepth
234-
? `l > ${depth + skipDepth}`
235-
: ''
242+
skipDepth || depth > initialDepth ? `l > ${depth + skipDepth}` : ''
236243
const skipConditions =
237-
Array.from(
238-
{ length: skipDepth + 1 },
239-
(_, i) => {
240-
const segment = candidates[0]![depth + i]!
241-
if (segment.type === 1) {
242-
const conditions = []
243-
if (segment.prefixSegment) {
244-
conditions.push(`baseSegments[${depth + i}].value.startsWith('${segment.prefixSegment}')`)
245-
}
246-
if (segment.suffixSegment) {
247-
conditions.push(`baseSegments[${depth + i}].value.endsWith('${segment.suffixSegment}')`)
248-
}
249-
return conditions.join(' && ')
244+
Array.from({ length: skipDepth + 1 }, (_, i) => {
245+
const segment = candidates[0]![depth + i]!
246+
if (segment.type === 1) {
247+
const conditions = []
248+
if (segment.prefixSegment) {
249+
conditions.push(
250+
`baseSegments[${depth + i}].value.startsWith('${segment.prefixSegment}')`,
251+
)
250252
}
251-
return `baseSegments[${depth + i}].value === '${segment.value}'`
253+
if (segment.suffixSegment) {
254+
conditions.push(
255+
`baseSegments[${depth + i}].value.endsWith('${segment.suffixSegment}')`,
256+
)
257+
}
258+
return conditions.join(' && ')
252259
}
253-
).filter(Boolean).join(`\n${indent} && `) +
254-
(skipDepth ? `\n${indent}` : '')
260+
return `baseSegments[${depth + i}].value === '${segment.value}'`
261+
})
262+
.filter(Boolean)
263+
.join(`\n${indent} && `) + (skipDepth ? `\n${indent}` : '')
255264
const hasCondition = Boolean(lCondition || skipConditions)
256265
if (hasCondition) {
257266
fn += `\n${indent}if (${lCondition}${lCondition && skipConditions ? ' && ' : ''}${skipConditions}) {`
@@ -266,7 +275,11 @@ describe('work in progress', () => {
266275
throw new Error('Implementation error: this should not happen')
267276
}
268277
if (deeper.length > 0) {
269-
recursiveStaticMatch(deeper, depth + 1 + skipDepth, hasCondition ? indent + ' ' : indent)
278+
recursiveStaticMatch(
279+
deeper,
280+
depth + 1 + skipDepth,
281+
hasCondition ? indent + ' ' : indent,
282+
)
270283
}
271284
if (leaves.length > 1) {
272285
throw new Error(
@@ -528,7 +541,7 @@ describe('work in progress', () => {
528541
'/foo/qux',
529542
'/a/user-123',
530543
'/files/hello-world.txt',
531-
'/something/foo/bar'
544+
'/something/foo/bar',
532545
])('matching %s', (s) => {
533546
const originalMatch = originalMatcher(s)
534547
const buildMatch = buildMatcher(parsePathname, s)
@@ -538,4 +551,3 @@ describe('work in progress', () => {
538551
expect(buildMatch).toBe(originalMatch)
539552
})
540553
})
541-

0 commit comments

Comments
 (0)