2 |
3 | Works!
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
16 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_size = 2
6 | indent_style = space
7 | end_of_line = lf
8 | charset = utf-8
9 | trim_trailing_whitespace = true
10 | insert_final_newline = true
11 |
12 | [*.md]
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/lib/plugin.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | <% options.components.forEach(({ name, path }) => { %>import <%= name %> from '<%= path %>'
3 | <% }) %>
4 |
5 | <% options.components.forEach(({ name }) => { %>
6 | Vue.component(<% if (!options.ignoreNameDetection) { %><%= name %>.name || <% } %>'<%= name %>', <%= name %>)
7 | <% }) %>
8 |
--------------------------------------------------------------------------------
/test/basic.test.js:
--------------------------------------------------------------------------------
1 | const { setup, loadConfig, get } = require('@nuxtjs/module-test-utils')
2 |
3 | describe('basic', () => {
4 | let nuxt
5 |
6 | beforeAll(async () => {
7 | ({ nuxt } = (await setup(loadConfig(__dirname, 'basic'))))
8 | }, 60000)
9 |
10 | afterAll(async () => {
11 | await nuxt.close()
12 | })
13 |
14 | test('render', async () => {
15 | const html = await get('/')
16 | expect(html).toContain('Works!')
17 | expect(html).toContain('bar content')
18 | expect(html).toContain('foo content')
19 | })
20 | })
21 |
--------------------------------------------------------------------------------
/test/__snapshots__/watch.test.js.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`watch discover components and pass as componentOptions 1`] = `
4 | Object {
5 | "components": Array [
6 | Object {
7 | "name": "A.js",
8 | "path": "~//project/nuxt/a.js",
9 | },
10 | Object {
11 | "name": "B",
12 | "path": "~//project/nuxt/b.global.js",
13 | },
14 | Object {
15 | "name": "C",
16 | "path": "~//project/nuxt/c.global.js",
17 | },
18 | ],
19 | "ignoreNameDetection": false,
20 | }
21 | `;
22 |
--------------------------------------------------------------------------------
/test/multiple-dirs.test.js:
--------------------------------------------------------------------------------
1 | const { setup, loadConfig, get } = require('@nuxtjs/module-test-utils')
2 |
3 | describe('multiple-dirs', () => {
4 | let nuxt
5 |
6 | beforeAll(async () => {
7 | ({ nuxt } = (await setup(loadConfig(__dirname, 'multiple-dirs'))))
8 | }, 60000)
9 |
10 | afterAll(async () => {
11 | await nuxt.close()
12 | })
13 |
14 | test('render', async () => {
15 | const html = await get('/')
16 | expect(html).toContain('Works!')
17 | expect(html).toContain('foo content')
18 | expect(html).toContain('bar content')
19 | })
20 | })
21 |
--------------------------------------------------------------------------------
/test/empty-suffixes.test.js:
--------------------------------------------------------------------------------
1 | const { setup, loadConfig, get } = require('@nuxtjs/module-test-utils')
2 |
3 | describe('empty-suffixes', () => {
4 | let nuxt
5 |
6 | beforeAll(async () => {
7 | ({ nuxt } = (await setup(loadConfig(__dirname, 'empty-suffixes'))))
8 | }, 60000)
9 |
10 | afterAll(async () => {
11 | await nuxt.close()
12 | })
13 |
14 | test('render', async () => {
15 | const html = await get('/')
16 | expect(html).toContain('Works!')
17 | expect(html).toContain('foo content')
18 | expect(html).toContain('bar content')
19 | })
20 | })
21 |
--------------------------------------------------------------------------------
/test/multiple-suffixes.test.js:
--------------------------------------------------------------------------------
1 | const { setup, loadConfig, get } = require('@nuxtjs/module-test-utils')
2 |
3 | describe('multiple-suffixes', () => {
4 | let nuxt
5 |
6 | beforeAll(async () => {
7 | ({ nuxt } = (await setup(loadConfig(__dirname, 'multiple-suffixes'))))
8 | }, 60000)
9 |
10 | afterAll(async () => {
11 | await nuxt.close()
12 | })
13 |
14 | test('render', async () => {
15 | const html = await get('/')
16 | expect(html).toContain('Works!')
17 | expect(html).toContain('foo content')
18 | expect(html).toContain('bar content')
19 | })
20 | })
21 |
--------------------------------------------------------------------------------
/test/pascal.test.js:
--------------------------------------------------------------------------------
1 | const { setup, loadConfig, get } = require('@nuxtjs/module-test-utils')
2 |
3 | describe('pascal', () => {
4 | let nuxt
5 |
6 | beforeAll(async () => {
7 | ({ nuxt } = (await setup(loadConfig(__dirname, 'pascal'))))
8 | }, 60000)
9 |
10 | afterAll(async () => {
11 | await nuxt.close()
12 | })
13 |
14 | test('render', async () => {
15 | const html = await get('/')
16 | expect(html).toContain('Works!')
17 | expect(html).toContain('bar content')
18 | expect(html).toContain('bar foo content')
19 | expect(html).toContain('foo content')
20 | expect(html).toContain('foo bar content')
21 | })
22 | })
23 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@nuxtjs/global-components",
3 | "version": "0.6.1",
4 | "description": "Module to register global components for Nuxt.js",
5 | "repository": "nuxt-community/global-components",
6 | "license": "MIT",
7 | "contributors": [
8 | "Ricardo Gobbo de Souza