This repository was archived by the owner on Dec 12, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +70
-8
lines changed
cypress/component/basic/slots Expand file tree Collapse file tree 5 files changed +70
-8
lines changed Original file line number Diff line number Diff line change @@ -216,7 +216,7 @@ describe('Declarative rendering', () => {
216216 { text: ' Learn JavaScript' },
217217 { text: ' Learn Vue' },
218218 { text: ' Build something awesome' },
219- ],
219+ ],
220220 }
221221 }
222222
@@ -518,6 +518,7 @@ Spec | Description
518518[ Mixins] ( cypress/component/basic/mixins ) | Registering Vue mixins
519519[ Plugins] ( cypress/component/basic/plugins ) | Loading additional plugins
520520[ Props] ( cypress/component/basic/props ) | Pass props to the component during mount
521+ [ Slots] ( cypress/component/basic/slots ) | Passing slots and scopedSlots to the component
521522[ Small examples] ( cypress/component/basic/small-examples ) | A few small examples testing forms, buttons
522523<!-- prettier-ignore-end -->
523524
@@ -554,13 +555,6 @@ Repo | Description
554555
555556## Known problems
556557
557- <details id =" slots " >
558- <summary >Slots not supported</summary >
559-
560- See issue [ #364 ] ( https://github.com/bahmutov/cypress-vue-unit-test/issues/364 )
561-
562- </details >
563-
564558<a name =" bundling " />
565559
566560## Bundling
Original file line number Diff line number Diff line change 1+ // In this test file we demo how to test a component with slots and a scoped slot.
2+
3+ // Usage is the same as Vue Test Utils, since slots and scopedSlots
4+ // in the render options are directly passed through to the Utils mount().
5+
6+ /// <reference types="cypress" />
7+
8+ import Card from './Card.vue'
9+ import { mount } from 'cypress-vue-unit-test'
10+
11+ describe ( 'Card' , ( ) => {
12+ it ( 'skipped slots' , ( ) => {
13+ mount ( Card )
14+ cy . contains ( 'Nothing used the Scoped content!' ) . should ( 'be.visible' )
15+ } )
16+
17+ it ( 'renders slots' , ( ) => {
18+ mount ( Card , {
19+ slots : {
20+ header : '<h1>HEADER</h1>' ,
21+ footer : '<div>FOOTER</div>' ,
22+ } ,
23+ } )
24+ cy . contains ( 'h1' , 'HEADER' )
25+ cy . contains ( 'div' , 'FOOTER' )
26+ } )
27+
28+ it ( 'renders scopedSlots' , ( ) => {
29+ mount ( Card , {
30+ scopedSlots : {
31+ default : '<p>Yay! {{props.content}}</p>' ,
32+ } ,
33+ } )
34+ cy . contains ( 'Yay! Scoped content!' ) . should ( 'be.visible' )
35+ cy . contains ( 'Nothing used the Scoped content!' ) . should ( 'not.exist' )
36+ } )
37+ } )
Original file line number Diff line number Diff line change 1+ <template >
2+ <div class =" card" >
3+ <slot name =" header" />
4+ <slot :content =" content" >
5+ <!-- Fallback content if no default slot is given -->
6+ <p >Nothing used the {{ content }}</p >
7+ </slot >
8+ <slot name =" footer" />
9+ </div >
10+ </template >
11+
12+ <script >
13+ // example from https://github.com/testing-library/vue-testing-library/blob/master/src/__tests__/components/Card.vue
14+ // For the sake of demoing scopedSlots, this Card component
15+ // passes a simple string down to its default slot.
16+ export default {
17+ data () {
18+ return {
19+ content: ' Scoped content!'
20+ }
21+ }
22+ }
23+ </script >
Original file line number Diff line number Diff line change 1+ # Slots
2+
3+ Testing [ Vue slots and scopedSlots] ( https://vue-test-utils.vuejs.org/api/options.html#slots ) .
4+ The example taken from [ Vue testing library] ( https://github.com/testing-library/vue-testing-library )
5+
6+ See [ Card.vue] ( Card.vue ) and [ Card.spec.js] ( Card.spec.js )
7+
8+ ![ Slots test] ( images/slots.png )
You can’t perform that action at this time.
0 commit comments