From e6a54b2e6fbf17fab945b38e666fd7d2dbc5fb51 Mon Sep 17 00:00:00 2001 From: 38elements <38elements@users.noreply.github.com> Date: Sun, 15 Apr 2018 00:27:34 +0900 Subject: [PATCH] feat: add scoped slots option (#507) --- docs/en/README.md | 1 + docs/en/SUMMARY.md | 1 + docs/en/api/README.md | 1 + docs/en/api/options.md | 29 ++++++- flow/options.flow.js | 1 + packages/create-instance/add-scoped-slots.js | 17 ++++ packages/create-instance/add-slots.js | 6 +- packages/create-instance/create-instance.js | 36 +++++++++ packages/server-test-utils/types/index.d.ts | 1 + packages/test-utils/types/index.d.ts | 1 + packages/test-utils/types/test/mount.ts | 3 + .../component-with-scoped-slots.vue | 33 ++++++++ .../mounting-options/scopedSlots.spec.js | 81 +++++++++++++++++++ test/specs/mounting-options/slots.spec.js | 2 +- 14 files changed, 208 insertions(+), 5 deletions(-) create mode 100644 packages/create-instance/add-scoped-slots.js create mode 100644 test/resources/components/component-with-scoped-slots.vue create mode 100644 test/specs/mounting-options/scopedSlots.spec.js diff --git a/docs/en/README.md b/docs/en/README.md index 17be425d7..3ab665ced 100644 --- a/docs/en/README.md +++ b/docs/en/README.md @@ -23,6 +23,7 @@ Vue Test Utils is the official unit testing utility library for Vue.js. * [Mounting Options](api/options.md) - [context](api/options.md#context) - [slots](api/options.md#slots) + - [scopedSlots](api/options.md#scopedslots) - [stubs](api/options.md#stubs) - [mocks](api/options.md#mocks) - [localVue](api/options.md#localvue) diff --git a/docs/en/SUMMARY.md b/docs/en/SUMMARY.md index f743a46a2..99f0a09c9 100644 --- a/docs/en/SUMMARY.md +++ b/docs/en/SUMMARY.md @@ -19,6 +19,7 @@ * [Mounting Options](api/options.md) - [context](api/options.md#context) - [slots](api/options.md#slots) + - [scopedSlots](api/options.md#scopedslots) - [stubs](api/options.md#stubs) - [mocks](api/options.md#mocks) - [localVue](api/options.md#localvue) diff --git a/docs/en/api/README.md b/docs/en/api/README.md index 879f38c01..ed8fe907c 100644 --- a/docs/en/api/README.md +++ b/docs/en/api/README.md @@ -7,6 +7,7 @@ * [Mounting Options](./options.md) - [context](./options.md#context) - [slots](./options.md#slots) + - [scopedSlots](./options.md#scopedslots) - [stubs](./options.md#stubs) - [mocks](./options.md#mocks) - [localVue](./options.md#localvue) diff --git a/docs/en/api/options.md b/docs/en/api/options.md index 3b4828578..9370fa8d8 100644 --- a/docs/en/api/options.md +++ b/docs/en/api/options.md @@ -6,6 +6,7 @@ Options for `mount` and `shallow`. The options object can contain both Vue Test - [`context`](#context) - [`slots`](#slots) +- [`scopedSlots`](#scopedslots) - [`stubs`](#stubs) - [`mocks`](#mocks) - [`localVue`](#localvue) @@ -66,7 +67,33 @@ You can pass text to `slots`. There is a limitation to this. This does not support PhantomJS. -Please use [Puppeteer](https://github.com/karma-runner/karma-chrome-launcher#headless-chromium-with-puppeteer). +You can use [Puppeteer](https://github.com/karma-runner/karma-chrome-launcher#headless-chromium-with-puppeteer) as an alternative. + +### `scopedSlots` + +- type: `{ [name: string]: string }` + +Provide an object of scoped slots contents to the component. The key corresponds to the slot name. The value can be a template string. + +There are three limitations. + +* This option is only supported in vue@2.5+. + +* You can not use `