]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
test: stricter no match test
authorEduardo San Martin Morote <posva13@gmail.com>
Thu, 9 Jan 2025 11:04:28 +0000 (12:04 +0100)
committerEduardo San Martin Morote <posva13@gmail.com>
Thu, 9 Jan 2025 11:04:28 +0000 (12:04 +0100)
packages/router/src/new-route-resolver/matcher-resolve.spec.ts

index a73a0584125f9f78278263127594b92f65fcb28e..66ca21a896123dd64e9f266f3a70865d2252b20f 100644 (file)
@@ -188,16 +188,21 @@ describe('RouterMatcher.resolve', () => {
 
     // console.log({ toLocation, resolved, expectedLocation, resolvedFrom })
 
-    expect(
-      matcher.resolve(
-        // FIXME: should work now
-        // @ts-expect-error
-        typeof toLocation === 'string' ? { path: toLocation } : toLocation,
-        resolvedFrom === START_LOCATION ? undefined : resolvedFrom
-      )
-    ).toMatchObject({
-      ...resolved,
-    })
+    const result = matcher.resolve(
+      // FIXME: should work now
+      // @ts-expect-error
+      typeof toLocation === 'string' ? { path: toLocation } : toLocation,
+      resolvedFrom === START_LOCATION ? undefined : resolvedFrom
+    )
+
+    if (
+      expectedLocation.name === undefined ||
+      expectedLocation.name !== NO_MATCH_LOCATION.name
+    ) {
+      expect(result.name).not.toBe(NO_MATCH_LOCATION.name)
+    }
+
+    expect(result).toMatchObject(resolved)
   }
 
   describe('LocationAsPath', () => {
@@ -273,7 +278,7 @@ describe('RouterMatcher.resolve', () => {
       assertRecordMatch(
         { path: '/', components },
         { path: '/foo' },
-        { params: {}, path: '/foo', matched: [] }
+        NO_MATCH_LOCATION
       )
     })