]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
test: use file snapshot instead of inline
authorEduardo San Martin Morote <posva13@gmail.com>
Fri, 27 Sep 2019 10:06:52 +0000 (12:06 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Fri, 27 Sep 2019 10:06:52 +0000 (12:06 +0200)
__tests__/__snapshots__/matcher.spec.ts.snap [new file with mode: 0644]
__tests__/__snapshots__/router-link.spec.ts.snap [new file with mode: 0644]
__tests__/__snapshots__/router-view.spec.ts.snap [new file with mode: 0644]
__tests__/matcher.spec.ts
__tests__/router-link.spec.ts
__tests__/router-view.spec.ts
__tests__/ssr/__snapshots__/basic.spec.ts.snap [new file with mode: 0644]
__tests__/ssr/basic.spec.ts

diff --git a/__tests__/__snapshots__/matcher.spec.ts.snap b/__tests__/__snapshots__/matcher.spec.ts.snap
new file mode 100644 (file)
index 0000000..044ee4a
--- /dev/null
@@ -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 (file)
index 0000000..1187a0b
--- /dev/null
@@ -0,0 +1,5 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`RouterLink displays a link with a string prop 1`] = `"<a href=\\"/home\\">a link</a>"`;
+
+exports[`RouterLink displays a link with an object with path prop 1`] = `"<a href=\\"/home\\">a link</a>"`;
diff --git a/__tests__/__snapshots__/router-view.spec.ts.snap b/__tests__/__snapshots__/router-view.spec.ts.snap
new file mode 100644 (file)
index 0000000..7fa8ce7
--- /dev/null
@@ -0,0 +1,11 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`RouterView displays current route component 1`] = `"<div>Home</div>"`;
+
+exports[`RouterView displays deeply nested views 1`] = `"<div><h2>Nested</h2><div><h2>Nested</h2><div>Foo</div></div></div>"`;
+
+exports[`RouterView displays named views 1`] = `"<div>Foo</div>"`;
+
+exports[`RouterView displays nested views 1`] = `"<div><h2>Nested</h2><div>Foo</div></div>"`;
+
+exports[`RouterView displays nothing when route is unmatched 1`] = `undefined`;
index 435981c51c340987bf3d0b8d3b4cce8b7bcb86e4..9b65df10d6403787c5001786b080950455f53bef 100644 (file)
@@ -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()
       })
     })
 
index 4dfa6905e8a72d0ce4beb4cffb02ad456ae4de95..ee60737da5de7bc06fb2929e5c0882221a6fba9b 100644 (file)
@@ -81,9 +81,7 @@ describe('RouterLink', () => {
       { to: locations.basic.string },
       locations.basic.normalized
     )
-    expect(wrapper.html()).toMatchInlineSnapshot(
-      `"<a href=\\"/home\\">a link</a>"`
-    )
+    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 href=\\"/home\\">a link</a>"`
-    )
+    expect(wrapper.html()).toMatchSnapshot()
   })
 
   it('calls ensureLocation', () => {
index 26b7ec3712fd36e16c29c5bbec1ad4f22a81f8c7..6d9ebfefbac8f8965f6d5c8eb05a5d88e4ea90c8 100644 (file)
@@ -76,31 +76,27 @@ describe('RouterView', () => {
 
   it('displays current route component', async () => {
     const wrapper = factory(routes.root)
-    expect(wrapper.html()).toMatchInlineSnapshot(`"<div>Home</div>"`)
+    expect(wrapper.html()).toMatchSnapshot()
   })
 
   it('displays named views', async () => {
     const wrapper = factory(routes.named, { name: 'foo' })
-    expect(wrapper.html()).toMatchInlineSnapshot(`"<div>Foo</div>"`)
+    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(
-      `"<div><h2>Nested</h2><div>Foo</div></div>"`
-    )
+    expect(wrapper.html()).toMatchSnapshot()
   })
 
   it('displays deeply nested views', async () => {
     const wrapper = factory(routes.nestedNested)
-    expect(wrapper.html()).toMatchInlineSnapshot(
-      `"<div><h2>Nested</h2><div><h2>Nested</h2><div>Foo</div></div></div>"`
-    )
+    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 (file)
index 0000000..d69763d
--- /dev/null
@@ -0,0 +1,3 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`SSR: basicRenderer renders the view 1`] = `"<div data-server-rendered=\\"true\\"><div>Home</div></div>"`;
index a7796a256349d04ff1688ca029060c559582c701..4211661249d4c7a7b5fd8ae681b95402663db1b7 100644 (file)
@@ -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(
-      `"<div data-server-rendered=\\"true\\"><div>Home</div></div>"`
-    )
+    expect(result).toMatchSnapshot()
   })
 
   /**