Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for Vue #418

Merged
merged 3 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7,896 changes: 2,008 additions & 5,888 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/typescript/custom-paths/subfolder2/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ class ExportClass {
}
}

export = ExportClass;
export default ExportClass;
2 changes: 1 addition & 1 deletion test/typescript/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ class ExportClass {
}
}

export = ExportClass;
export default ExportClass;
37 changes: 37 additions & 0 deletions test/vue.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* eslint-env mocha */
'use strict';

const madge = require('../lib/api');
require('should');

describe('Vue', () => {
const dir = __dirname + '/vue';
// this seems necessary to run the tests successfully
const emptyTsConfig = {compilerOptions: {}};

it('finds import in Vue files using TS', (done) => {
madge(dir + '/BasicComponentTs.vue', {tsConfig: emptyTsConfig}).then((res) => {
res.obj().should.eql({
'one.ts': [],
'BasicComponentTs.vue': ['OneNestedTs.vue', 'TwoNested.vue'],
'OneNestedTs.vue': ['ThreeNested.vue', 'one.ts'],
'ThreeNested.vue': [],
'TwoNested.vue': []
});
done();
}).catch(done);
});

it('finds import in Vue files', (done) => {
madge(dir + '/BasicComponent.vue', {tsConfig: emptyTsConfig}).then((res) => {
res.obj().should.eql({
'two.js': [],
'BasicComponent.vue': ['OneNested.vue', 'TwoNested.vue'],
'OneNested.vue': ['ThreeNested.vue', 'two.js'],
'ThreeNested.vue': [],
'TwoNested.vue': []
});
done();
}).catch(done);
});
});
9 changes: 9 additions & 0 deletions test/vue/BasicComponent.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<script setup>
import OneNested from './OneNested.vue';
import TwoNested from './TwoNested.vue';
</script>

<template>
<OneNested />
<TwoNested />
</template>
9 changes: 9 additions & 0 deletions test/vue/BasicComponentTs.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<script lang="ts" setup>
import OneNested from './OneNestedTs.vue';
import TwoNested from './TwoNested.vue';
</script>

<template>
<OneNested />
<TwoNested />
</template>
11 changes: 11 additions & 0 deletions test/vue/OneNested.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script setup>
import { ref } from "vue";
import ThreeNested from "./ThreeNested.vue";
import "./two";

const count = ref(0);
</script>

<template>
<button @click="count++">{{ count }}</button>
</template>
11 changes: 11 additions & 0 deletions test/vue/OneNestedTs.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script lang="ts" setup>
import { ref } from "vue";
import ThreeNested from "./ThreeNested.vue";
import "./one";

const count = ref(0);
</script>

<template>
<button @click="count++">{{ count }}</button>
</template>
1 change: 1 addition & 0 deletions test/vue/ThreeNested.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<template>Content without deps</template>
1 change: 1 addition & 0 deletions test/vue/TwoNested.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<template>Content without deps</template>
1 change: 1 addition & 0 deletions test/vue/one.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// no content
1 change: 1 addition & 0 deletions test/vue/two.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// no content