From: Eduardo San Martin Morote Date: Fri, 27 Sep 2019 10:03:11 +0000 (+0200) Subject: refactor: use ts for tests X-Git-Tag: v4.0.0-alpha.0~217 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=320863b20ce620c0add0ba6c6d14f3c482a0c699;p=thirdparty%2Fvuejs%2Frouter.git refactor: use ts for tests --- diff --git a/__tests__/errors.spec.js b/__tests__/errors.spec.ts similarity index 84% rename from __tests__/errors.spec.js rename to __tests__/errors.spec.ts index ae6c1f8a..0bd4ed63 100644 --- a/__tests__/errors.spec.js +++ b/__tests__/errors.spec.ts @@ -1,16 +1,10 @@ -// @ts-check -const fakePromise = require('faked-promise') -const { AbstractHistory } = require('../src/history/abstract') -const { Router } = require('../src/router') -const { - NavigationAborted, - NavigationCancelled, - NavigationGuardRedirect, -} = require('../src/errors') -const { components, tick } = require('./utils') +import { AbstractHistory } from '../src/history/abstract' +import { Router } from '../src/router' +import { NavigationAborted, NavigationGuardRedirect } from '../src/errors' +import { components, tick } from './utils' +import { RouteRecord } from '../src/types' -/** @type {import('../src/types').RouteRecord[]} */ -const routes = [ +const routes: RouteRecord[] = [ { path: '/', component: components.Home }, { path: '/foo', component: components.Foo, name: 'Foo' }, { path: '/to-foo', redirect: '/foo' }, diff --git a/__tests__/extractComponentsGuards.spec.js b/__tests__/extractComponentsGuards.spec.ts similarity index 80% rename from __tests__/extractComponentsGuards.spec.js rename to __tests__/extractComponentsGuards.spec.ts index 480274c8..a6f373f1 100644 --- a/__tests__/extractComponentsGuards.spec.js +++ b/__tests__/extractComponentsGuards.spec.ts @@ -1,7 +1,10 @@ -// @ts-check -const { extractComponentsGuards } = require('../src/utils') -const { START_LOCATION_NORMALIZED } = require('../src/types') -const { components, normalizeRouteRecord } = require('./utils') +import { extractComponentsGuards } from '../src/utils' +import { + START_LOCATION_NORMALIZED, + RouteRecord, + MatchedRouteRecord, +} from '../src/types' +import { components, normalizeRouteRecord } from './utils' /** @typedef {import('../src/types').RouteRecord} RouteRecord */ /** @typedef {import('../src/types').MatchedRouteRecord} MatchedRouteRecord */ @@ -13,15 +16,12 @@ const beforeRouteEnter = jest.fn() const to = START_LOCATION_NORMALIZED const from = START_LOCATION_NORMALIZED -/** @type {RouteRecord} */ -const NoGuard = { path: '/', component: components.Home } -/** @type {RouteRecord} */ -const SingleGuard = { +const NoGuard: RouteRecord = { path: '/', component: components.Home } +const SingleGuard: RouteRecord = { path: '/', component: { ...components.Home, beforeRouteEnter }, } -/** @type {RouteRecord} */ -const SingleGuardNamed = { +const SingleGuardNamed: RouteRecord = { path: '/', components: { default: { ...components.Home, beforeRouteEnter }, @@ -29,20 +29,18 @@ const SingleGuardNamed = { }, } -/** - * - * @param {Exclude} record - * @returns {MatchedRouteRecord} - */ -function makeAsync(record) { +function makeAsync( + record: Exclude +): MatchedRouteRecord { if ('components' in record) { const copy = { ...record } copy.components = Object.keys(record.components).reduce( (components, name) => { + // @ts-ignore components[name] = () => Promise.resolve(record.components[name]) return components }, - {} + {} as typeof record['components'] ) return copy } else { @@ -66,12 +64,10 @@ beforeEach(() => { }) }) -/** - * - * @param {Exclude[]} components - * @param {number} n - */ -async function checkGuards(components, n) { +async function checkGuards( + components: Exclude[], + n: number +) { beforeRouteEnter.mockClear() const guards = await extractComponentsGuards( // type is fine as we excluded RouteRecordRedirect in components argument diff --git a/__tests__/guards/component-beforeRouteEnter.spec.js b/__tests__/guards/component-beforeRouteEnter.spec.ts similarity index 90% rename from __tests__/guards/component-beforeRouteEnter.spec.js rename to __tests__/guards/component-beforeRouteEnter.spec.ts index 75bf4894..ea3a0d4f 100644 --- a/__tests__/guards/component-beforeRouteEnter.spec.js +++ b/__tests__/guards/component-beforeRouteEnter.spec.ts @@ -1,16 +1,12 @@ -// @ts-check -const { HTML5History } = require('../../src/history/html5') -const { Router } = require('../../src/router') -const fakePromise = require('faked-promise') -const { NAVIGATION_TYPES, createDom, noGuard } = require('../utils') - -/** @typedef {import('../../src/types').RouteRecord} RouteRecord */ -/** @typedef {import('../../src/router').RouterOptions} RouterOptions */ - -/** - * @param {Partial & { routes: RouteRecord[]}} options - */ -function createRouter(options) { +import { HTML5History } from '../../src/history/html5' +import { Router, RouterOptions } from '../../src/router' +import fakePromise from 'faked-promise' +import { NAVIGATION_TYPES, createDom, noGuard } from '../utils' +import { RouteRecord } from '../../src/types' + +function createRouter( + options: Partial & { routes: RouteRecord[] } +) { return new Router({ history: new HTML5History(), ...options, @@ -36,8 +32,7 @@ const nested = { nestedNestedParam: jest.fn(), } -/** @type {RouteRecord[]} */ -const routes = [ +const routes: RouteRecord[] = [ { path: '/', component: Home }, { path: '/foo', component: Foo }, { @@ -106,11 +101,11 @@ const routes = [ function resetMocks() { beforeRouteEnter.mockReset() for (const key in named) { - named[key].mockReset() + named[key as keyof typeof named].mockReset() } for (const key in nested) { - nested[key].mockReset() - nested[key].mockImplementation(noGuard) + nested[key as keyof typeof nested].mockReset() + nested[key as keyof typeof nested].mockImplementation(noGuard) } } @@ -200,7 +195,7 @@ describe('beforeRouteEnter', () => { template: `
`, beforeRouteEnter: spy, } - const [promise, resolve] = fakePromise() + const [promise, resolve] = fakePromise() const router = createRouter({ routes: [...routes, { path: '/async', component: () => promise }], }) diff --git a/__tests__/guards/component-beforeRouteLeave.spec.js b/__tests__/guards/component-beforeRouteLeave.spec.ts similarity index 90% rename from __tests__/guards/component-beforeRouteLeave.spec.js rename to __tests__/guards/component-beforeRouteLeave.spec.ts index 0c0f319e..aee7cca7 100644 --- a/__tests__/guards/component-beforeRouteLeave.spec.js +++ b/__tests__/guards/component-beforeRouteLeave.spec.ts @@ -1,16 +1,12 @@ -// @ts-check -const { HTML5History } = require('../../src/history/html5') -const { Router } = require('../../src/router') -const fakePromise = require('faked-promise') -const { NAVIGATION_TYPES, createDom, noGuard } = require('../utils') +import { HTML5History } from '../../src/history/html5' +import { Router, RouterOptions } from '../../src/router' +import { NAVIGATION_TYPES, createDom, noGuard } from '../utils' +import { RouteRecord } from '../../src/types' -/** @typedef {import('../../src/types').RouteRecord} RouteRecord */ -/** @typedef {import('../../src/router').RouterOptions} RouterOptions */ - -/** - * @param {Partial & { routes: RouteRecord[]}} options - */ -function createRouter(options) { +// TODO: refactor in utils +function createRouter( + options: Partial & { routes: RouteRecord[] } +) { return new Router({ history: new HTML5History(), ...options, @@ -32,8 +28,7 @@ const nested = { } const beforeRouteLeave = jest.fn() -/** @type {RouteRecord[]} */ -const routes = [ +const routes: RouteRecord[] = [ { path: '/', component: Home }, { path: '/foo', component: Foo }, { @@ -94,8 +89,8 @@ const routes = [ function resetMocks() { beforeRouteLeave.mockReset() for (const key in nested) { - nested[key].mockReset() - nested[key].mockImplementation(noGuard) + nested[key as keyof typeof nested].mockReset() + nested[key as keyof typeof nested].mockImplementation(noGuard) } } diff --git a/__tests__/guards/component-beforeRouteUpdate.spec.js b/__tests__/guards/component-beforeRouteUpdate.spec.ts similarity index 85% rename from __tests__/guards/component-beforeRouteUpdate.spec.js rename to __tests__/guards/component-beforeRouteUpdate.spec.ts index 925182bd..46172ba8 100644 --- a/__tests__/guards/component-beforeRouteUpdate.spec.js +++ b/__tests__/guards/component-beforeRouteUpdate.spec.ts @@ -1,13 +1,13 @@ -// @ts-check -const { HTML5History } = require('../../src/history/html5') -const { Router } = require('../../src/router') -const fakePromise = require('faked-promise') -const { NAVIGATION_TYPES, createDom, noGuard } = require('../utils') +import { HTML5History } from '../../src/history/html5' +import { Router } from '../../src/router' +import fakePromise from 'faked-promise' +import { NAVIGATION_TYPES, createDom, noGuard } from '../utils' -/** - * @param {Partial & { routes: import('../../src/types').RouteRecord[]}} options - */ -function createRouter(options) { +function createRouter( + options: Partial & { + routes: import('../../src/types').RouteRecord[] + } +) { return new Router({ history: new HTML5History(), ...options, diff --git a/__tests__/guards/global-after.spec.js b/__tests__/guards/global-after.spec.ts similarity index 88% rename from __tests__/guards/global-after.spec.js rename to __tests__/guards/global-after.spec.ts index 2dc8fbf6..2a589401 100644 --- a/__tests__/guards/global-after.spec.js +++ b/__tests__/guards/global-after.spec.ts @@ -1,12 +1,12 @@ -// @ts-check -const { HTML5History } = require('../../src/history/html5') -const { Router } = require('../../src/router') -const { NAVIGATION_TYPES, createDom } = require('../utils') +import { HTML5History } from '../../src/history/html5' +import { Router } from '../../src/router' +import { NAVIGATION_TYPES, createDom } from '../utils' -/** - * @param {Partial & { routes: import('../../src/types').RouteRecord[]}} options - */ -function createRouter(options) { +function createRouter( + options: Partial & { + routes: import('../../src/types').RouteRecord[] + } +) { return new Router({ history: new HTML5History(), ...options, diff --git a/__tests__/guards/global-beforeEach.spec.js b/__tests__/guards/global-beforeEach.spec.ts similarity index 93% rename from __tests__/guards/global-beforeEach.spec.js rename to __tests__/guards/global-beforeEach.spec.ts index dac1dce7..c0e1b32c 100644 --- a/__tests__/guards/global-beforeEach.spec.js +++ b/__tests__/guards/global-beforeEach.spec.ts @@ -1,16 +1,12 @@ -// @ts-check -const { HTML5History } = require('../../src/history/html5') -const { Router } = require('../../src/router') -const fakePromise = require('faked-promise') -const { NAVIGATION_TYPES, createDom, tick, noGuard } = require('../utils') - -/** @typedef {import('../../src/types').RouteRecord} RouteRecord */ -/** @typedef {import('../../src/router').RouterOptions} RouterOptions */ - -/** - * @param {Partial & { routes: RouteRecord[]}} options - */ -function createRouter(options) { +import { HTML5History } from '../../src/history/html5' +import { Router, RouterOptions } from '../../src/router' +import fakePromise from 'faked-promise' +import { NAVIGATION_TYPES, createDom, tick, noGuard } from '../utils' +import { RouteRecord, RouteLocation } from '../../src/types' + +function createRouter( + options: Partial & { routes: RouteRecord[] } +) { return new Router({ history: new HTML5History(), ...options, @@ -124,7 +120,7 @@ describe('router.beforeEach', () => { expect(router.currentRoute.fullPath).toBe('/other') }) - async function assertRedirect(redirectFn) { + async function assertRedirect(redirectFn: (i: string) => RouteLocation) { const spy = jest.fn() const router = createRouter({ routes }) await router.push('/') @@ -132,7 +128,7 @@ describe('router.beforeEach', () => { // only allow going to /other const i = Number(to.params.i) if (i >= 3) next() - else next(redirectFn(i + 1)) + else next(redirectFn(String(i + 1))) }) router.beforeEach(spy) expect(spy).not.toHaveBeenCalled() diff --git a/__tests__/guards/route-beforeEnter.spec.js b/__tests__/guards/route-beforeEnter.spec.ts similarity index 91% rename from __tests__/guards/route-beforeEnter.spec.js rename to __tests__/guards/route-beforeEnter.spec.ts index d3b6aff9..cee5dbf7 100644 --- a/__tests__/guards/route-beforeEnter.spec.js +++ b/__tests__/guards/route-beforeEnter.spec.ts @@ -1,16 +1,12 @@ -// @ts-check -const { HTML5History } = require('../../src/history/html5') -const { Router } = require('../../src/router') -const fakePromise = require('faked-promise') -const { NAVIGATION_TYPES, createDom, noGuard, tick } = require('../utils') +import { HTML5History } from '../../src/history/html5' +import { Router, RouterOptions } from '../../src/router' +import fakePromise from 'faked-promise' +import { NAVIGATION_TYPES, createDom, noGuard, tick } from '../utils' +import { RouteRecord } from '../../src/types' -/** @typedef {import('../../src/types').RouteRecord} RouteRecord */ -/** @typedef {import('../../src/router').RouterOptions} RouterOptions */ - -/** - * @param {Partial & { routes: RouteRecord[]}} options - */ -function createRouter(options) { +function createRouter( + options: Partial & { routes: RouteRecord[] } +) { return new Router({ history: new HTML5History(), ...options, @@ -97,8 +93,8 @@ function resetMocks() { spy.mockImplementationOnce(noGuard) }) for (const key in nested) { - nested[key].mockReset() - nested[key].mockImplementation(noGuard) + nested[key as keyof typeof nested].mockReset() + nested[key as keyof typeof nested].mockImplementation(noGuard) } } diff --git a/__tests__/history/abstract.spec.js b/__tests__/history/abstract.spec.ts similarity index 97% rename from __tests__/history/abstract.spec.js rename to __tests__/history/abstract.spec.ts index 8d935fa8..e2fc6683 100644 --- a/__tests__/history/abstract.spec.js +++ b/__tests__/history/abstract.spec.ts @@ -1,7 +1,6 @@ -// @ts-check -const { AbstractHistory } = require('../../src/history/abstract') -const { START } = require('../../src/history/base') +import { AbstractHistory } from '../../src/history/abstract' +import { START } from '../../src/history/base' /** @type {import('../../src/history/base').HistoryLocation} */ const loc = { diff --git a/__tests__/history/html5.spec.js b/__tests__/history/html5.spec.ts similarity index 77% rename from __tests__/history/html5.spec.js rename to __tests__/history/html5.spec.ts index 07cc01c5..5d291868 100644 --- a/__tests__/history/html5.spec.js +++ b/__tests__/history/html5.spec.ts @@ -1,6 +1,5 @@ -// @ts-check -const { HTML5History } = require('../../src/history/html5') -const { createDom } = require('../utils') +import { HTML5History } from '../../src/history/html5' +import { createDom } from '../utils' // TODO: is it really worth testing this implementation on jest or is it // better to directly use e2e tests instead diff --git a/__tests__/matcher-ranking.spec.js b/__tests__/matcher-ranking.spec.ts similarity index 80% rename from __tests__/matcher-ranking.spec.js rename to __tests__/matcher-ranking.spec.ts index c6bc6a1d..4a3b6b85 100644 --- a/__tests__/matcher-ranking.spec.js +++ b/__tests__/matcher-ranking.spec.ts @@ -1,29 +1,19 @@ -// @ts-check -const { createRouteMatcher } = require('../src/matcher') - -/** @type {RouteComponent} */ -const component = null - -/** @typedef {import('../src/types').RouteRecord} RouteRecord */ -/** @typedef {import('../src/types').RouteComponent} RouteComponent */ -/** @typedef {import('../src/types').MatchedRouteRecord} MatchedRouteRecord */ -/** @typedef {import('../src/types').MatcherLocation} MatcherLocation */ -/** @typedef {import('../src/types').MatcherLocationRedirect} MatcherLocationRedirect */ -/** @typedef {import('../src/types').MatcherLocationNormalized} MatcherLocationNormalized */ -/** @typedef {import('../src/matcher').RouteMatcher} RouteMatcher */ -/** @typedef {import('path-to-regexp').RegExpOptions} RegExpOptions */ - -function stringifyOptions(options) { +import { createRouteMatcher } from '../src/matcher' +import { RegExpOptions } from 'path-to-regexp' +import { RouteComponent } from '../src/types' + +// @ts-ignore +const component: RouteComponent = null + +function stringifyOptions(options: any) { return Object.keys(options).length ? ` (${JSON.stringify(options)})` : '' } describe('createRouteMatcher', () => { - /** - * - * @param {Array} paths - * @param {RegExpOptions} options - */ - function checkPathOrder(paths, options = {}) { + function checkPathOrder( + paths: Array, + options: RegExpOptions = {} + ) { const normalizedPaths = paths.map(pathOrCombined => { if (Array.isArray(pathOrCombined)) return [pathOrCombined[0], { ...options, ...pathOrCombined[1] }] diff --git a/__tests__/matcher.spec.js b/__tests__/matcher.spec.ts similarity index 82% rename from __tests__/matcher.spec.js rename to __tests__/matcher.spec.ts index bc4b6ba9..435981c5 100644 --- a/__tests__/matcher.spec.js +++ b/__tests__/matcher.spec.ts @@ -1,32 +1,27 @@ -// @ts-check -const { RouterMatcher } = require('../src/matcher') -const { START_LOCATION_NORMALIZED } = require('../src/types') -const { normalizeRouteRecord } = require('./utils') - -/** @type {RouteComponent} */ -const component = null - -/** @typedef {import('../src/types').RouteRecord} RouteRecord */ -/** @typedef {import('../src/types').RouteComponent} RouteComponent */ -/** @typedef {import('../src/types').MatchedRouteRecord} MatchedRouteRecord */ -/** @typedef {import('../src/types').MatcherLocation} MatcherLocation */ -/** @typedef {import('../src/types').MatcherLocationRedirect} MatcherLocationRedirect */ -/** @typedef {import('../src/types').MatcherLocationNormalized} MatcherLocationNormalized */ +import { RouterMatcher } from '../src/matcher' +import { + START_LOCATION_NORMALIZED, + RouteComponent, + RouteRecord, + MatcherLocation, + MatcherLocationNormalized, + MatcherLocationRedirect, +} from '../src/types' +import { normalizeRouteRecord } from './utils' + +// @ts-ignore +const component: RouteComponent = null + +// for normalized records +const components = { default: component } describe('Router Matcher', () => { describe('resolve', () => { - /** - * - * @param {RouteRecord | RouteRecord[]} record Record or records we are testing the matcher against - * @param {MatcherLocation} location location we want to reolve against - * @param {Partial> }>>} resolved Expected resolved location given by the matcher - * @param {import('../src/types').Override> }>} [start] Optional currentLocation used when resolving - */ function assertRecordMatch( - record, - location, - resolved, - start = START_LOCATION_NORMALIZED + record: RouteRecord | RouteRecord[], + location: MatcherLocation, + resolved: Partial, + start: MatcherLocationNormalized = START_LOCATION_NORMALIZED ) { record = Array.isArray(record) ? record : [record] const matcher = new RouterMatcher(record) @@ -45,7 +40,8 @@ describe('Router Matcher', () => { throw new Error('not handled') } else { // use one single record - if (!('matched' in resolved)) + if (!resolved.matched) + // @ts-ignore resolved.matched = record.map(normalizeRouteRecord) else resolved.matched = resolved.matched.map(normalizeRouteRecord) } @@ -84,9 +80,9 @@ describe('Router Matcher', () => { * @returns {any} error */ function assertErrorMatch( - record, - location, - start = START_LOCATION_NORMALIZED + record: RouteRecord | RouteRecord[], + location: MatcherLocation, + start: MatcherLocationNormalized = START_LOCATION_NORMALIZED ) { try { assertRecordMatch(record, location, {}, start) @@ -98,7 +94,7 @@ describe('Router Matcher', () => { describe('LocationAsPath', () => { it('resolves a normal path', () => { assertRecordMatch( - { path: '/', name: 'Home', component }, + { path: '/', name: 'Home', components }, { path: '/' }, { name: 'Home', path: '/', params: {} } ) @@ -106,7 +102,7 @@ describe('Router Matcher', () => { it('resolves a normal path without name', () => { assertRecordMatch( - { path: '/', component }, + { path: '/', components }, { path: '/' }, { name: undefined, path: '/', params: {} } ) @@ -114,7 +110,7 @@ describe('Router Matcher', () => { it('resolves a path with params', () => { assertRecordMatch( - { path: '/users/:id', name: 'User', component }, + { path: '/users/:id', name: 'User', components }, { path: '/users/posva' }, { name: 'User', params: { id: 'posva' } } ) @@ -122,7 +118,7 @@ describe('Router Matcher', () => { it('resolves a path with multiple params', () => { assertRecordMatch( - { path: '/users/:id/:other', name: 'User', component }, + { path: '/users/:id/:other', name: 'User', components }, { path: '/users/posva/hey' }, { name: 'User', params: { id: 'posva', other: 'hey' } } ) @@ -130,7 +126,7 @@ describe('Router Matcher', () => { it('resolves a path with multiple params but no name', () => { assertRecordMatch( - { path: '/users/:id/:other', component }, + { path: '/users/:id/:other', components }, { path: '/users/posva/hey' }, { name: undefined, params: { id: 'posva', other: 'hey' } } ) @@ -138,7 +134,7 @@ describe('Router Matcher', () => { it('throws if the path does not exists', () => { expect( - assertErrorMatch({ path: '/', component }, { path: '/foo' }) + assertErrorMatch({ path: '/', components }, { path: '/foo' }) ).toMatchInlineSnapshot( `[NoRouteMatchError: No match for {"path":"/foo","params":{},"query":{},"hash":"","fullPath":"/"}]` ) @@ -148,7 +144,7 @@ describe('Router Matcher', () => { describe('LocationAsName', () => { it('matches a name', () => { assertRecordMatch( - { path: '/home', name: 'Home', component }, + { path: '/home', name: 'Home', components }, { name: 'Home' }, { name: 'Home', path: '/home' } ) @@ -156,7 +152,7 @@ describe('Router Matcher', () => { it('matches a name and fill params', () => { assertRecordMatch( - { path: '/users/:id/m/:role', name: 'UserEdit', component }, + { path: '/users/:id/m/:role', name: 'UserEdit', components }, { name: 'UserEdit', params: { id: 'posva', role: 'admin' } }, { name: 'UserEdit', path: '/users/posva/m/admin' } ) @@ -164,7 +160,7 @@ describe('Router Matcher', () => { it('throws if the named route does not exists', () => { expect( - assertErrorMatch({ path: '/', component }, { name: 'Home' }) + assertErrorMatch({ path: '/', components }, { name: 'Home' }) ).toMatchInlineSnapshot( `[NoRouteMatchError: No match for {"path":"/","name":"Home","params":{},"query":{},"hash":"","fullPath":"/"}]` ) @@ -173,7 +169,7 @@ describe('Router Matcher', () => { describe('LocationAsRelative', () => { it('matches with nothing', () => { - const record = { path: '/home', name: 'Home', component } + const record = { path: '/home', name: 'Home', components } assertRecordMatch( record, {}, @@ -189,7 +185,7 @@ describe('Router Matcher', () => { }) it('replace params even with no name', () => { - const record = { path: '/users/:id/m/:role', component } + const record = { path: '/users/:id/m/:role', components } assertRecordMatch( record, { params: { id: 'posva', role: 'admin' } }, @@ -208,7 +204,7 @@ describe('Router Matcher', () => { const record = { path: '/users/:id/m/:role', name: 'UserEdit', - component, + components, } assertRecordMatch( record, @@ -228,7 +224,7 @@ describe('Router Matcher', () => { const record = { path: '/users/:id/m/:role', name: 'UserEdit', - component, + components, } assertRecordMatch( record, @@ -249,7 +245,7 @@ describe('Router Matcher', () => { }) it('keep params if not provided even with no name', () => { - const record = { path: '/users/:id/m/:role', component } + const record = { path: '/users/:id/m/:role', components } assertRecordMatch( record, {}, @@ -269,18 +265,11 @@ describe('Router Matcher', () => { }) describe('redirects', () => { - /** - * - * @param {RouteRecord[]} records Record or records we are testing the matcher against - * @param {MatcherLocation} location location we want to reolve against - * @param {MatcherLocationNormalized | MatcherLocationRedirect} expected Expected resolved location given by the matcher - * @param {MatcherLocationNormalized} [currentLocation] Optional currentLocation used when resolving - */ function assertRedirect( - records, - location, - expected, - currentLocation = START_LOCATION_NORMALIZED + records: RouteRecord[], + location: MatcherLocation, + expected: MatcherLocationNormalized | MatcherLocationRedirect, + currentLocation: MatcherLocationNormalized = START_LOCATION_NORMALIZED ) { const matcher = new RouterMatcher(records) const resolved = matcher.resolve(location, currentLocation) @@ -290,7 +279,7 @@ describe('Router Matcher', () => { it('resolves a redirect string', () => { const records = [ - { path: '/home', component }, + { path: '/home', components }, { path: '/redirect', redirect: '/home' }, ] assertRedirect( @@ -315,7 +304,7 @@ describe('Router Matcher', () => { it('resolves a redirect function that returns a string', () => { const redirect = () => '/home' const records = [ - { path: '/home', component }, + { path: '/home', components }, { path: '/redirect', redirect }, ] assertRedirect( @@ -342,7 +331,7 @@ describe('Router Matcher', () => { path: '/home' } const records = [ - { path: '/home', component }, + { path: '/home', components }, { path: '/redirect', redirect }, ] assertRedirect( @@ -366,7 +355,7 @@ describe('Router Matcher', () => { it('resolves a redirect as an object', () => { const records = [ - { path: '/home', component }, + { path: '/home', components }, { path: '/redirect', redirect: { path: 'home' } }, ] assertRedirect( @@ -390,7 +379,7 @@ describe('Router Matcher', () => { it('works with a named location', () => { const records = [ - { path: '/home', component }, + { path: '/home', components }, { path: '/redirect', name: 'redirect', redirect: { path: 'home' } }, ] assertRedirect( @@ -412,10 +401,6 @@ describe('Router Matcher', () => { }) it('throws if relative location when redirecting', () => { - const records = [ - { path: '/home', component }, - { path: '/redirect', redirect: '/home' }, - ] expect( assertErrorMatch( { path: '/redirect', redirect: '/home' }, @@ -438,15 +423,15 @@ describe('Router Matcher', () => { }) it('normalize a location when redirecting', () => { - const redirect = to => ({ name: 'b', params: to.params }) + const redirect = (to: any) => ({ name: 'b', params: to.params }) const records = [ - { path: '/home', component }, + { path: '/home', components }, { path: '/a/:a', name: 'a', redirect, }, - { path: '/b/:a', name: 'b', component }, + { path: '/b/:a', name: 'b', components }, ] assertRedirect( records, @@ -468,7 +453,7 @@ describe('Router Matcher', () => { }) it('throws if the current named route does not exists', () => { - const record = { path: '/', component } + const record = { path: '/', components } const start = { name: 'home', params: {}, @@ -494,10 +479,10 @@ describe('Router Matcher', () => { }) describe('children', () => { - const ChildA = { path: 'a', name: 'child-a', component } - const ChildB = { path: 'b', name: 'child-b', component } - const ChildC = { path: 'c', name: 'child-c', component } - const ChildWithParam = { path: ':p', name: 'child-params', component } + const ChildA = { path: 'a', name: 'child-a', components } + const ChildB = { path: 'b', name: 'child-b', components } + const ChildC = { path: 'c', name: 'child-c', components } + const ChildWithParam = { path: ':p', name: 'child-params', components } const NestedChildWithParam = { ...ChildWithParam, name: 'nested-child-params', @@ -508,13 +493,13 @@ describe('Router Matcher', () => { const Nested = { path: 'nested', name: 'nested', - component, + components, children: [NestedChildA, NestedChildB, NestedChildC], } const NestedWithParam = { path: 'nested/:n', name: 'nested', - component, + components, children: [NestedChildWithParam], } @@ -522,7 +507,7 @@ describe('Router Matcher', () => { const Foo = { path: '/foo', name: 'Foo', - component, + components, children: [ChildA, ChildB, ChildC], } assertRecordMatch( @@ -538,11 +523,11 @@ describe('Router Matcher', () => { }) it('resolves children with empty paths', () => { - const Nested = { path: '', name: 'nested', component } + const Nested = { path: '', name: 'nested', components } const Foo = { path: '/foo', name: 'Foo', - component, + components, children: [Nested], } assertRecordMatch( @@ -560,17 +545,17 @@ describe('Router Matcher', () => { }) it('resolves nested children with empty paths', () => { - const NestedNested = { path: '', name: 'nested', component } + const NestedNested = { path: '', name: 'nested', components } const Nested = { path: '', name: 'nested-nested', - component, + components, children: [NestedNested], } const Foo = { path: '/foo', name: 'Foo', - component, + components, children: [Nested], } assertRecordMatch( @@ -593,7 +578,7 @@ describe('Router Matcher', () => { const Foo = { path: '/foo', name: 'Foo', - component, + components, children: [Nested], } assertRecordMatch( @@ -619,7 +604,7 @@ describe('Router Matcher', () => { const Foo = { path: '/foo', name: 'Foo', - component, + components, children: [Nested], } assertRecordMatch( @@ -645,7 +630,7 @@ describe('Router Matcher', () => { const Foo = { path: '/foo', name: 'Foo', - component, + components, children: [Nested], } assertRecordMatch( @@ -678,7 +663,7 @@ describe('Router Matcher', () => { const Foo = { path: '/foo', name: 'Foo', - component, + components, children: [NestedWithParam], } assertRecordMatch( @@ -707,7 +692,7 @@ describe('Router Matcher', () => { const Foo = { path: '/foo', name: 'Foo', - component, + components, children: [NestedWithParam], } assertRecordMatch( diff --git a/__tests__/query.spec.js b/__tests__/query.spec.ts similarity index 87% rename from __tests__/query.spec.js rename to __tests__/query.spec.ts index 2bb07f9a..c1d505be 100644 --- a/__tests__/query.spec.js +++ b/__tests__/query.spec.ts @@ -1,5 +1,4 @@ -// @ts-check -const { parseQuery } = require('../src/history/utils') +import { parseQuery } from '../src/history/utils' describe('parseQuery', () => { it('works with leading ?', () => { diff --git a/__tests__/router-link.spec.js b/__tests__/router-link.spec.ts similarity index 72% rename from __tests__/router-link.spec.js rename to __tests__/router-link.spec.ts index f38ad26e..4dfa6905 100644 --- a/__tests__/router-link.spec.js +++ b/__tests__/router-link.spec.ts @@ -1,20 +1,25 @@ /** * @jest-environment jsdom */ -// @ts-check // NOTE: these tests only run when using jest `yarn jest --watch` -const { default: RouterLink } = require('../src/components/Link') -const { components, isMocha, HistoryMock } = require('./utils') -const { START_LOCATION_NORMALIZED } = require('../src/types') +import RouterLink from '../src/components/Link' +import { HistoryMock } from './utils' +import { + START_LOCATION_NORMALIZED, + RouteQueryAndHash, + MatcherLocation, + RouteLocationNormalized, +} from '../src/types' +import { mount } from '@vue/test-utils' -/** @typedef {import('../src/types').RouteLocationNormalized} RouteLocationNormalized */ -/** @typedef {import('../src/types').RouteRecord} RouteRecord */ -/** @typedef {import('../src/types').RouteLocation} RouteLocation */ -/** @typedef {import('../src/types').MatcherLocation} MatcherLocation */ -/** @typedef {import('../src/types').RouteQueryAndHash} RouteQueryAndHash */ - -/** @type {Record }>} */ -const locations = { +const locations: Record< + string, + { + string: string + normalized: RouteLocationNormalized + toResolve?: MatcherLocation & Required + } +> = { basic: { string: '/home', // toResolve: { path: '/home', fullPath: '/home', undefined, query: {}, hash: '' }, @@ -46,18 +51,11 @@ const locations = { } describe('RouterLink', () => { - // skip these tests on mocha because @vue/test-utils - // do not work correctly - if (isMocha()) return - const { mount } = require('@vue/test-utils') - - /** - * - * @param {RouteLocationNormalized} currentLocation - * @param {Object} propsData - * @param {RouteLocationNormalized} resolvedLocation - */ - function factory(currentLocation, propsData, resolvedLocation) { + function factory( + currentLocation: RouteLocationNormalized, + propsData: any, + resolvedLocation: RouteLocationNormalized + ) { const router = { history: new HistoryMock(), resolve: jest.fn(), diff --git a/__tests__/router-view.spec.js b/__tests__/router-view.spec.ts similarity index 79% rename from __tests__/router-view.spec.js rename to __tests__/router-view.spec.ts index 47e42217..26b7ec37 100644 --- a/__tests__/router-view.spec.js +++ b/__tests__/router-view.spec.ts @@ -1,16 +1,16 @@ /** * @jest-environment jsdom */ -// @ts-check // NOTE: these tests only run when using jest `yarn jest --watch` -const { default: RouterView } = require('../src/components/View') -const { components, isMocha } = require('./utils') -const { START_LOCATION_NORMALIZED } = require('../src/types') +import RouterView from '../src/components/View' +import { components } from './utils' +import { + START_LOCATION_NORMALIZED, + RouteLocationNormalized, +} from '../src/types' +import { mount } from '@vue/test-utils' -/** @typedef {import('../src/types').RouteLocationNormalized} RouteLocationNormalized */ - -/** @type {Record} */ -const routes = { +const routes: Record = { root: { fullPath: '/', name: undefined, @@ -61,17 +61,7 @@ const routes = { } describe('RouterView', () => { - // skip these tests on mocha because @vue/test-utils - // do not work correctly - if (isMocha()) return - const { mount } = require('@vue/test-utils') - - /** - * - * @param {RouteLocationNormalized} $route - * @param {Object} [props] - */ - function factory($route, props = {}) { + function factory($route: RouteLocationNormalized, props: any = {}) { // @ts-ignore cannot mount functional component? const wrapper = mount(RouterView, { context: { diff --git a/__tests__/router.spec.js b/__tests__/router.spec.ts similarity index 91% rename from __tests__/router.spec.js rename to __tests__/router.spec.ts index d78949ba..619861df 100644 --- a/__tests__/router.spec.js +++ b/__tests__/router.spec.ts @@ -1,13 +1,11 @@ -// @ts-check -const fakePromise = require('faked-promise') -const { HTML5History } = require('../src/history/html5') -const { AbstractHistory } = require('../src/history/abstract') -const { Router } = require('../src/router') -const { NavigationCancelled } = require('../src/errors') -const { createDom, components, tick, HistoryMock } = require('./utils') +import fakePromise from 'faked-promise' +import { AbstractHistory } from '../src/history/abstract' +import { Router } from '../src/router' +import { NavigationCancelled } from '../src/errors' +import { createDom, components, tick, HistoryMock } from './utils' +import { RouteRecord, RouteLocation } from '../src/types' -/** @type {import('../src/types').RouteRecord[]} */ -const routes = [ +const routes: RouteRecord[] = [ { path: '/', component: components.Home }, { path: '/search', component: components.Home }, { path: '/foo', component: components.Foo, name: 'Foo' }, @@ -101,7 +99,9 @@ describe('Router', () => { }) describe('navigation', () => { - async function checkNavigationCancelledOnPush(target) { + async function checkNavigationCancelledOnPush( + target?: RouteLocation | false | ((vm: any) => void) + ) { const [p1, r1] = fakePromise() const [p2, r2] = fakePromise() const history = new HistoryMock() @@ -110,7 +110,8 @@ describe('Router', () => { if (to.name !== 'Param') return next() if (to.params.p === 'a') { await p1 - next(target) + // @ts-ignore: for some reason it's not handling the string here + target == null ? next() : next(target) } else { await p2 next() @@ -145,7 +146,9 @@ describe('Router', () => { await checkNavigationCancelledOnPush(undefined) }) - async function checkNavigationCancelledOnPopstate(target) { + async function checkNavigationCancelledOnPopstate( + target?: RouteLocation | false | ((vm: any) => void) + ) { const [p1, r1] = fakePromise() const [p2, r2] = fakePromise() const history = new AbstractHistory() @@ -162,6 +165,7 @@ describe('Router', () => { next() } else if (from.fullPath === '/p/b') { await p2 + // @ts-ignore: same as function above next(target) } else { next() diff --git a/__tests__/ssr/basic.spec.js b/__tests__/ssr/basic.spec.ts similarity index 91% rename from __tests__/ssr/basic.spec.js rename to __tests__/ssr/basic.spec.ts index 71c5f77c..a7796a25 100644 --- a/__tests__/ssr/basic.spec.js +++ b/__tests__/ssr/basic.spec.ts @@ -1,5 +1,4 @@ -// @ts-check -const { renderApp, renderer } = require('./shared') +import { renderApp, renderer } from './shared' describe('SSR: basicRenderer', () => { it('renders the view', async () => { @@ -45,9 +44,7 @@ describe('SSR: basicRenderer', () => { }, components: { test: { - render() { - return this.$createElement('div', { class: ['a'] }, 'test') - }, + template: `
test
`, }, testAsync(resolve) { resolve({ diff --git a/__tests__/ssr/shared.ts b/__tests__/ssr/shared.ts index 143fac83..b23b16b5 100644 --- a/__tests__/ssr/shared.ts +++ b/__tests__/ssr/shared.ts @@ -1,4 +1,4 @@ -import Vue from 'vue' +import Vue, { ComponentOptions } from 'vue' import Router from '../../src' import { components } from '../utils' @@ -51,7 +51,7 @@ export function createApp( export function renderApp( context: { url: string }, routerOptions?: Partial, - vueOptions?: any + vueOptions?: ComponentOptions ) { return new Promise['app']>((resolve, reject) => { const { app, router } = createApp(routerOptions, vueOptions) diff --git a/__tests__/tsconfig.json b/__tests__/tsconfig.json deleted file mode 100644 index 533ede6c..00000000 --- a/__tests__/tsconfig.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "include": ["./**/*.ts", "./**/*.js"], - "exclude": ["./helper.js"], - "compilerOptions": { - "target": "esnext", - "module": "commonjs", - "noEmit": true, - "checkJs": true, - "allowJs": true, - "esModuleInterop": true - } -} diff --git a/__tests__/url-encoding.spec.js b/__tests__/url-encoding.spec.ts similarity index 93% rename from __tests__/url-encoding.spec.js rename to __tests__/url-encoding.spec.ts index 51ee82b1..4556010a 100644 --- a/__tests__/url-encoding.spec.js +++ b/__tests__/url-encoding.spec.ts @@ -1,17 +1,18 @@ -// @ts-check -const { Router } = require('../src/router') -const { createDom, components, tick, HistoryMock } = require('./utils') +import { Router } from '../src/router' +import { createDom, components, HistoryMock } from './utils' +import { RouteRecord } from '../src/types' -/** @type {import('../src/types').RouteRecord[]} */ -const routes = [ +const routes: RouteRecord[] = [ { path: '/', name: 'home', component: components.Home }, { path: '/%25', name: 'percent', component: components.Home }, { path: '/to-p/:p', redirect: to => `/p/${to.params.p}` }, { path: '/p/:p', component: components.Bar, name: 'params' }, ] -function createHistory(initialUrl) { - return new HistoryMock(initialUrl) +// this function is meant to easy refactor in the future as Histories are going to be +// function-based +function createHistory(...args: ConstructorParameters) { + return new HistoryMock(...args) } describe('URL Encoding', () => { diff --git a/__tests__/url.spec.js b/__tests__/url.spec.ts similarity index 97% rename from __tests__/url.spec.js rename to __tests__/url.spec.ts index 3b2de19d..560b755f 100644 --- a/__tests__/url.spec.js +++ b/__tests__/url.spec.ts @@ -1,9 +1,8 @@ -// @ts-check -const { +import { parseURL, stringifyURL, normalizeLocation, -} = require('../src/history/utils') +} from '../src/history/utils' describe('parseURL', () => { it('works with no query no hash', () => { diff --git a/__tests__/utils.ts b/__tests__/utils.ts index 83ae2faf..a3790994 100644 --- a/__tests__/utils.ts +++ b/__tests__/utils.ts @@ -5,7 +5,8 @@ export { HistoryMock } from './HistoryMock' export const tick = () => new Promise(resolve => process.nextTick(resolve)) -export const NAVIGATION_TYPES = ['push', 'replace'] +export type NAVIGATION_METHOD = 'push' | 'replace' +export const NAVIGATION_TYPES: NAVIGATION_METHOD[] = ['push', 'replace'] declare global { namespace NodeJS { @@ -50,11 +51,6 @@ export const components = { }, } -// allow using a .jest modifider to skip some tests on mocha -// specifically, skip component tests as they are a pain to correctly -// adapt to mocha -export const isMocha = () => typeof global.before === 'function' - /** * Copies and normalizes the record so it always contains an object of `components` * diff --git a/jest.config.js b/jest.config.js index 83e5bd1e..7c39bcb9 100644 --- a/jest.config.js +++ b/jest.config.js @@ -8,7 +8,7 @@ module.exports = { 'src/consola.ts', ], testMatch: [ - '**/__tests__/**/*.spec.[j]s?(x)', + '**/__tests__/**/*.spec.ts?(x)', // '**/__tests__/**/*.spec.[jt]s?(x)', // '**/?(*.)+(spec|test).[jt]s?(x)', ], diff --git a/package.json b/package.json index 1f7f3aef..b022e980 100644 --- a/package.json +++ b/package.json @@ -9,9 +9,7 @@ "types": "dist/index.d.ts", "license": "MIT", "scripts": { - "test:types:src": "tsc --build tsconfig.check-types.json", - "test:types:test": "tsc --build __tests__/tsconfig.json", - "test:types": "yarn test:types:src && yarn test:types:test", + "test:types": "tsc --build tsconfig.json", "test:unit": "jest --coverage", "test": "yarn run test:types && yarn run test:unit && yarn build", "build": "yarn rollup -c rollup.config.js", @@ -24,7 +22,7 @@ "codecov": "^3.6.1", "consola": "^2.10.1", "expect": "^24.9.0", - "faked-promise": "^2.1.0", + "faked-promise": "^2.2.2", "html-webpack-plugin": "^3.2.0", "jest": "^24.9.0", "jsdom": "^15.1.1", diff --git a/tsconfig.check-types.json b/tsconfig.check-types.json deleted file mode 100644 index 1cc234a0..00000000 --- a/tsconfig.check-types.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "include": ["src/**/*.ts"], - "compilerOptions": { - "target": "esnext", - "module": "commonjs", - // "lib": ["es2017.object"] , - "allowJs": true, - "checkJs": true, - // "declaration": true , - // "sourceMap": true , - // "outFile": "./", /* Concatenate and emit output to single file. */ - // "outDir": "./dist" , - // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ - // "composite": true, /* Enable project compilation */ - "noEmit": true, - - "strict": true, - "noUnusedLocals": true, - // "noUnusedParameters": true, - "noImplicitReturns": true, - - "moduleResolution": "node", - "esModuleInterop": true - } -} diff --git a/tsconfig.json b/tsconfig.json index 927a40dc..5a537c38 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,61 +1,23 @@ { - "include": ["src/**/*.ts"], + "include": ["src/**/*.ts", "__tests__/**/*.ts"], "compilerOptions": { - /* Basic Options */ - "target": "esnext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */, - // Necessary for tests with mocha - "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */, + "target": "esnext", + "module": "commonjs", // "lib": ["es2017.object"] /* Specify library files to be included in the compilation. */, - // "allowJs": true, /* Allow javascript files to be compiled. */ - // "checkJs": true, /* Report errors in .js files. */ - // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ - "declaration": true /* Generates corresponding '.d.ts' file. */, - // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ - "sourceMap": true /* Generates corresponding '.map' file. */, - // "outFile": "./", /* Concatenate and emit output to single file. */ - "outDir": "./dist" /* Redirect output structure to the directory. */, - // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ - // "composite": true, /* Enable project compilation */ - "removeComments": false /* Do not emit comments to output. */, - // "noEmit": true, /* Do not emit outputs. */ - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ - // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ + "declaration": true, + // "declarationMap": true, + "sourceMap": true, + "outDir": "./dist", + "removeComments": false, + "noEmit": true, - /* Strict Type-Checking Options */ - "strict": true /* Enable all strict type-checking options. */, - // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* Enable strict null checks. */ - // "strictFunctionTypes": true, /* Enable strict checking of function types. */ - // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ - // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ - // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + "strict": true, - /* Additional Checks */ - "noUnusedLocals": true /* Report errors on unused locals. */, - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - "noImplicitReturns": true /* Report error when not all code paths in function return a value. */, - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + "noUnusedLocals": true, + // "noUnusedParameters": true, + "noImplicitReturns": true, - /* Module Resolution Options */ - "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */, - // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ - // "typeRoots": [], /* List of folders to include type definitions from. */ - // "types": [], /* Type declaration files to be included in compilation. */ - // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ - // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ - - /* Source Map Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ - // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ - - /* Experimental Options */ - // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ - // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + "moduleResolution": "node", + "esModuleInterop": true } } diff --git a/yarn.lock b/yarn.lock index 8dbf4fb8..39e7c8e8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2236,10 +2236,10 @@ extsprintf@^1.2.0: resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" integrity sha1-4mifjzVvrWLMplo6kcXfX5VRaS8= -faked-promise@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/faked-promise/-/faked-promise-2.1.0.tgz#988dd6f7e1c30638be2cd0d67e944b51d5dbbaeb" - integrity sha512-p5QCxMj8OsHjBs0aIEbg1WFW019Tib3LIWpz6Fyl5uVf4A3FRJzcMrJgiTgwVB5k99k3M566U6NUa/rEi473fA== +faked-promise@^2.2.2: + version "2.2.2" + resolved "https://registry.yarnpkg.com/faked-promise/-/faked-promise-2.2.2.tgz#c89dd11d29a561bb03229813e3aa13a369df137c" + integrity sha512-1kaSWavyNHJw83/aJ0dZAhKWID/FAED9vlgBa43kW8Vb61BSXORXf8f9W6NJ7qepTtlPSaJc557qkpxT1HCUBw== fast-deep-equal@^2.0.1: version "2.0.1"