Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add option to import plugins (#45)
- Loading branch information
1 parent
5e4f32f
commit cbebaa9
Showing
8 changed files
with
93 additions
and
2 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
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
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
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
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,15 @@ | ||
module.exports = { | ||
rootDir: __dirname, | ||
render: { | ||
resourceHints: false | ||
}, | ||
buildModules: [ | ||
{ handler: require('../../../') } | ||
], | ||
moment: { | ||
plugins: [ | ||
'moment-strftime', | ||
'moment-fquarter' | ||
] | ||
} | ||
} |
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,16 @@ | ||
<template> | ||
<div> | ||
<p v-text="str" /> | ||
{{ $moment('19951225', 'YYYYMMDD').fquarter() }} | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
asyncData (ctx) { | ||
return { | ||
str: ctx.app.$moment('19951225', 'YYYYMMDD').strftime('%m/%d/%Y') | ||
} | ||
} | ||
} | ||
</script> |
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,23 @@ | ||
const { setup, loadConfig, get, url } = require('@nuxtjs/module-test-utils') | ||
|
||
describe('plugins', () => { | ||
let nuxt | ||
|
||
beforeAll(async () => { | ||
({ nuxt } = (await setup(loadConfig(__dirname, 'plugins')))) | ||
}, 60000) | ||
|
||
afterAll(async () => { | ||
await nuxt.close() | ||
}) | ||
|
||
test('render moment-strftime', async () => { | ||
const window = await nuxt.renderAndGetWindow(url('/')) | ||
expect(window.document.querySelector('p').textContent).toBe('12/25/1995') | ||
}) | ||
|
||
test('render moment-fquarter', async () => { | ||
const html = await get('/') | ||
expect(html).toContain('Q3 1995/96') | ||
}) | ||
}) |
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