-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
59 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,3 @@ node_modules/ | |
.DS_Store | ||
/index.js | ||
dist | ||
test/snapshots |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,18 @@ | ||
import path from 'path' | ||
import test from 'ava' | ||
import { | ||
renderRoutes, | ||
collectRoutes, | ||
renderRoutesMap | ||
} from '../lib/collect-fs-routes' | ||
import Plugin from '../lib/plugin' | ||
import { renderRoutes, collectRoutes } from '../lib/collect-fs-routes' | ||
|
||
const dir = path.join(__dirname, 'views') | ||
const dir = 'test/views' | ||
const options = { | ||
dir, | ||
match: 'vue,js' | ||
} | ||
|
||
test('main', async t => { | ||
const routes = await collectRoutes(options) | ||
|
||
const routesString = renderRoutes(routes) | ||
const routesMap = renderRoutesMap(routes) | ||
const routesString = renderRoutes(routes, { | ||
componentPrefix: '' | ||
}) | ||
|
||
t.snapshot(JSON.stringify(routes), 'collect routes') | ||
t.snapshot(routesString, 'render routes') | ||
t.snapshot(routesMap, 'render routes map') | ||
}) | ||
|
||
test('plugin routes file', async t => { | ||
const plugin = new Plugin(options) | ||
|
||
t.snapshot(await plugin.handleRoutesString(), 'plugin routes file') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Snapshot report for `test/index.test.js` | ||
|
||
The actual snapshot is saved in `index.test.js.snap`. | ||
|
||
Generated by [AVA](https://ava.li). | ||
|
||
## main | ||
|
||
> collect routes | ||
'[{"path":"/","component":"test/views/index.vue"},{"path":"/bar","component":"test/views/bar/index.vue"},{"path":"/bar/:id","component":"test/views/bar/$id.vue"},{"path":"/foo","component":"test/views/foo/index.vue"},{"path":"/foo/:name","component":"test/views/foo/{name}.vue"}]' | ||
|
||
> render routes | ||
`␊ | ||
[␊ | ||
␊ | ||
{␊ | ||
path: "/",␊ | ||
␊ | ||
component: () => import(/* webpackChunkName: "page-test-views-index-vue" */ "test/views/index.vue"),␊ | ||
␊ | ||
}␊ | ||
,␊ | ||
{␊ | ||
path: "/bar",␊ | ||
␊ | ||
component: () => import(/* webpackChunkName: "page-test-views-bar-index-vue" */ "test/views/bar/index.vue"),␊ | ||
␊ | ||
}␊ | ||
,␊ | ||
{␊ | ||
path: "/bar/:id",␊ | ||
␊ | ||
component: () => import(/* webpackChunkName: "page-test-views-bar-$id-vue" */ "test/views/bar/$id.vue"),␊ | ||
␊ | ||
}␊ | ||
,␊ | ||
{␊ | ||
path: "/foo",␊ | ||
␊ | ||
component: () => import(/* webpackChunkName: "page-test-views-foo-index-vue" */ "test/views/foo/index.vue"),␊ | ||
␊ | ||
}␊ | ||
,␊ | ||
{␊ | ||
path: "/foo/:name",␊ | ||
props: true,␊ | ||
component: () => import(/* webpackChunkName: "page-test-views-foo-{name}-vue" */ "test/views/foo/{name}.vue"),␊ | ||
␊ | ||
}␊ | ||
␊ | ||
]␊ | ||
` |
Binary file not shown.