From: Eduardo San Martin Morote Date: Fri, 27 Sep 2019 10:06:52 +0000 (+0200) Subject: test: use file snapshot instead of inline X-Git-Tag: v4.0.0-alpha.0~216 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=509677561f38c529287a4036523aadf6aa834ab3;p=thirdparty%2Fvuejs%2Frouter.git test: use file snapshot instead of inline --- diff --git a/__tests__/__snapshots__/matcher.spec.ts.snap b/__tests__/__snapshots__/matcher.spec.ts.snap new file mode 100644 index 00000000..044ee4ab --- /dev/null +++ b/__tests__/__snapshots__/matcher.spec.ts.snap @@ -0,0 +1,15 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Router Matcher resolve LocationAsName throws if the named route does not exists 1`] = `[NoRouteMatchError: No match for {"path":"/","name":"Home","params":{},"query":{},"hash":"","fullPath":"/"}]`; + +exports[`Router Matcher resolve LocationAsPath throws if the path does not exists 1`] = `[NoRouteMatchError: No match for {"path":"/foo","params":{},"query":{},"hash":"","fullPath":"/"}]`; + +exports[`Router Matcher resolve LocationAsRelative redirects throws if relative location when redirecting 1`] = ` +[InvalidRouteMatch: Cannot redirect using a relative location: +{ + "params": {} +} +Use the function redirect and explicitely provide a name] +`; + +exports[`Router Matcher resolve LocationAsRelative throws if the current named route does not exists 1`] = `[NoRouteMatchError: No match for {"name":"home","params":{},"path":"/"}]`; diff --git a/__tests__/__snapshots__/router-link.spec.ts.snap b/__tests__/__snapshots__/router-link.spec.ts.snap new file mode 100644 index 00000000..1187a0b7 --- /dev/null +++ b/__tests__/__snapshots__/router-link.spec.ts.snap @@ -0,0 +1,5 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`RouterLink displays a link with a string prop 1`] = `"a link"`; + +exports[`RouterLink displays a link with an object with path prop 1`] = `"a link"`; diff --git a/__tests__/__snapshots__/router-view.spec.ts.snap b/__tests__/__snapshots__/router-view.spec.ts.snap new file mode 100644 index 00000000..7fa8ce74 --- /dev/null +++ b/__tests__/__snapshots__/router-view.spec.ts.snap @@ -0,0 +1,11 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`RouterView displays current route component 1`] = `"
Home
"`; + +exports[`RouterView displays deeply nested views 1`] = `"

Nested

Nested

Foo
"`; + +exports[`RouterView displays named views 1`] = `"
Foo
"`; + +exports[`RouterView displays nested views 1`] = `"

Nested

Foo
"`; + +exports[`RouterView displays nothing when route is unmatched 1`] = `undefined`; diff --git a/__tests__/matcher.spec.ts b/__tests__/matcher.spec.ts index 435981c5..9b65df10 100644 --- a/__tests__/matcher.spec.ts +++ b/__tests__/matcher.spec.ts @@ -135,9 +135,7 @@ describe('Router Matcher', () => { it('throws if the path does not exists', () => { expect( assertErrorMatch({ path: '/', components }, { path: '/foo' }) - ).toMatchInlineSnapshot( - `[NoRouteMatchError: No match for {"path":"/foo","params":{},"query":{},"hash":"","fullPath":"/"}]` - ) + ).toMatchSnapshot() }) }) @@ -161,9 +159,7 @@ describe('Router Matcher', () => { it('throws if the named route does not exists', () => { expect( assertErrorMatch({ path: '/', components }, { name: 'Home' }) - ).toMatchInlineSnapshot( - `[NoRouteMatchError: No match for {"path":"/","name":"Home","params":{},"query":{},"hash":"","fullPath":"/"}]` - ) + ).toMatchSnapshot() }) }) @@ -413,13 +409,7 @@ describe('Router Matcher', () => { meta: {}, } ) - ).toMatchInlineSnapshot(` - [InvalidRouteMatch: Cannot redirect using a relative location: - { - "params": {} - } - Use the function redirect and explicitely provide a name] - `) + ).toMatchSnapshot() }) it('normalize a location when redirecting', () => { @@ -472,9 +462,7 @@ describe('Router Matcher', () => { meta: {}, } ) - ).toMatchInlineSnapshot( - `[NoRouteMatchError: No match for {"name":"home","params":{},"path":"/"}]` - ) + ).toMatchSnapshot() }) }) diff --git a/__tests__/router-link.spec.ts b/__tests__/router-link.spec.ts index 4dfa6905..ee60737d 100644 --- a/__tests__/router-link.spec.ts +++ b/__tests__/router-link.spec.ts @@ -81,9 +81,7 @@ describe('RouterLink', () => { { to: locations.basic.string }, locations.basic.normalized ) - expect(wrapper.html()).toMatchInlineSnapshot( - `"a link"` - ) + expect(wrapper.html()).toMatchSnapshot() }) it('displays a link with an object with path prop', () => { @@ -92,9 +90,7 @@ describe('RouterLink', () => { { to: { path: locations.basic.string } }, locations.basic.normalized ) - expect(wrapper.html()).toMatchInlineSnapshot( - `"a link"` - ) + expect(wrapper.html()).toMatchSnapshot() }) it('calls ensureLocation', () => { diff --git a/__tests__/router-view.spec.ts b/__tests__/router-view.spec.ts index 26b7ec37..6d9ebfef 100644 --- a/__tests__/router-view.spec.ts +++ b/__tests__/router-view.spec.ts @@ -76,31 +76,27 @@ describe('RouterView', () => { it('displays current route component', async () => { const wrapper = factory(routes.root) - expect(wrapper.html()).toMatchInlineSnapshot(`"
Home
"`) + expect(wrapper.html()).toMatchSnapshot() }) it('displays named views', async () => { const wrapper = factory(routes.named, { name: 'foo' }) - expect(wrapper.html()).toMatchInlineSnapshot(`"
Foo
"`) + expect(wrapper.html()).toMatchSnapshot() }) it('displays nothing when route is unmatched', async () => { const wrapper = factory(START_LOCATION_NORMALIZED) // NOTE: I wonder if this will stay stable in future releases - expect(wrapper.html()).toMatchInlineSnapshot(`undefined`) + expect(wrapper.html()).toMatchSnapshot() }) it('displays nested views', async () => { const wrapper = factory(routes.nested) - expect(wrapper.html()).toMatchInlineSnapshot( - `"

Nested

Foo
"` - ) + expect(wrapper.html()).toMatchSnapshot() }) it('displays deeply nested views', async () => { const wrapper = factory(routes.nestedNested) - expect(wrapper.html()).toMatchInlineSnapshot( - `"

Nested

Nested

Foo
"` - ) + expect(wrapper.html()).toMatchSnapshot() }) }) diff --git a/__tests__/ssr/__snapshots__/basic.spec.ts.snap b/__tests__/ssr/__snapshots__/basic.spec.ts.snap new file mode 100644 index 00000000..d69763d5 --- /dev/null +++ b/__tests__/ssr/__snapshots__/basic.spec.ts.snap @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`SSR: basicRenderer renders the view 1`] = `"
Home
"`; diff --git a/__tests__/ssr/basic.spec.ts b/__tests__/ssr/basic.spec.ts index a7796a25..42116612 100644 --- a/__tests__/ssr/basic.spec.ts +++ b/__tests__/ssr/basic.spec.ts @@ -4,9 +4,7 @@ describe('SSR: basicRenderer', () => { it('renders the view', async () => { const app = await renderApp({ url: '/' }) const result = await renderer.renderToString(app) - expect(result).toMatchInlineSnapshot( - `"
Home
"` - ) + expect(result).toMatchSnapshot() }) /**