Skip to content

Commit

Permalink
Merge pull request #351 from suusan2go/fix-105
Browse files Browse the repository at this point in the history
Fix #105 label slot for children nodes not working
  • Loading branch information
suusan2go authored Aug 7, 2020
2 parents 342e475 + d7be964 commit fdf21df
Show file tree
Hide file tree
Showing 8 changed files with 288 additions and 140 deletions.
6 changes: 3 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ module.exports = {
moduleNameMapper: {
"^@/(.*)$": "<rootDir>/src/$1",
"^~/(.*)$": "<rootDir>/src/$1",
"^vue$": "vue/dist/vue.common.js"
"^vue$": "vue/dist/vue.common.js",
},
moduleFileExtensions: ["js", "vue", "json", "ts"],
transform: {
"^.+\\.ts$": "ts-jest",
"^.+\\.js$": "babel-jest",
".*\\.(vue)$": "vue-jest"
".*\\.(vue)$": "vue-jest",
},
snapshotSerializers: ["<rootDir>/node_modules/jest-serializer-vue"],
setupFiles: ["<rootDir>/test/setup.ts"],
collectCoverage: true,
collectCoverageFrom: ["<rootDir>/src/**/*"]
collectCoverageFrom: ["<rootDir>/src/**/*"],
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vuetify-draggable-treeview",
"version": "0.0.4",
"version": "0.0.5",
"description": "draggable v-treeview component",
"main": "dist/v-draggable-treeview.umd.js",
"module": "dist/v-draggable-treeview.esm.js",
Expand Down
3 changes: 3 additions & 0 deletions src/DraggableTreeviewNode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
<template v-slot:prepend="{ item, open }">
<slot name="prepend" v-bind="{ item, open }" />
</template>
<template v-slot:label="{ item, open }">
<slot name="label" v-bind="{ item, open }"></slot>
</template>
<template v-slot:append="{ item }">
<slot name="append" v-bind="{ item }" />
</template>
Expand Down
40 changes: 0 additions & 40 deletions test/DraggableTreeview.spec.js

This file was deleted.

85 changes: 85 additions & 0 deletions test/DraggableTreeview.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import Vue from "vue";
import Vuetify from "vuetify";
import { mount } from "@vue/test-utils";
import DraggableTreeview from "../src/DraggableTreeview.vue";

describe("DraggableTreeview", () => {
test("renders correctly", () => {
const wrapper = mount(DraggableTreeview, {
vuetify: new Vuetify({
mocks: {
$vuetify: {
theme: {
isDark: false,
},
},
},
}),
propsData: {
value: [
{
id: 1,
name: "test",
children: [
{
id: 101,
name: "test-children",
children: [{ id: 201, name: "test-children-children" }],
},
],
},
],
},
});
expect(wrapper.element).toMatchSnapshot();
wrapper.find(".v-treeview-node__root").trigger("click");
Vue.nextTick().then(() => {
expect(wrapper.element).toMatchSnapshot();
});
});

test("renders correctly with slot", () => {
const wrapper = mount(DraggableTreeview, {
vuetify: new Vuetify({
mocks: {
$vuetify: {
theme: {
isDark: false,
},
},
},
}),
scopedSlots: {
label({ item }: any) {
return this.$createElement(
"span",
{
attrs: { class: "primary--text" },
},
[item.name]
);
},
},
propsData: {
value: [
{
id: 1,
name: "test",
children: [
{
id: 101,
name: "test-children",
children: [{ id: 201, name: "test-children-children" }],
},
],
},
],
},
});
expect(wrapper.element).toMatchSnapshot();
wrapper.find(".v-treeview-node__root").trigger("click");
Vue.nextTick().then(() => {
expect(wrapper.element).toMatchSnapshot();
});
});
});
95 changes: 0 additions & 95 deletions test/__snapshots__/DraggableTreeview.spec.js.snap

This file was deleted.

Loading

0 comments on commit fdf21df

Please sign in to comment.