@@ -69,4 +69,102 @@ describe('getMetaInfo', () => {
69
69
__dangerouslyDisableSanitizers : [ ]
70
70
} )
71
71
} )
72
+
73
+ it ( 'properly uses string titleTemplates' , ( ) => {
74
+ component = new Vue ( {
75
+ metaInfo : {
76
+ title : 'Hello' ,
77
+ titleTemplate : '%s World' ,
78
+ meta : [
79
+ { charset : 'utf-8' }
80
+ ]
81
+ }
82
+ } )
83
+ expect ( getMetaInfo ( component ) ) . to . eql ( {
84
+ title : 'Hello World' ,
85
+ titleChunk : 'Hello' ,
86
+ titleTemplate : '%s World' ,
87
+ htmlAttrs : { } ,
88
+ headAttrs : { } ,
89
+ bodyAttrs : { } ,
90
+ meta : [
91
+ { charset : 'utf-8' }
92
+ ] ,
93
+ base : [ ] ,
94
+ link : [ ] ,
95
+ style : [ ] ,
96
+ script : [ ] ,
97
+ noscript : [ ] ,
98
+ __dangerouslyDisableSanitizers : [ ]
99
+ } )
100
+ } )
101
+
102
+ it ( 'properly uses function titleTemplates' , ( ) => {
103
+ const titleTemplate = chunk => `${ chunk } Function World`
104
+
105
+ component = new Vue ( {
106
+ metaInfo : {
107
+ title : 'Hello' ,
108
+ titleTemplate : titleTemplate ,
109
+ meta : [
110
+ { charset : 'utf-8' }
111
+ ]
112
+ }
113
+ } )
114
+ expect ( getMetaInfo ( component ) ) . to . eql ( {
115
+ title : 'Hello Function World' ,
116
+ titleChunk : 'Hello' ,
117
+ titleTemplate : titleTemplate ,
118
+ htmlAttrs : { } ,
119
+ headAttrs : { } ,
120
+ bodyAttrs : { } ,
121
+ meta : [
122
+ { charset : 'utf-8' }
123
+ ] ,
124
+ base : [ ] ,
125
+ link : [ ] ,
126
+ style : [ ] ,
127
+ script : [ ] ,
128
+ noscript : [ ] ,
129
+ __dangerouslyDisableSanitizers : [ ]
130
+ } )
131
+ } )
132
+
133
+ it ( 'has the proper `this` binding when using function titleTemplates' , ( ) => {
134
+ const titleTemplate = function ( chunk ) {
135
+ return `${ chunk } ${ this . helloWorldText } `
136
+ }
137
+
138
+ component = new Vue ( {
139
+ metaInfo : {
140
+ title : 'Hello' ,
141
+ titleTemplate : titleTemplate ,
142
+ meta : [
143
+ { charset : 'utf-8' }
144
+ ]
145
+ } ,
146
+ data ( ) {
147
+ return {
148
+ helloWorldText : 'Function World'
149
+ }
150
+ }
151
+ } )
152
+ expect ( getMetaInfo ( component ) ) . to . eql ( {
153
+ title : 'Hello Function World' ,
154
+ titleChunk : 'Hello' ,
155
+ titleTemplate : titleTemplate ,
156
+ htmlAttrs : { } ,
157
+ headAttrs : { } ,
158
+ bodyAttrs : { } ,
159
+ meta : [
160
+ { charset : 'utf-8' }
161
+ ] ,
162
+ base : [ ] ,
163
+ link : [ ] ,
164
+ style : [ ] ,
165
+ script : [ ] ,
166
+ noscript : [ ] ,
167
+ __dangerouslyDisableSanitizers : [ ]
168
+ } )
169
+ } )
72
170
} )
0 commit comments