From: Eduardo San Martin Morote Date: Sat, 26 Oct 2019 14:22:12 +0000 (+0100) Subject: test: create folder for matchers X-Git-Tag: v4.0.0-alpha.0~181 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=619532a11158bd6386ef693051006d1b1f2d5a6e;p=thirdparty%2Fvuejs%2Frouter.git test: create folder for matchers --- diff --git a/__tests__/__snapshots__/matcher.spec.ts.snap b/__tests__/matcher/__snapshots__/resolve.spec.ts.snap similarity index 100% rename from __tests__/__snapshots__/matcher.spec.ts.snap rename to __tests__/matcher/__snapshots__/resolve.spec.ts.snap diff --git a/__tests__/matcher-ranking.spec.ts b/__tests__/matcher/ranking.spec.ts similarity index 97% rename from __tests__/matcher-ranking.spec.ts rename to __tests__/matcher/ranking.spec.ts index 7613a1eb..75126d38 100644 --- a/__tests__/matcher-ranking.spec.ts +++ b/__tests__/matcher/ranking.spec.ts @@ -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 diff --git a/__tests__/matcher.spec.ts b/__tests__/matcher/resolve.spec.ts similarity index 98% rename from __tests__/matcher.spec.ts rename to __tests__/matcher/resolve.spec.ts index 25812de7..034a5381 100644 --- a/__tests__/matcher.spec.ts +++ b/__tests__/matcher/resolve.spec.ts @@ -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