]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
test: create folder for matchers
authorEduardo San Martin Morote <posva13@gmail.com>
Sat, 26 Oct 2019 14:22:12 +0000 (15:22 +0100)
committerEduardo San Martin Morote <posva13@gmail.com>
Sat, 26 Oct 2019 14:22:12 +0000 (15:22 +0100)
__tests__/matcher/__snapshots__/resolve.spec.ts.snap [moved from __tests__/__snapshots__/matcher.spec.ts.snap with 100% similarity]
__tests__/matcher/ranking.spec.ts [moved from __tests__/matcher-ranking.spec.ts with 97% similarity]
__tests__/matcher/resolve.spec.ts [moved from __tests__/matcher.spec.ts with 98% similarity]

similarity index 97%
rename from __tests__/matcher-ranking.spec.ts
rename to __tests__/matcher/ranking.spec.ts
index 7613a1ebf72391d6c78eb0cbd76282e82a49ac88..75126d38431874b07334eb88137071b7ec8fa1fb 100644 (file)
@@ -1,6 +1,6 @@
-import { createRouteMatcher, RouteMatcher } from '../src/matcher'
+import { createRouteMatcher, RouteMatcher } from '../../src/matcher'
 import { RegExpOptions } from 'path-to-regexp'
-import { RouteComponent } from '../src/types'
+import { RouteComponent } from '../../src/types'
 
 // @ts-ignore
 const component: RouteComponent = null
similarity index 98%
rename from __tests__/matcher.spec.ts
rename to __tests__/matcher/resolve.spec.ts
index 25812de7c143c3f4c8971bd12ad1a0fb700e8010..034a5381b80c34a3eaea61ee4ec37d9c273f4d0c 100644 (file)
@@ -1,4 +1,4 @@
-import { RouterMatcher } from '../src/matcher'
+import { RouterMatcher } from '../../src/matcher'
 import {
   START_LOCATION_NORMALIZED,
   RouteComponent,
@@ -6,12 +6,16 @@ import {
   MatcherLocation,
   MatcherLocationNormalized,
   MatcherLocationRedirect,
-} from '../src/types'
-import { normalizeRouteRecord } from './utils'
+} from '../../src/types'
+import { normalizeRouteRecord } from '../utils'
 
 // @ts-ignore
 const component: RouteComponent = null
 
+function createRouterMatcher(records: RouteRecord[]) {
+  return new RouterMatcher(records)
+}
+
 // for normalized records
 const components = { default: component }
 
@@ -24,7 +28,7 @@ describe('Router Matcher', () => {
       start: MatcherLocationNormalized = START_LOCATION_NORMALIZED
     ) {
       record = Array.isArray(record) ? record : [record]
-      const matcher = new RouterMatcher(record)
+      const matcher = createRouterMatcher(record)
 
       if (!('meta' in resolved)) {
         resolved.meta = record[0].meta || {}
@@ -335,7 +339,7 @@ describe('Router Matcher', () => {
           expected: MatcherLocationNormalized | MatcherLocationRedirect,
           currentLocation: MatcherLocationNormalized = START_LOCATION_NORMALIZED
         ) {
-          const matcher = new RouterMatcher(records)
+          const matcher = createRouterMatcher(records)
           const resolved = matcher.resolve(location, currentLocation)
           expect(resolved).toEqual(expected)
           return resolved