From c1f38b75e4edee4fc80219b3ee1f4cbefd722ac1 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Fri, 24 Apr 2020 14:34:32 +0200 Subject: [PATCH] test: fix failing test --- __tests__/router.spec.ts | 10 +++++----- src/history/html5.ts | 7 +++++-- src/router.ts | 10 ++++++---- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/__tests__/router.spec.ts b/__tests__/router.spec.ts index d158937d..096be961 100644 --- a/__tests__/router.spec.ts +++ b/__tests__/router.spec.ts @@ -119,7 +119,7 @@ describe('Router', () => { query: {}, hash: '', }), - undefined + expect.anything() ) }) @@ -138,7 +138,7 @@ describe('Router', () => { query: {}, hash: '', }), - undefined + expect.anything() ) }) @@ -188,7 +188,7 @@ describe('Router', () => { query: {}, hash: '', }), - undefined + expect.anything() ) }) @@ -204,7 +204,7 @@ describe('Router', () => { query: {}, hash: '', }), - undefined + expect.anything() ) }) @@ -220,7 +220,7 @@ describe('Router', () => { query: {}, hash: '', }), - undefined + expect.anything() ) }) diff --git a/src/history/html5.ts b/src/history/html5.ts index bab3decc..bf523732 100644 --- a/src/history/html5.ts +++ b/src/history/html5.ts @@ -10,7 +10,10 @@ import { ValueContainer, normalizeBase, } from './common' -import { computeScrollPosition, ScrollToPosition } from '../utils/scroll' +import { + computeScrollPosition, + ScrollPositionCoordinates, +} from '../scrollBehavior' import { warn } from 'vue' import { stripBase } from '../utils/location' @@ -22,7 +25,7 @@ interface StateEntry extends HistoryState { forward: HistoryLocationNormalized | null position: number replaced: boolean - scroll: ScrollToPosition | null + scroll: Required | null | false } /** diff --git a/src/router.ts b/src/router.ts index 394f4bf0..72eb14bc 100644 --- a/src/router.ts +++ b/src/router.ts @@ -559,10 +559,12 @@ export function createRouter({ pendingLocation = toLocation const from = currentRoute.value - saveScrollPosition( - getScrollKey(from.fullPath, info.distance), - computeScrollPosition() - ) + if (isBrowser) { + saveScrollPosition( + getScrollKey(from.fullPath, info.distance), + computeScrollPosition() + ) + } let failure: NavigationFailure | void -- 2.47.3