Skip to content

Commit

Permalink
Merge pull request #418 from fdc-viktor-luft/vl/239
Browse files Browse the repository at this point in the history
Add tests for Vue
  • Loading branch information
vikingair authored May 30, 2024
2 parents 5c9b1c3 + 3a52fae commit 6612178
Show file tree
Hide file tree
Showing 12 changed files with 2,091 additions and 5,890 deletions.
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

0 comments on commit 6612178

Please sign in to comment.