Skip to content

Commit 23acc00

Browse files
committed
feat: add getOptions method (resolves: nuxt#215)
1 parent 3db250d commit 23acc00

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

src/client/$meta.js

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default function _$meta(options = {}) {
1212
*/
1313
return function $meta() {
1414
return {
15+
getOptions: () => Object.freeze({ ...options }),
1516
refresh: _refresh.bind(this),
1617
inject,
1718
pause: pause.bind(this),

src/server/$meta.js

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export default function _$meta(options = {}) {
1313
*/
1414
return function $meta() {
1515
return {
16+
getOptions: () => Object.freeze({ ...options }),
1617
refresh: _refresh.bind(this),
1718
inject: _inject.bind(this),
1819
pause: pause.bind(this),

test/plugin-browser.test.js

+5
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,14 @@ describe('plugin', () => {
2020

2121
expect(instance.$meta().inject).toEqual(expect.any(Function))
2222
expect(instance.$meta().refresh).toEqual(expect.any(Function))
23+
expect(instance.$meta().getOptions).toEqual(expect.any(Function))
2324

2425
expect(instance.$meta().inject()).toBeUndefined()
2526
expect(instance.$meta().refresh()).toBeDefined()
27+
28+
const options = instance.$meta().getOptions()
29+
expect(options).toBeDefined()
30+
expect(options.keyName).toBe(defaultOptions.keyName)
2631
})
2732

2833
test('component has _hasMetaInfo set to true', () => {

0 commit comments

Comments
 (0)