Skip to content

Commit

Permalink
feat(vue): update generated file setup for apps
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysoo committed Oct 3, 2023
1 parent 19be500 commit 3d59d43
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,20 +177,7 @@ exports[`application generator should set up project correctly with given option
"
`;

exports[`application generator should set up project correctly with given options 5`] = `
"import { describe, it, expect } from 'vitest';
import { mount } from '@vue/test-utils';
import App from '../App.vue';
describe('App', () => {
it('renders properly', () => {
const wrapper = mount(App, {});
expect(wrapper.text()).toContain('Welcome test 👋');
});
});
"
`;
exports[`application generator should set up project correctly with given options 5`] = `null`;

exports[`application generator should set up project correctly with given options 6`] = `
[
Expand All @@ -200,21 +187,21 @@ exports[`application generator should set up project correctly with given option
".prettierrc",
"nx.json",
"package.json",
"test-e2e/.eslintrc.json",
"test-e2e/cypress.config.ts",
"test-e2e/project.json",
"test-e2e/src/e2e/app.cy.ts",
"test-e2e/src/fixtures/example.json",
"test-e2e/src/support/app.po.ts",
"test-e2e/src/support/commands.ts",
"test-e2e/src/support/e2e.ts",
"test-e2e/tsconfig.json",
"packages/vue/test-e2e/.eslintrc.json",
"packages/vue/test-e2e/cypress.config.ts",
"packages/vue/test-e2e/project.json",
"packages/vue/test-e2e/src/e2e/app.cy.ts",
"packages/vue/test-e2e/src/fixtures/example.json",
"packages/vue/test-e2e/src/support/app.po.ts",
"packages/vue/test-e2e/src/support/commands.ts",
"packages/vue/test-e2e/src/support/e2e.ts",
"packages/vue/test-e2e/tsconfig.json",
"test/.eslintrc.json",
"test/index.html",
"test/project.json",
"test/src/__tests__/App.spec.ts",
"test/src/App.vue",
"test/src/components/NxWelcome.vue",
"test/src/app/App.spec.ts",
"test/src/app/App.vue",
"test/src/app/NxWelcome.vue",
"test/src/main.ts",
"test/src/styles.css",
"test/tsconfig.app.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { describe, it, expect } from 'vitest'
<% } %>
import { mount } from '@vue/test-utils'
import App from '../App.vue';
import App from './App.vue';

describe('App', () => {
it('renders properly', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<script setup lang="ts">
<% if (routing) { %>
import { RouterLink, RouterView } from 'vue-router';
<% } else { %>
import NxWelcome from './NxWelcome.vue';
<% } %>
import NxWelcome from './components/NxWelcome.vue';
</script>

<template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import router from './router';
<% } %>

import { createApp } from 'vue';
import App from './App.vue';
import App from './app/App.vue';

const app = createApp(App);
<% if (routing) { %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import NxWelcome from '../components/NxWelcome.vue'
import NxWelcome from '../app/NxWelcome.vue'
</script>

<template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ div {

exports[`component should generate files with jest 2`] = `
"import { mount } from '@vue/test-utils';
import Hello from '../hello.vue';
import Hello from './hello.vue';
describe('Hello', () => {
it('renders properly', () => {
Expand Down Expand Up @@ -60,7 +60,7 @@ exports[`component should generate files with vitest 2`] = `
"import { describe, it, expect } from 'vitest';
import { mount } from '@vue/test-utils';
import Hello from '../hello.vue';
import Hello from './hello.vue';
describe('Hello', () => {
it('renders properly', () => {
Expand Down
20 changes: 6 additions & 14 deletions packages/vue/src/generators/component/component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { logger, readJson, Tree } from '@nx/devkit';
import { logger, Tree } from '@nx/devkit';
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
import { componentGenerator } from './component';
import { createLib } from '../../utils/test-utils';
Expand Down Expand Up @@ -30,17 +30,14 @@ describe('component', () => {
appTree.exists('my-lib/src/components/hello/hello.vue')
).toBeTruthy();
expect(
appTree.exists('my-lib/src/components/hello/__tests__/hello.spec.ts')
appTree.exists('my-lib/src/components/hello/hello.spec.ts')
).toBeTruthy();

expect(
appTree.read('my-lib/src/components/hello/hello.vue', 'utf-8')
).toMatchSnapshot();
expect(
appTree.read(
'my-lib/src/components/hello/__tests__/hello.spec.ts',
'utf-8'
)
appTree.read('my-lib/src/components/hello/hello.spec.ts', 'utf-8')
).toMatchSnapshot();
});

Expand All @@ -55,10 +52,7 @@ describe('component', () => {
appTree.read('my-lib/src/components/hello/hello.vue', 'utf-8')
).toMatchSnapshot();
expect(
appTree.read(
'my-lib/src/components/hello/__tests__/hello.spec.ts',
'utf-8'
)
appTree.read('my-lib/src/components/hello/hello.spec.ts', 'utf-8')
).toMatchSnapshot();
});

Expand Down Expand Up @@ -114,7 +108,7 @@ describe('component', () => {
appTree.exists('my-lib/src/components/hello/Hello.vue')
).toBeTruthy();
expect(
appTree.exists('my-lib/src/components/hello/__tests__/Hello.spec.ts')
appTree.exists('my-lib/src/components/hello/Hello.spec.ts')
).toBeTruthy();
});
});
Expand All @@ -131,9 +125,7 @@ describe('component', () => {
appTree.exists('my-lib/src/components/HelloWorld/HelloWorld.vue')
).toBeTruthy();
expect(
appTree.exists(
'my-lib/src/components/HelloWorld/__tests__/HelloWorld.spec.ts'
)
appTree.exists('my-lib/src/components/HelloWorld/HelloWorld.spec.ts')
).toBeTruthy();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { describe, it, expect } from 'vitest'
<% } %>

import { mount } from '@vue/test-utils'
import <%= className %> from '../<%= fileName %>.vue';
import <%= className %> from './<%= fileName %>.vue';

describe('<%= className %>', () => {
it('renders properly', () => {
Expand Down
8 changes: 2 additions & 6 deletions packages/vue/src/generators/library/library.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,7 @@ describe('lib', () => {
expect(tree.exists('my-lib/package.json')).toBeFalsy();
expect(tree.exists('my-lib/src/index.ts')).toBeTruthy();
expect(tree.exists('my-lib/src/components/my-lib.vue')).toBeTruthy();
expect(
tree.exists('my-lib/src/components/__tests__/my-lib.spec.ts')
).toBeTruthy();
expect(tree.exists('my-lib/src/components/my-lib.spec.ts')).toBeTruthy();
const eslintJson = readJson(tree, 'my-lib/.eslintrc.json');
expect(eslintJson).toMatchSnapshot();
});
Expand Down Expand Up @@ -206,9 +204,7 @@ describe('lib', () => {
tree.exists('my-dir/my-lib/src/components/my-dir-my-lib.vue')
).toBeTruthy();
expect(
tree.exists(
'my-dir/my-lib/src/components/__tests__/my-dir-my-lib.spec.ts'
)
tree.exists('my-dir/my-lib/src/components/my-dir-my-lib.spec.ts')
).toBeTruthy();
});

Expand Down

0 comments on commit 3d59d43

Please sign in to comment.