Skip to content

Plugin directive for slot #2619

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

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
added tests for slot child relations
  • Loading branch information
paulpflug committed Apr 3, 2016
commit 15072ef2d6b5ec25f2a6f12a014bb18ef63d38db
55 changes: 53 additions & 2 deletions test/unit/specs/directives/element/slot_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,7 @@ describe('Slot Distribution', function () {
expect('"slot" attribute must be static').toHaveBeenWarned()
})

it('plugin directive', function () {
console.log("---------------------------------")
it('plugin directive - scoped data', function () {
var vm = new Vue({
el: el,
template: '<comp1><comp2>{{text}}</comp2></comp1>',
Expand Down Expand Up @@ -487,4 +486,56 @@ describe('Slot Distribution', function () {
})
expect(vm.$el.textContent).toBe('comp1main')
})

it('plugin directive - child relations', function () {
var vm = new Vue({
el: el,
template: '<comp1><comp2></comp2></comp1>',
data: {
text:'main'
},
components: {
comp1: {
template: '<div><comp11><slot></slot><comp11></div>',
components: {
comp11: {
template: '<div><slot plugin></slot></div>'
}
}
},
comp2: {
template: '<div><slot></slot></div>'
}
}
})
expect(vm.$children[0].$children.length).toBe(1)
expect(vm.$children[0].$children[0].$options.name).toBe("comp11")
expect(vm.$children[0].$children[0].$children[0].$options.name).toBe("comp2")
})

it('child relations', function () {
var vm = new Vue({
el: el,
template: '<comp1><comp2></comp2></comp1>',
data: {
text:'main'
},
components: {
comp1: {
template: '<div><comp11><slot></slot><comp11></div>',
components: {
comp11: {
template: '<div><slot></slot></div>'
}
}
},
comp2: {
template: '<div><slot></slot></div>'
}
}
})
expect(vm.$children[0].$children.length).toBe(2)
expect(vm.$children[0].$children[0].$children.length).toBe(0)
expect(vm.$children[0].$children[1].$children.length).toBe(0)
})
})