File tree Expand file tree Collapse file tree 5 files changed +43
-2
lines changed Expand file tree Collapse file tree 5 files changed +43
-2
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,11 @@ function dayjsModule(moduleOptions) {
1212 moduleOptions . defaultLocale ||
1313 this . options . dayjs . defaultLocale ||
1414 null
15- )
15+ ) ,
16+ plugins : [
17+ ...( this . options . dayjs . plugins || [ ] ) ,
18+ ...( moduleOptions . plugins || [ ] ) ,
19+ ]
1620 }
1721
1822 this . addPlugin ( {
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ import dayjs from 'dayjs'
22
33< %= options . locales . map ( l => `import 'dayjs/locale/${ l } '` ) . join ( '\n' ) % >
44
5+ < %= options . plugins . map ( l => `dayjs.extend(require('dayjs/plugin/${ l } '))` ) . join ( '\n' ) % >
6+
57< % if ( options . defaultLocale ) { % >
68dayjs . locale ( '<%= options.defaultLocale %>' )
79< % } % >
Original file line number Diff line number Diff line change @@ -7,5 +7,6 @@ module.exports = {
77 dev : process . env . NODE_ENV !== 'test' && process . env . NODE_ENV === 'production' ,
88 dayjs : {
99 locales : [ 'ja' ] ,
10- } ,
10+ plugins : [ 'advancedFormat' , 'localizedFormat' ]
11+ }
1112}
Original file line number Diff line number Diff line change 1+ <template >
2+ <div >
3+ <p data-test-id =" advancedFormat" >{{ advancedFormat }}</p >
4+ <p data-test-id =" localized" >{{ localized }}</p >
5+ </div >
6+ </template >
7+ <script >
8+ export default {
9+ asyncData (context ) {
10+ return {
11+ advancedFormat: context
12+ .$dayjs (' 2018-08-16' )
13+ .format (' Do' ),
14+ localized: context
15+ .$dayjs (' 2018-08-16' )
16+ .format (' ll' )
17+ }
18+ }
19+ }
20+ </script >
Original file line number Diff line number Diff line change @@ -62,4 +62,18 @@ describe('basic', () => {
6262 const newValue = await newTextContent . jsonValue ( )
6363 return expect ( newValue ) . toBe ( '1995/12/18(月曜日)' )
6464 } )
65+
66+ test ( 'support plugins' , async ( ) => {
67+ expect . assertions ( 2 )
68+ await page . goto ( url ( '/plugin' ) )
69+ const el = await page . $ ( '[data-test-id="advancedFormat"]' )
70+ const textContent = await el ! . getProperty ( 'textContent' )
71+ const value = await textContent . jsonValue ( )
72+ expect ( value ) . toBe ( '16th' )
73+
74+ const el1 = await page . $ ( '[data-test-id="localized"]' )
75+ const textContent1 = await el1 ! . getProperty ( 'textContent' )
76+ const value1 = await textContent1 . jsonValue ( )
77+ return expect ( value1 ) . toBe ( 'Aug 16, 2018' )
78+ } )
6579} )
You can’t perform that action at this time.
0 commit comments