From 5b9925a87acfd7b5646821aac9bdf29e417073a8 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Thu, 16 Nov 2017 03:17:55 +0000 Subject: [PATCH 01/71] start translate :fire: updating all menus --- docs/pt-br/README.md | 74 +++++ docs/pt-br/SUMMARY.md | 70 +++++ docs/pt-br/api/README.md | 49 ++++ docs/pt-br/api/components/README.md | 5 + .../api/components/TransitionGroupStub.md | 30 ++ docs/pt-br/api/components/TransitionStub.md | 30 ++ docs/pt-br/api/config.md | 25 ++ docs/pt-br/api/createLocalVue.md | 28 ++ docs/pt-br/api/mount.md | 136 +++++++++ docs/pt-br/api/options.md | 165 +++++++++++ docs/pt-br/api/selectors.md | 43 +++ docs/pt-br/api/shallow.md | 124 ++++++++ docs/pt-br/api/wrapper-array/README.md | 11 + docs/pt-br/api/wrapper-array/at.md | 21 ++ docs/pt-br/api/wrapper-array/contains.md | 24 ++ docs/pt-br/api/wrapper-array/destroy.md | 18 ++ docs/pt-br/api/wrapper-array/hasAttribute.md | 21 ++ docs/pt-br/api/wrapper-array/hasClass.md | 20 ++ docs/pt-br/api/wrapper-array/hasProp.md | 24 ++ docs/pt-br/api/wrapper-array/hasStyle.md | 24 ++ docs/pt-br/api/wrapper-array/is.md | 20 ++ docs/pt-br/api/wrapper-array/isEmpty.md | 17 ++ docs/pt-br/api/wrapper-array/isVueInstance.md | 18 ++ docs/pt-br/api/wrapper-array/setComputed.md | 26 ++ docs/pt-br/api/wrapper-array/setData.md | 22 ++ docs/pt-br/api/wrapper-array/setMethods.md | 27 ++ docs/pt-br/api/wrapper-array/setProps.md | 22 ++ docs/pt-br/api/wrapper-array/trigger.md | 26 ++ docs/pt-br/api/wrapper-array/update.md | 20 ++ docs/pt-br/api/wrapper/README.md | 16 ++ docs/pt-br/api/wrapper/contains.md | 23 ++ docs/pt-br/api/wrapper/destroy.md | 20 ++ docs/pt-br/api/wrapper/emitted.md | 33 +++ docs/pt-br/api/wrapper/emittedByOrder.md | 28 ++ docs/pt-br/api/wrapper/exists.md | 21 ++ docs/pt-br/api/wrapper/find.md | 27 ++ docs/pt-br/api/wrapper/findAll.md | 27 ++ docs/pt-br/api/wrapper/hasAttribute.md | 37 +++ docs/pt-br/api/wrapper/hasClass.md | 21 ++ docs/pt-br/api/wrapper/hasProp.md | 25 ++ docs/pt-br/api/wrapper/hasStyle.md | 24 ++ docs/pt-br/api/wrapper/html.md | 16 ++ docs/pt-br/api/wrapper/is.md | 19 ++ docs/pt-br/api/wrapper/isEmpty.md | 16 ++ docs/pt-br/api/wrapper/isVueInstance.md | 16 ++ docs/pt-br/api/wrapper/name.md | 18 ++ docs/pt-br/api/wrapper/setComputed.md | 43 +++ docs/pt-br/api/wrapper/setData.md | 20 ++ docs/pt-br/api/wrapper/setMethods.md | 24 ++ docs/pt-br/api/wrapper/setProps.md | 48 ++++ docs/pt-br/api/wrapper/text.md | 16 ++ docs/pt-br/api/wrapper/trigger.md | 38 +++ docs/pt-br/api/wrapper/update.md | 19 ++ docs/pt-br/guides/README.md | 10 + docs/pt-br/guides/choosing-a-test-runner.md | 45 +++ docs/pt-br/guides/common-tips.md | 135 +++++++++ docs/pt-br/guides/dom-events.md | 196 +++++++++++++ docs/pt-br/guides/getting-started.md | 116 ++++++++ docs/pt-br/guides/testing-SFCs-with-jest.md | 178 ++++++++++++ .../guides/testing-SFCs-with-mocha-webpack.md | 180 ++++++++++++ docs/pt-br/guides/using-with-vue-router.md | 71 +++++ docs/pt-br/guides/using-with-vuex.md | 264 ++++++++++++++++++ 62 files changed, 2930 insertions(+) create mode 100644 docs/pt-br/README.md create mode 100644 docs/pt-br/SUMMARY.md create mode 100644 docs/pt-br/api/README.md create mode 100644 docs/pt-br/api/components/README.md create mode 100644 docs/pt-br/api/components/TransitionGroupStub.md create mode 100644 docs/pt-br/api/components/TransitionStub.md create mode 100644 docs/pt-br/api/config.md create mode 100644 docs/pt-br/api/createLocalVue.md create mode 100644 docs/pt-br/api/mount.md create mode 100644 docs/pt-br/api/options.md create mode 100644 docs/pt-br/api/selectors.md create mode 100644 docs/pt-br/api/shallow.md create mode 100644 docs/pt-br/api/wrapper-array/README.md create mode 100644 docs/pt-br/api/wrapper-array/at.md create mode 100644 docs/pt-br/api/wrapper-array/contains.md create mode 100644 docs/pt-br/api/wrapper-array/destroy.md create mode 100644 docs/pt-br/api/wrapper-array/hasAttribute.md create mode 100644 docs/pt-br/api/wrapper-array/hasClass.md create mode 100644 docs/pt-br/api/wrapper-array/hasProp.md create mode 100644 docs/pt-br/api/wrapper-array/hasStyle.md create mode 100644 docs/pt-br/api/wrapper-array/is.md create mode 100644 docs/pt-br/api/wrapper-array/isEmpty.md create mode 100644 docs/pt-br/api/wrapper-array/isVueInstance.md create mode 100644 docs/pt-br/api/wrapper-array/setComputed.md create mode 100644 docs/pt-br/api/wrapper-array/setData.md create mode 100644 docs/pt-br/api/wrapper-array/setMethods.md create mode 100644 docs/pt-br/api/wrapper-array/setProps.md create mode 100644 docs/pt-br/api/wrapper-array/trigger.md create mode 100644 docs/pt-br/api/wrapper-array/update.md create mode 100644 docs/pt-br/api/wrapper/README.md create mode 100644 docs/pt-br/api/wrapper/contains.md create mode 100644 docs/pt-br/api/wrapper/destroy.md create mode 100644 docs/pt-br/api/wrapper/emitted.md create mode 100644 docs/pt-br/api/wrapper/emittedByOrder.md create mode 100644 docs/pt-br/api/wrapper/exists.md create mode 100644 docs/pt-br/api/wrapper/find.md create mode 100644 docs/pt-br/api/wrapper/findAll.md create mode 100644 docs/pt-br/api/wrapper/hasAttribute.md create mode 100644 docs/pt-br/api/wrapper/hasClass.md create mode 100644 docs/pt-br/api/wrapper/hasProp.md create mode 100644 docs/pt-br/api/wrapper/hasStyle.md create mode 100644 docs/pt-br/api/wrapper/html.md create mode 100644 docs/pt-br/api/wrapper/is.md create mode 100644 docs/pt-br/api/wrapper/isEmpty.md create mode 100644 docs/pt-br/api/wrapper/isVueInstance.md create mode 100644 docs/pt-br/api/wrapper/name.md create mode 100644 docs/pt-br/api/wrapper/setComputed.md create mode 100644 docs/pt-br/api/wrapper/setData.md create mode 100644 docs/pt-br/api/wrapper/setMethods.md create mode 100644 docs/pt-br/api/wrapper/setProps.md create mode 100644 docs/pt-br/api/wrapper/text.md create mode 100644 docs/pt-br/api/wrapper/trigger.md create mode 100644 docs/pt-br/api/wrapper/update.md create mode 100644 docs/pt-br/guides/README.md create mode 100644 docs/pt-br/guides/choosing-a-test-runner.md create mode 100644 docs/pt-br/guides/common-tips.md create mode 100644 docs/pt-br/guides/dom-events.md create mode 100644 docs/pt-br/guides/getting-started.md create mode 100644 docs/pt-br/guides/testing-SFCs-with-jest.md create mode 100644 docs/pt-br/guides/testing-SFCs-with-mocha-webpack.md create mode 100644 docs/pt-br/guides/using-with-vue-router.md create mode 100644 docs/pt-br/guides/using-with-vuex.md diff --git a/docs/pt-br/README.md b/docs/pt-br/README.md new file mode 100644 index 000000000..a3eaf2bdc --- /dev/null +++ b/docs/pt-br/README.md @@ -0,0 +1,74 @@ +# vue-test-utils + +`vue-test-utils` é a biblioteca oficial de testes de unidade para o Vue.js. + +## Tabela de conteúdo + +* [Guia](guides/README.md) + * [Iniciando](guides/getting-started.md) + * [Dicas comuns](guides/common-tips.md) + * [Mouse, Tecla e outros eventos do DOM](guides/dom-events.md) + * [Escolhendo um executador de testes](guides/choosing-a-test-runner.md) + * [Testando SFCs com Jest](guides/testing-SFCs-with-jest.md) + * [Testando SFCs com Mocha + webpack](guides/testing-SFCs-with-mocha-webpack.md) + * [Usando com o Vue Router](guides/using-with-vue-router.md) + * [Usando com o Vuex](guides/using-with-vuex.md) +* [API](api/README.md) + * [mount](api/mount.md) + * [shallow](api/shallow.md) + * [Opções de montagem](api/options.md) + - [context](api/options.md#context) + - [slots](api/options.md#slots) + - [stubs](api/options.md#stubs) + - [mocks](api/options.md#mocks) + - [localVue](api/options.md#localvue) + - [attachToDocument](api/options.md#attachtodocument) + - [attrs](api/options.md#attrs) + - [listeners](api/options.md#listeners) + - [clone](api/options.md#clone) + * [Wrapper](api/wrapper/README.md) + * [contains](api/wrapper/contains.md) + * [emitted](api/wrapper/emitted.md) + * [emittedByOrder](api/wrapper/emittedByOrder.md) + * [find](api/wrapper/find.md) + * [findAll](api/wrapper/findAll.md) + * [hasAttribute](api/wrapper/hasAttribute.md) + * [hasClass](api/wrapper/hasClass.md) + * [hasProp](api/wrapper/hasProp.md) + * [hasStyle](api/wrapper/hasStyle.md) + * [html](api/wrapper/html.md) + * [is](api/wrapper/is.md) + * [isEmpty](api/wrapper/isEmpty.md) + * [isVueInstance](api/wrapper/isVueInstance.md) + * [name](api/wrapper/name.md) + * [setComputed](api/wrapper/setComputed.md) + * [setData](api/wrapper/setData.md) + * [setMethods](api/wrapper/setMethods.md) + * [setProps](api/wrapper/setProps.md) + * [text](api/wrapper/text.md) + * [trigger](api/wrapper/trigger.md) + * [update](api/wrapper/update.md) + * [destroy](api/wrapper/destroy.md) + * [WrapperArray](api/wrapper-array/README.md) + * [at](api/wrapper-array/at.md) + * [contains](api/wrapper-array/contains.md) + * [hasAttribute](api/wrapper-array/hasAttribute.md) + * [hasClass](api/wrapper-array/hasClass.md) + * [hasProp](api/wrapper-array/hasProp.md) + * [hasStyle](api/wrapper-array/hasStyle.md) + * [is](api/wrapper-array/is.md) + * [isEmpty](api/wrapper-array/isEmpty.md) + * [isVueInstance](api/wrapper-array/isVueInstance.md) + * [setComputed](api/wrapper-array/setComputed.md) + * [setData](api/wrapper-array/setData.md) + * [setMethods](api/wrapper-array/setMethods.md) + * [setProps](api/wrapper-array/setProps.md) + * [trigger](api/wrapper-array/trigger.md) + * [update](api/wrapper-array/update.md) + * [destroy](api/wrapper-array/destroy.md) + * [components](api/components/README.md) + * [TransitionStub](api/components/TransitionStub.md) + * [TransitionGroupStub](api/components/TransitionGroupStub.md) + * [Seletores](api/selectors.md) + * [createLocalVue](api/createLocalVue.md) + * [config](api/config.md) diff --git a/docs/pt-br/SUMMARY.md b/docs/pt-br/SUMMARY.md new file mode 100644 index 000000000..0ba7935c8 --- /dev/null +++ b/docs/pt-br/SUMMARY.md @@ -0,0 +1,70 @@ +## Tabela de conteúdo + +* [Guia](guides/README.md) + * [Iniciando](guides/getting-started.md) + * [Dicas comuns](guides/common-tips.md) + * [Mouse, Tecla e outros eventos do DOM](guides/dom-events.md) + * [Escolhendo um executador de testes](guides/choosing-a-test-runner.md) + * [Testando SFCs com Jest](guides/testing-SFCs-with-jest.md) + * [Testando SFCs com Mocha + webpack](guides/testing-SFCs-with-mocha-webpack.md) + * [Usando com o Vue Router](guides/using-with-vue-router.md) + * [Usando com o Vuex](guides/using-with-vuex.md) +* [API](api/README.md) + * [mount](api/mount.md) + * [shallow](api/shallow.md) + * [Opções de montagem](api/options.md) + - [context](api/options.md#context) + - [slots](api/options.md#slots) + - [stubs](api/options.md#stubs) + - [mocks](api/options.md#mocks) + - [localVue](api/options.md#localvue) + - [attachToDocument](api/options.md#attachtodocument) + - [attrs](api/options.md#attrs) + - [listeners](api/options.md#listeners) + - [clone](api/options.md#clone) + * [Wrapper](api/wrapper/README.md) + * [contains](api/wrapper/contains.md) + * [emitted](api/wrapper/emitted.md) + * [emittedByOrder](api/wrapper/emittedByOrder.md) + * [find](api/wrapper/find.md) + * [findAll](api/wrapper/findAll.md) + * [hasAttribute](api/wrapper/hasAttribute.md) + * [hasClass](api/wrapper/hasClass.md) + * [hasProp](api/wrapper/hasProp.md) + * [hasStyle](api/wrapper/hasStyle.md) + * [html](api/wrapper/html.md) + * [is](api/wrapper/is.md) + * [isEmpty](api/wrapper/isEmpty.md) + * [isVueInstance](api/wrapper/isVueInstance.md) + * [name](api/wrapper/name.md) + * [setComputed](api/wrapper/setComputed.md) + * [setData](api/wrapper/setData.md) + * [setMethods](api/wrapper/setMethods.md) + * [setProps](api/wrapper/setProps.md) + * [text](api/wrapper/text.md) + * [trigger](api/wrapper/trigger.md) + * [update](api/wrapper/update.md) + * [destroy](api/wrapper/destroy.md) + * [WrapperArray](api/wrapper-array/README.md) + * [at](api/wrapper-array/at.md) + * [contains](api/wrapper-array/contains.md) + * [hasAttribute](api/wrapper-array/hasAttribute.md) + * [hasClass](api/wrapper-array/hasClass.md) + * [hasProp](api/wrapper-array/hasProp.md) + * [hasStyle](api/wrapper-array/hasStyle.md) + * [is](api/wrapper-array/is.md) + * [isEmpty](api/wrapper-array/isEmpty.md) + * [isVueInstance](api/wrapper-array/isVueInstance.md) + * [setComputed](api/wrapper-array/setComputed.md) + * [setData](api/wrapper-array/setData.md) + * [setMethods](api/wrapper-array/setMethods.md) + * [setProps](api/wrapper-array/setProps.md) + * [trigger](api/wrapper-array/trigger.md) + * [update](api/wrapper-array/update.md) + * [destroy](api/wrapper-array/destroy.md) + * [components](api/components/README.md) + * [TransitionStub](api/components/TransitionStub.md) + * [TransitionGroupStub](api/components/TransitionGroupStub.md) + * [Seletores](api/selectors.md) + * [createLocalVue](api/createLocalVue.md) + * [config](api/config.md) diff --git a/docs/pt-br/api/README.md b/docs/pt-br/api/README.md new file mode 100644 index 000000000..6941e1a63 --- /dev/null +++ b/docs/pt-br/api/README.md @@ -0,0 +1,49 @@ +# API + +* [mount](./mount.md) +* [shallow](./shallow.md) +* [Opções de montagem](./options.md) + - [context](./options.md#context) + - [slots](./options.md#slots) + - [stubs](./options.md#stubs) + - [mocks](./options.md#mocks) + - [localVue](./options.md#localvue) + - [attachToDocument](./options.md#attachtodocument) + - [attrs](./options.md#attrs) + - [listeners](./options.md#listeners) + - [clone](./options.md#clone) +* [Wrapper](./wrapper/README.md) + * [contains](./wrapper/contains.md) + * [emitted](./wrapper/emitted.md) + * [emittedByOrder](./wrapper/emittedByOrder.md) + * [find](./wrapper/find.md) + * [hasAttribute](./wrapper/hasAttribute.md) + * [hasClass](./wrapper/hasClass.md) + * [hasProp](./wrapper/hasProp.md) + * [hasStyle](./wrapper/hasStyle.md) + * [html](./wrapper/html.md) + * [is](./wrapper/is.md) + * [isEmpty](./wrapper/isEmpty.md) + * [isVueInstance](./wrapper/isVueInstance.md) + * [name](./wrapper/name.md) + * [update](./wrapper/update.md) + * [setData](./wrapper/setData.md) + * [setProps](./wrapper/setProps.md) + * [text](./wrapper/text.md) + * [trigger](./wrapper/trigger.md) +* [WrapperArray](./wrapper-array/README.md) + * [at](./wrapper-array/at.md) + * [contains](./wrapper-array/contains.md) + * [hasAttribute](./wrapper-array/hasAttribute.md) + * [hasClass](./wrapper-array/hasClass.md) + * [hasProp](./wrapper-array/hasProp.md) + * [hasStyle](./wrapper-array/hasStyle.md) + * [is](./wrapper-array/is.md) + * [isEmpty](./wrapper-array/isEmpty.md) + * [isVueInstance](./wrapper-array/isVueInstance.md) + * [update](./wrapper-array/update.md) + * [setData](./wrapper-array/setData.md) + * [setProps](./wrapper-array/setProps.md) + * [trigger](./wrapper-array/trigger.md) +* [createLocalVue](./createLocalVue.md) +* [Seletores](./selectors.md) diff --git a/docs/pt-br/api/components/README.md b/docs/pt-br/api/components/README.md new file mode 100644 index 000000000..b6db0b05b --- /dev/null +++ b/docs/pt-br/api/components/README.md @@ -0,0 +1,5 @@ +# Components + +vue-test-utils includes utility components you can use to stub components. + +[TransitionStub](./TransitionStub.md) and [TransitionGroupStub](./TransitionGroupStub.md) are used to stub `transition` and `transition-group` components by default. You can edit the stubs by editing the config. diff --git a/docs/pt-br/api/components/TransitionGroupStub.md b/docs/pt-br/api/components/TransitionGroupStub.md new file mode 100644 index 000000000..f7061f5c3 --- /dev/null +++ b/docs/pt-br/api/components/TransitionGroupStub.md @@ -0,0 +1,30 @@ +# TransitionGroupStub + +A component to stub the `transition-group` wrapper component. Instead of performing transitions asynchronously, it returns the child components synchronously. + +This is set to stub all `transition-group` components by default in the vue-test-utils config. To use the built-in `transition-group` wrapper component set `config.stubs[transition-group]` to false: + +```js +import VueTestUtils from 'vue-test-utils' + +VueTestUtils.config.stubs.transition = false +``` + +To reset it to stub transition components: +```js +import VueTestUtils, { TransitionGroupStub } from 'vue-test-utils' + +VueTestUtils.config.stubs['transition-group'] = TransitionGroupStub +``` + +To set it as a stub in mounting options: + +```js +import { mount, TransitionGroupStub } from 'vue-test-utils' + +mount(Component, { + stubs: { + 'transition-group': TransitionGroupStub + } +}) +``` diff --git a/docs/pt-br/api/components/TransitionStub.md b/docs/pt-br/api/components/TransitionStub.md new file mode 100644 index 000000000..8a11d34eb --- /dev/null +++ b/docs/pt-br/api/components/TransitionStub.md @@ -0,0 +1,30 @@ +# TransitionStub + +A component to stub the `transition` wrapper component. Instead of performing transitions asynchronously, it returns the child component synchronously. + +This is set to stub all `transition` components by default in the vue-test-utils config. To use the built-in `transition` wrapper component set `config.stubs.transition` to false: + +```js +import VueTestUtils from 'vue-test-utils' + +VueTestUtils.config.stubs.transition = false +``` + +To reset it to stub transition components: +```js +import VueTestUtils, { TransitionStub } from 'vue-test-utils' + +VueTestUtils.config.stubs.transition = TransitionStub +``` + +To set it as a stub in mounting options: + +```js +import { mount, TransitionStub } from 'vue-test-utils' + +mount(Component, { + stubs: { + transition: TransitionStub + } +}) +``` diff --git a/docs/pt-br/api/config.md b/docs/pt-br/api/config.md new file mode 100644 index 000000000..6f44dd639 --- /dev/null +++ b/docs/pt-br/api/config.md @@ -0,0 +1,25 @@ +# Config + +vue-test-utils includes a config object to defined options used by vue-test-utils. + +## `vue-test-utils` Config Options + +### `stubs` + +- type: `Object` +- default: `{ + transition: TransitionStub, + 'transition-group': TransitionGroupStub +}` + +Stubs to use in components. These are overwritten by `stubs` passed in the mounting options. + +When passing `stubs` as an array in the mounting options, `config.stubs` are converted to an array, and will stub components with a basic component that returns a div. + +Example: + +```js +import VueTestUtils from 'vue-test-utils' + +VueTestUtils.config.stubs['my-compomnent'] = '
' +``` diff --git a/docs/pt-br/api/createLocalVue.md b/docs/pt-br/api/createLocalVue.md new file mode 100644 index 000000000..a3cbfcee3 --- /dev/null +++ b/docs/pt-br/api/createLocalVue.md @@ -0,0 +1,28 @@ +# createLocalVue() + +- **Returns:** + - `{Component}` + +- **Usage:** + +`createLocalVue` returns a Vue class for you to add components, mixins and install plugins without polluting the global Vue class. + +Use it with `options.localVue` + +```js +import { createLocalVue, shallow } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +const localVue = createLocalVue() +const wrapper = shallow(Foo, { + localVue, + mocks: { foo: true } +}) +expect(wrapper.vm.foo).toBe(true) + +const freshWrapper = shallow(Foo) +expect(freshWrapper.vm.foo).toBe(false) +``` + +- **See also:** [Common Tips](../guides/common-tips.md#applying-global-plugins-and-mixins) diff --git a/docs/pt-br/api/mount.md b/docs/pt-br/api/mount.md new file mode 100644 index 000000000..aaddd3e2f --- /dev/null +++ b/docs/pt-br/api/mount.md @@ -0,0 +1,136 @@ +# mount(component {, options}]) + +- **Arguments:** + + - `{Component} component` + - `{Object} options` + +- **Returns:** `{Wrapper}` + +- **Options:** + +See [options](options.md) + +- **Usage:** + +Returns [`Wrapper`](wrapper/README.md) of first DOM node or Vue component matching selector. + +Use any valid [selector](selectors.md). + +**Without options:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +describe('Foo', () => { + it('renders a div', () => { + const wrapper = mount(Foo) + expect(wrapper.contains('div')).toBe(true) + }) +}) +``` +**With Vue options:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +describe('Foo', () => { + it('renders a div', () => { + const wrapper = mount(Foo, { + propsData: { + color: 'red' + } + }) + expect(wrapper.hasProp('color', 'red')).toBe(true) + }) +}) +``` + +**Attach to DOM:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +describe('Foo', () => { + it('renders a div', () => { + const wrapper = mount(Foo, { + attachToDocument: true + }) + expect(wrapper.contains('div')).toBe(true) + }) +}) +``` +**Default and named slots:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' +import Bar from './Bar.vue' +import FooBar from './FooBar.vue' + +describe('Foo', () => { + it('renders a div', () => { + const wrapper = mount(Foo, { + slots: { + default: [Bar, FooBar], + fooBar: FooBar, // Will match , + foo: '
' + } + }) + expect(wrapper.contains('div')).toBe(true) + }) +}) +``` + +**Stubbing global properties:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +describe('Foo', () => { + it('renders a div', () => { + const $route = { path: 'http://www.example-path.com' } + const wrapper = mount(Foo, { + mocks: { + $route + } + }) + expect(wrapper.vm.$route.path).toBe($route.path) + }) +}) +``` + +**Stubbing components:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' +import Bar from './Bar.vue' +import Faz from './Faz.vue' + +describe('Foo', () => { + it('renders a div', () => { + const wrapper = mount(Foo, { + stub: { + Bar: '
, + foo: '
' + } +}) +expect(wrapper.find('div')).toBe(true) +``` + +### `stubs` + +- type: `{ [name: string]: Component | boolean } | Array` + +Stubs child components. Can be an Array of component names to stub, or an object. + +Example: + +```js +import Foo from './Foo.vue' + +mount(Component, { + stubs: ['registered-component'] +}) + +shallow(Component, { + stubs: { + // stub with a specific implementation + 'registered-component': Foo, + // create default stub + 'another-component': true + } +}) +``` + +### `mocks` + +- type: `Object` + +Add additional properties to the instance. Useful for mocking global injections. + +Example: + +```js +import { expect } from 'chai' + +const $route = { path: 'http://www.example-path.com' } +const wrapper = shallow(Component, { + mocks: { + $route + } +}) +expect(wrapper.vm.$route.path).toBe($route.path) +``` + +### `localVue` + +- type: `Vue` + +A local copy of Vue created by [createLocalVue](./createLocalVue.md) to use when mounting the component. Installing plugins on this copy of Vue prevents polluting the original `Vue` copy. + +Example: + +```js +import { createLocalVue, mount } from 'vue-test-utils' +import VueRouter from 'vue-router' +import { expect } from 'chai' +import Foo from './Foo.vue' + +const localVue = createLocalVue() +localVue.use(VueRouter) + +const routes = [ + { path: '/foo', component: Foo } +] + +const router = new VueRouter({ + routes +}) + +const wrapper = mount(Component, { + localVue, + router +}) +expect(wrapper.vm.$route).toBeInstanceOf(Object) +``` + +### `attachToDocument` + +- type: `boolean` +- default: `false` + +Component will be attach to DOM when rendered if set to `true`. This can be used with [`hasStyle`](wrapper/hasStyle.md) to check multi element CSS selectors. + +### `attrs` + +- type: `Object` + +Set the component instance's `$attrs` object. + +### `listeners` + +- type: `Object` + +Set the component instance's `$listeners` object. + +### `clone` + +- type: `boolean` +- default: `true` + +Clones component before mounting if `true`, which avoids mutating the original component definition. + +`options.mocks` (`Object`): Add globals to Vue instance. + +`options.localVue` (`Object`): vue class to use in `mount`. See [createLocalVue](createLocalVue.md) diff --git a/docs/pt-br/api/selectors.md b/docs/pt-br/api/selectors.md new file mode 100644 index 000000000..0c6a47f3b --- /dev/null +++ b/docs/pt-br/api/selectors.md @@ -0,0 +1,43 @@ +# Selectors + +A lot of methods take a selector as an argument. A selector can either be a CSS selector, or a Vue component. + +## CSS Selectors + +mount handles any valid CSS selector: + +- tag selectors (div, foo, bar) +- class selectors (.foo, .bar) +- attribute selectors ([foo], [foo="bar"]) +- id selectors (#foo, #bar) +- pseudo selectors (div:first-of-type) + +You can also use combinators: + +- direct descendant combinator (div > #bar > .foo) +- general descendant combinator (div #bar .foo) +- adjacent sibling selector (div + .foo) +- general sibling selector (div ~ .foo) + +## Vue Components + +Vue components are also valid selectors. + +vue-test-utils uses the `name` property to search the instance tree for matching Vue components. + +```js +// Foo.vue + +export default{ + name: 'FooComponent' +} +``` + +```js +import { shallow } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +const wrapper = shallow(Foo) +expect(wrapper.is(Foo)).toBe(true) +``` diff --git a/docs/pt-br/api/shallow.md b/docs/pt-br/api/shallow.md new file mode 100644 index 000000000..fa16e9d24 --- /dev/null +++ b/docs/pt-br/api/shallow.md @@ -0,0 +1,124 @@ +# shallow(component {, options}]) + +- **Arguments:** + + - `{Component} component` + - `{Object} options` + - `{boolean} attachToDocument` + - `{Object} context` + - `{Object} slots` + - `{Array|Component|String} default` + - `{Array|Component|String} named` + - `{Object} mocks` + - `{Object|Array} stubs` + - `{boolean} clone` + - `{Object} children` + - `{Vue} localVue` + +- **Returns:** `{Wrapper}` + +- **Options:** + +See [options](./options.md) + +- **Usage:** + +Returns [`Wrapper`](./wrapper/README.md) of first DOM node or Vue component matching selector. + +Stubs all child components. + +Use any valid [selector](./selectors.md). + +**Without options:** + +```js +import { shallow } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +describe('Foo', () => { + it('renders a div', () => { + const wrapper = shallow(Foo) + expect(wrapper.contains('div')).toBe(true) + }) +}) +``` + +**With Vue options:** + +```js +import { shallow } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +describe('Foo', () => { + it('renders a div', () => { + const wrapper = shallow(Foo, { + propsData: { + color: 'red' + } + }) + expect(wrapper.hasProp('color', 'red')).toBe(true) + }) +}) +``` + +**Attach to DOM:** + +```js +import { shallow } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +describe('Foo', () => { + it('renders a div', () => { + const wrapper = shallow(Foo, { + attachToDocument: true + }) + expect(wrapper.contains('div')).toBe(true) + }) +}) +``` + +**Default and named slots:** + +```js +import { shallow } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' +import Bar from './Bar.vue' +import FooBar from './FooBar.vue' + +describe('Foo', () => { + it('renders a div', () => { + const wrapper = shallow(Foo, { + slots: { + default: [Bar, FooBar], + fooBar: FooBar, // Will match , + foo: '
' + } + }) + expect(wrapper.find('div')).toBe(true) + }) +}) +``` + +**Stubbing global properties:** + +```js +import { shallow } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +describe('Foo', () => { + it('renders a div', () => { + const $route = { path: 'http://www.example-path.com' } + const wrapper = shallow(Foo, { + mocks: { + $route + } + }) + expect(wrapper.vm.$route.path).toBe($route.path) + }) +}) +``` diff --git a/docs/pt-br/api/wrapper-array/README.md b/docs/pt-br/api/wrapper-array/README.md new file mode 100644 index 000000000..2a6d40ccc --- /dev/null +++ b/docs/pt-br/api/wrapper-array/README.md @@ -0,0 +1,11 @@ +# WrapperArray + +A `WrapperArray` is an object that contains an array of [Wrappers](../wrapper/README.md), and methods to test the `Wrappers`. + +- **Properties:** + +`length` `number`: the number of `Wrappers` contained in the `WrapperArray` + + - **Methods:** + +There is a detailed list of methods in the WrapperArray section of the docs. diff --git a/docs/pt-br/api/wrapper-array/at.md b/docs/pt-br/api/wrapper-array/at.md new file mode 100644 index 000000000..e5864bf1b --- /dev/null +++ b/docs/pt-br/api/wrapper-array/at.md @@ -0,0 +1,21 @@ +# at(index) + +Returns `Wrapper` at `index` passed. Uses zero based numbering (i.e. first item is at index 0). + +- **Arguments:** + - `{number} index` + +- **Returns:** `{Wrapper}` + +- **Example:** + +```js +import { shallow } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +const wrapper = shallow(Foo) +const divArray = wrapper.findAll('div') +const secondDiv = divArray.at(1) +expect(secondDiv.is('p')).toBe(true) +``` diff --git a/docs/pt-br/api/wrapper-array/contains.md b/docs/pt-br/api/wrapper-array/contains.md new file mode 100644 index 000000000..3b5ee31de --- /dev/null +++ b/docs/pt-br/api/wrapper-array/contains.md @@ -0,0 +1,24 @@ +# contains(selector) + +Assert every wrapper in `WrapperArray` contains selector. + +Use any valid [selector](../selectors.md). + +- **Arguments:** + - `{string|Component} selector` + +- **Returns:** `{boolean}` + +- **Example:** + +```js +import { shallow } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' +import Bar from './Bar.vue' + +const wrapper = shallow(Foo) +const divArray = wrapper.findAll('div') +expect(divArray.contains('p')).toBe(true) +expect(divArray.contains(Bar)).toBe(true) +``` diff --git a/docs/pt-br/api/wrapper-array/destroy.md b/docs/pt-br/api/wrapper-array/destroy.md new file mode 100644 index 000000000..875936ecb --- /dev/null +++ b/docs/pt-br/api/wrapper-array/destroy.md @@ -0,0 +1,18 @@ +# destroy() + +Destroys each Vue `Wrapper` in `WrapperArray`. + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +const wrapper = mount(Foo) +const divArray = wrapper.findAll('div') +expect(divArray.contains('p')).toBe(true) +divArray.destroy() +expect(divArray.contains('p')).toBe(false) + +``` diff --git a/docs/pt-br/api/wrapper-array/hasAttribute.md b/docs/pt-br/api/wrapper-array/hasAttribute.md new file mode 100644 index 000000000..b3436edc9 --- /dev/null +++ b/docs/pt-br/api/wrapper-array/hasAttribute.md @@ -0,0 +1,21 @@ +# hasAttribute(attribute, value) + +Assert every `Wrapper` in `WrapperArray` DOM node has `attribute` matching `value`. + +- **Arguments:** + - `{string} attribute` + - `{string} value` + +- **Returns:** `{boolean}` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +const wrapper = mount(Foo) +const divArray = wrapper.findAll('div') +expect(divArray.hasAttribute('id', 'foo')).toBe(true) +``` diff --git a/docs/pt-br/api/wrapper-array/hasClass.md b/docs/pt-br/api/wrapper-array/hasClass.md new file mode 100644 index 000000000..b4c48b397 --- /dev/null +++ b/docs/pt-br/api/wrapper-array/hasClass.md @@ -0,0 +1,20 @@ +# hasClass(className) + +Assert every `Wrapper` in `WrapperArray` DOM node has class containing `className`. + +- **Arguments:** + - `{string} className` + +- **Returns:** `{boolean}` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +const wrapper = mount(Foo) +const divArray = wrapper.findAll('div') +expect(divArray.hasClass('bar')).toBe(true) +``` diff --git a/docs/pt-br/api/wrapper-array/hasProp.md b/docs/pt-br/api/wrapper-array/hasProp.md new file mode 100644 index 000000000..6ce255fd7 --- /dev/null +++ b/docs/pt-br/api/wrapper-array/hasProp.md @@ -0,0 +1,24 @@ +# hasProp(prop, value) + +Assert every `Wrapper` in `WrapperArray` `vm` has `prop` matching `value`. + +**Note the Wrapper must contain a Vue instance.** + +- **Arguments:** + - `{string} prop` + - `{any} value` + +- **Returns:** `{boolean}` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' +import Bar from './Bar.vue' + +const wrapper = mount(Foo) +const barArray = wrapper.findAll(Bar) +expect(barArray.hasProp('bar', 10)).toBe(true) +``` diff --git a/docs/pt-br/api/wrapper-array/hasStyle.md b/docs/pt-br/api/wrapper-array/hasStyle.md new file mode 100644 index 000000000..56a8843fa --- /dev/null +++ b/docs/pt-br/api/wrapper-array/hasStyle.md @@ -0,0 +1,24 @@ +# hasStyle(style, value) + +Assert every `Wrapper` in `WrapperArray` DOM node has style matching value. + +Returns `true` if `Wrapper` DOM node has `style` matching `value`. + +**Note will only detect inline styles when running in `jsdom`.** +- **Arguments:** + - `{string} style` + - `{string} value` + +- **Returns:** `{boolean}` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +const wrapper = mount(Foo) +const divArray = wrapper.findAll('div') +expect(divArray.hasStyle('color', 'red')).toBe(true) +``` diff --git a/docs/pt-br/api/wrapper-array/is.md b/docs/pt-br/api/wrapper-array/is.md new file mode 100644 index 000000000..8a5a7cb7a --- /dev/null +++ b/docs/pt-br/api/wrapper-array/is.md @@ -0,0 +1,20 @@ +# is(selector) + +Assert every `Wrapper` in `WrapperArray` DOM node or `vm` matches [selector](../selectors.md). + +- **Arguments:** + - `{string|Component} selector` + +- **Returns:** `{boolean}` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +const wrapper = mount(Foo) +const divArray = wrapper.find('div') +expect(divArray.is('div')).toBe(true) +``` diff --git a/docs/pt-br/api/wrapper-array/isEmpty.md b/docs/pt-br/api/wrapper-array/isEmpty.md new file mode 100644 index 000000000..6ef8b4145 --- /dev/null +++ b/docs/pt-br/api/wrapper-array/isEmpty.md @@ -0,0 +1,17 @@ +# isEmpty() + +Assert every `Wrapper` in `WrapperArray` does not contain child node. + +- **Returns:** `{boolean}` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +const wrapper = mount(Foo) +const divArray = wrapper.findAll('div') +expect(divArray.isEmpty()).toBe(true) +``` diff --git a/docs/pt-br/api/wrapper-array/isVueInstance.md b/docs/pt-br/api/wrapper-array/isVueInstance.md new file mode 100644 index 000000000..66d556b7f --- /dev/null +++ b/docs/pt-br/api/wrapper-array/isVueInstance.md @@ -0,0 +1,18 @@ +# isVueInstance() + +Assert every `Wrapper` in `WrapperArray` is Vue instance. + +- **Returns:** `{boolean}` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' +import Bar from './Bar.vue' + +const wrapper = mount(Foo) +const barArray = wrapper.findAll(Bar) +expect(barArray.isVueInstance()).toBe(true) +``` diff --git a/docs/pt-br/api/wrapper-array/setComputed.md b/docs/pt-br/api/wrapper-array/setComputed.md new file mode 100644 index 000000000..7531132cf --- /dev/null +++ b/docs/pt-br/api/wrapper-array/setComputed.md @@ -0,0 +1,26 @@ + +# setComputed(computedObjects) + +Sets `Wrapper` `vm` computed and forces update on each `Wrapper` in `WrapperArray`. + +**Note every `Wrapper` must contain a Vue instance.** +**Note every Vue instance must already have the computed properties passed to setComputed.** + +- **Arguments:** + - `{Object} computed properties` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import Foo from './Foo.vue' +import Bar from './Bar.vue' + +const wrapper = mount(Foo) +const barArray = wrapper.findAll(Bar) + +barArray.setComputed({ + computed1: 'new-computed1', + computed2: 'new-computed2' +}) +``` diff --git a/docs/pt-br/api/wrapper-array/setData.md b/docs/pt-br/api/wrapper-array/setData.md new file mode 100644 index 000000000..f4f69bf61 --- /dev/null +++ b/docs/pt-br/api/wrapper-array/setData.md @@ -0,0 +1,22 @@ +# setData(data) + +Sets `Wrapper` `vm` data and forces update on each `Wrapper` in `WrapperArray`. + +**Note every `Wrapper` must contain a Vue instance.** + +- **Arguments:** + - `{Object} data` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' +import Bar from './Bar.vue' + +const wrapper = mount(Foo) +const barArray = wrapper.findAll(Bar) +barArray.setData({ foo: 'bar' }) +expect(barArray.at(0).vm.foo).toBe('bar') +``` diff --git a/docs/pt-br/api/wrapper-array/setMethods.md b/docs/pt-br/api/wrapper-array/setMethods.md new file mode 100644 index 000000000..5d50927ae --- /dev/null +++ b/docs/pt-br/api/wrapper-array/setMethods.md @@ -0,0 +1,27 @@ + +# setMethods(methods) + +Sets `Wrapper` `vm` methods and forces update on each `Wrapper` in `WrapperArray`. + +**Note every `Wrapper` must contain a Vue instance.** + +- **Arguments:** + - `{Object} methods` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import sinon from 'sinon' +import Foo from './Foo.vue' +import Bar from './Bar.vue' + +const wrapper = mount(Foo) +const barArray = wrapper.findAll(Bar) +const clickMethodStub = sinon.stub() + +barArray.setMethods({ clickMethod: clickMethodStub }) +barArray.at(0).trigger('click') +expect(clickMethodStub.called).toBe(true) +``` diff --git a/docs/pt-br/api/wrapper-array/setProps.md b/docs/pt-br/api/wrapper-array/setProps.md new file mode 100644 index 000000000..c68e84f1d --- /dev/null +++ b/docs/pt-br/api/wrapper-array/setProps.md @@ -0,0 +1,22 @@ +# setProps(props) + +Sets `Wrapper` `vm` props and forces update on each `Wrapper` in `WrapperArray`. + +**Note every `Wrapper` must contain a Vue instance.** + +- **Arguments:** + - `{Object} props` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' +import Bar from './Bar.vue' + +const wrapper = mount(Foo) +const barArray = wrapper.findAll(Bar) +barArray.setProps({ foo: 'bar' }) +expect(barArray.at(0).vm.foo).toBe('bar') +``` diff --git a/docs/pt-br/api/wrapper-array/trigger.md b/docs/pt-br/api/wrapper-array/trigger.md new file mode 100644 index 000000000..5ffdb7423 --- /dev/null +++ b/docs/pt-br/api/wrapper-array/trigger.md @@ -0,0 +1,26 @@ +# trigger(eventName) + +Triggers an event on every `Wrapper` in the `WrapperArray` DOM node. + +**Note every `Wrapper` must contain a Vue instance.** + +- **Arguments:** + - `{string} eventName` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import sinon from 'sinon' +import Foo from './Foo.vue' + +const clickHandler = sinon.stub() +const wrapper = mount(Foo, { + propsData: { clickHandler } +}) + +const divArray = wrapper.findAll('div') +divArray.trigger('click') +expect(clickHandler.called).toBe(true) +``` diff --git a/docs/pt-br/api/wrapper-array/update.md b/docs/pt-br/api/wrapper-array/update.md new file mode 100644 index 000000000..de0647028 --- /dev/null +++ b/docs/pt-br/api/wrapper-array/update.md @@ -0,0 +1,20 @@ +# update() + +Force root Vue component of each `Wrapper` in `WrapperArray` to re-render. + +If called on a Vue component wrapper array, it will force each Vue component to re-render. + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +const wrapper = mount(Foo) +const divArray = wrapper.findAll('div') +expect(divArray.at(0).vm.bar).toBe('bar') +divArray.at(0).vm.bar = 'new value' +divArray.update() +expect(divArray.at(0).vm.bar).toBe('new value') +``` diff --git a/docs/pt-br/api/wrapper/README.md b/docs/pt-br/api/wrapper/README.md new file mode 100644 index 000000000..6469b8745 --- /dev/null +++ b/docs/pt-br/api/wrapper/README.md @@ -0,0 +1,16 @@ +# Wrapper + +vue-test-utils is a wrapper based API. + +A `Wrapper` is an object that contains a mounted component or vnode and methods to test the component or vnode. + +- **Properties:** + +`vm` `Component`: this is the vue instance. You can access all the [instance methods and properties of a vm](https://vuejs.org/v2/api/#Instance-Properties) with `wrapper.vm`. This only exists on Vue component wrappers +`element` `HTMLElement`: the root DOM node of the wrapper +`options` `Object`: Object containing vue-test-utils options passed to `mount` or `shallow` +`options.attachedToDom` `Boolean`: True if attachToDom was passed to `mount` or `shallow` + +- **Methods:** + +There is a detailed list of methods in the wrapper section of the docs. diff --git a/docs/pt-br/api/wrapper/contains.md b/docs/pt-br/api/wrapper/contains.md new file mode 100644 index 000000000..a91b0353b --- /dev/null +++ b/docs/pt-br/api/wrapper/contains.md @@ -0,0 +1,23 @@ +# contains(selector) + +Assert `Wrapper` contains an element or component matching [selector](../selectors.md). + +- **Arguments:** + - `{string|Component} selector` + +- **Returns:** `{boolean}` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' +import Bar from './Bar.vue' + +const wrapper = mount(Foo) +expect(wrapper.contains('p')).toBe(true) +expect(wrapper.contains(Bar)).toBe(true) +``` + +- **See also:** [selectors](../selectors.md) diff --git a/docs/pt-br/api/wrapper/destroy.md b/docs/pt-br/api/wrapper/destroy.md new file mode 100644 index 000000000..015d5a5ea --- /dev/null +++ b/docs/pt-br/api/wrapper/destroy.md @@ -0,0 +1,20 @@ +# destroy() + +Destroys a Vue component instance. + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import sinon from 'sinon' + +const spy = sinon.stub() +mount({ + render: null, + destroyed () { + spy() + } +}).destroy() +expect(spy.calledOnce).to.equal(true) +``` diff --git a/docs/pt-br/api/wrapper/emitted.md b/docs/pt-br/api/wrapper/emitted.md new file mode 100644 index 000000000..d754eab98 --- /dev/null +++ b/docs/pt-br/api/wrapper/emitted.md @@ -0,0 +1,33 @@ +# emitted() + +Return an object containing custom events emitted by the `Wrapper` `vm`. + +- **Returns:** `{ [name: string]: Array> }` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' + +const wrapper = mount(Component) + +wrapper.vm.$emit('foo') +wrapper.vm.$emit('foo', 123) + +/* +wrapper.emitted() returns the following object: +{ + foo: [[], [123]] +} +*/ + +// assert event has been emitted +expect(wrapper.emitted().foo).toBeTruthy() + +// assert event count +expect(wrapper.emitted().foo.length).toBe(2) + +// assert event payload +expect(wrapper.emitted().foo[1]).toEqual([123]) +``` diff --git a/docs/pt-br/api/wrapper/emittedByOrder.md b/docs/pt-br/api/wrapper/emittedByOrder.md new file mode 100644 index 000000000..55ff975b2 --- /dev/null +++ b/docs/pt-br/api/wrapper/emittedByOrder.md @@ -0,0 +1,28 @@ +# emittedByOrder() + +Return an Array containing custom events emitted by the `Wrapper` `vm`. + +- **Returns:** `Array<{ name: string, args: Array }>` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' + +const wrapper = mount(Component) + +wrapper.vm.$emit('foo') +wrapper.vm.$emit('bar', 123) + +/* +wrapper.emittedByOrder() returns the following Array: +[ + { name: 'foo', args: [] }, + { name: 'bar', args: [123] } +] +*/ + +// assert event emit order +expect(wrapper.emittedByOrder().map(e => e.name)).toEqual(['foo', 'bar']) +``` diff --git a/docs/pt-br/api/wrapper/exists.md b/docs/pt-br/api/wrapper/exists.md new file mode 100644 index 000000000..4fac1351f --- /dev/null +++ b/docs/pt-br/api/wrapper/exists.md @@ -0,0 +1,21 @@ +# exists() + +Assert `Wrapper` or `WrapperArray` exists. + +Returns false if called on an empty `Wrapper` or `WrapperArray`. + +- **Returns:** `{boolean}` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +const wrapper = mount(Foo) +expect(wrapper.exists()).toBe(true) +expect(wrapper.find('does-not-exist').exists()).toBe(false) +expect(wrapper.findAll('div').exists()).toBe(true) +expect(wrapper.findAll('does-not-exist').exists()).toBe(false) +``` diff --git a/docs/pt-br/api/wrapper/find.md b/docs/pt-br/api/wrapper/find.md new file mode 100644 index 000000000..1d121c591 --- /dev/null +++ b/docs/pt-br/api/wrapper/find.md @@ -0,0 +1,27 @@ +# find(selector) + +Returns [`Wrapper`](README.md) of first DOM node or Vue component matching selector. + +Use any valid [selector](../selectors.md). + +- **Arguments:** + - `{string|Component} selector` + +- **Returns:** `{Wrapper}` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' +import Bar from './Bar.vue' + +const wrapper = mount(Foo) +const div = wrapper.find('div') +expect(div.is('div')).toBe(true) +const bar = wrapper.find(Bar) +expect(bar.is(Bar)).toBe(true) +``` + +- **See also:** [Wrapper](README.md) diff --git a/docs/pt-br/api/wrapper/findAll.md b/docs/pt-br/api/wrapper/findAll.md new file mode 100644 index 000000000..f78ab6201 --- /dev/null +++ b/docs/pt-br/api/wrapper/findAll.md @@ -0,0 +1,27 @@ +# findAll(selector) + +Returns a [`WrapperArray`](../wrapper-array/README.md) of [Wrappers](README.md). + +Use any valid [selector](../selectors.md). + +- **Arguments:** + - `{string|Component} selector` + +- **Returns:** `{WrapperArray}` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' +import Bar from './Bar.vue' + +const wrapper = mount(Foo) +const div = wrapper.findAll('div').at(0) +expect(div.is('div')).toBe(true) +const bar = wrapper.findAll(Bar).at(0) +expect(bar.is(Bar)).toBe(true) +``` + +- **See also:** [Wrapper](README.md) diff --git a/docs/pt-br/api/wrapper/hasAttribute.md b/docs/pt-br/api/wrapper/hasAttribute.md new file mode 100644 index 000000000..da9a893b5 --- /dev/null +++ b/docs/pt-br/api/wrapper/hasAttribute.md @@ -0,0 +1,37 @@ +# hasAttribute(attribute, value) + +Assert `Wrapper` DOM node has attribute matching value. + +Returns `true` if `Wrapper` DOM node contains attribute with matching value. + +- **Arguments:** + - `{string} attribute` + - `{string} value` + +- **Returns:** `{boolean}` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +const wrapper = mount(Foo) +expect(wrapper.hasAttribute('id', 'foo')).toBe(true) +``` + +- **Alternative:** + +You could get the attribute from the `Wrapper.element` to have a value based assertion: + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +const wrapper = mount(Foo) +expect(wrapper.element.getAttribute('id')).toBe('foo') +``` + +This makes for a more informative assertion error. diff --git a/docs/pt-br/api/wrapper/hasClass.md b/docs/pt-br/api/wrapper/hasClass.md new file mode 100644 index 000000000..c70b21ef9 --- /dev/null +++ b/docs/pt-br/api/wrapper/hasClass.md @@ -0,0 +1,21 @@ +# hasClass(className) + +Assert `Wrapper` DOM node has class contains `className`. + +Returns `true` if `Wrapper` DOM node contains class. + +- **Arguments:** + - `{string} className` + +- **Returns:** `{boolean}` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +const wrapper = mount(Foo) +expect(wrapper.hasClass('bar')).toBe(true) +``` diff --git a/docs/pt-br/api/wrapper/hasProp.md b/docs/pt-br/api/wrapper/hasProp.md new file mode 100644 index 000000000..66e64b41b --- /dev/null +++ b/docs/pt-br/api/wrapper/hasProp.md @@ -0,0 +1,25 @@ +# hasProp(prop, value) + +Assert `Wrapper` `vm` has `prop` matching `value`. + +Returns `true` if `Wrapper` `vm` has `prop` matching `value`. + + +**Note: the Wrapper must contain a Vue instance.** + +- **Arguments:** + - `{string} prop` + - `{any} value` + +- **Returns:** `{boolean}` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +const wrapper = mount(Foo) +expect(wrapper.hasProp('bar', 10)).toBe(true) +``` diff --git a/docs/pt-br/api/wrapper/hasStyle.md b/docs/pt-br/api/wrapper/hasStyle.md new file mode 100644 index 000000000..0281d8401 --- /dev/null +++ b/docs/pt-br/api/wrapper/hasStyle.md @@ -0,0 +1,24 @@ +# hasStyle(style, value) + +Assert `Wrapper` DOM node has style matching value + +Returns `true` if `Wrapper` DOM node has `style` matching `value`. + +**Note will only detect inline styles when running in `jsdom`.** + +- **Arguments:** + - `{string} style` + - `{string} value` + +- **Returns:** `{boolean}` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +const wrapper = mount(Foo) +expect(wrapper.hasStyle('color', 'red')).toBe(true) +``` diff --git a/docs/pt-br/api/wrapper/html.md b/docs/pt-br/api/wrapper/html.md new file mode 100644 index 000000000..1243f180f --- /dev/null +++ b/docs/pt-br/api/wrapper/html.md @@ -0,0 +1,16 @@ +# html() + +Returns HTML of `Wrapper` DOM node as a string. + +- **Returns:** `{string}` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +const wrapper = mount(Foo) +expect(wrapper.html()).toBe('

Foo

') +``` diff --git a/docs/pt-br/api/wrapper/is.md b/docs/pt-br/api/wrapper/is.md new file mode 100644 index 000000000..2987de1a2 --- /dev/null +++ b/docs/pt-br/api/wrapper/is.md @@ -0,0 +1,19 @@ +# is(selector) + +Assert `Wrapper` DOM node or `vm` matches [selector](../selectors.md). + +- **Arguments:** + - `{string|Component} selector` + +- **Returns:** `{boolean}` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +const wrapper = mount(Foo) +expect(wrapper.is('div')).toBe(true) +``` diff --git a/docs/pt-br/api/wrapper/isEmpty.md b/docs/pt-br/api/wrapper/isEmpty.md new file mode 100644 index 000000000..d70fe7140 --- /dev/null +++ b/docs/pt-br/api/wrapper/isEmpty.md @@ -0,0 +1,16 @@ +# isEmpty() + +Assert `Wrapper` does not contain child node. + +- **Returns:** `{boolean}` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +const wrapper = mount(Foo) +expect(wrapper.isEmpty()).toBe(true) +``` diff --git a/docs/pt-br/api/wrapper/isVueInstance.md b/docs/pt-br/api/wrapper/isVueInstance.md new file mode 100644 index 000000000..9da12a267 --- /dev/null +++ b/docs/pt-br/api/wrapper/isVueInstance.md @@ -0,0 +1,16 @@ +# isVueInstance() + +Assert `Wrapper` is Vue instance. + +- **Returns:** `{boolean}` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +const wrapper = mount(Foo) +expect(wrapper.isVueInstance()).toBe(true) + ``` diff --git a/docs/pt-br/api/wrapper/name.md b/docs/pt-br/api/wrapper/name.md new file mode 100644 index 000000000..a1faf1b4f --- /dev/null +++ b/docs/pt-br/api/wrapper/name.md @@ -0,0 +1,18 @@ +# name() + +Returns component name if `Wrapper` contains a Vue instance, or the tag name of `Wrapper` DOM node if `Wrapper` does not contain a Vue instance. + +- **Returns:** `{string}` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +const wrapper = mount(Foo) +expect(wrapper.name()).toBe('Foo') +const p = wrapper.find('p') +expect(p.name()).toBe('p') +``` diff --git a/docs/pt-br/api/wrapper/setComputed.md b/docs/pt-br/api/wrapper/setComputed.md new file mode 100644 index 000000000..b5db5549e --- /dev/null +++ b/docs/pt-br/api/wrapper/setComputed.md @@ -0,0 +1,43 @@ +# setComputed(computedProperties) + +Sets `Wrapper` `vm` computed property and forces update. + +**Note the Wrapper must contain a Vue instance.** +**Note every Vue instance must already have the computed properties passed to setComputed.** + + +- **Arguments:** + - `{Object} computed properties` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' + +const wrapper = mount({ + template: '
{{ computed1 }} {{ computed2 }}
', + data () { + return { + initial: 'initial' + } + }, + computed: { + computed1 () { + return this.initial + }, + computed2 () { + return this.initial + } + } +}) + +expect(wrapper.html()).toBe('
initial initial
') + +wrapper.setComputed({ + computed1: 'new-computed1', + computed2: 'new-computed2' +}) + +expect(wrapper.html()).toBe('
new-computed1 new-computed2
') +``` diff --git a/docs/pt-br/api/wrapper/setData.md b/docs/pt-br/api/wrapper/setData.md new file mode 100644 index 000000000..608f083f4 --- /dev/null +++ b/docs/pt-br/api/wrapper/setData.md @@ -0,0 +1,20 @@ +# setData(data) + +Sets `Wrapper` `vm` data and forces update. + +**Note the Wrapper must contain a Vue instance.** + +- **Arguments:** + - `{Object} data` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +const wrapper = mount(Foo) +wrapper.setData({ foo: 'bar' }) +expect(wrapper.vm.foo).toBe('bar') +``` diff --git a/docs/pt-br/api/wrapper/setMethods.md b/docs/pt-br/api/wrapper/setMethods.md new file mode 100644 index 000000000..4a40546ee --- /dev/null +++ b/docs/pt-br/api/wrapper/setMethods.md @@ -0,0 +1,24 @@ +# setMethods(methods) + +Sets `Wrapper` `vm` methods and forces update. + +**Note the Wrapper must contain a Vue instance.** + +- **Arguments:** + - `{Object} methods` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import sinon from 'sinon' +import Foo from './Foo.vue' + +const wrapper = mount(Foo) +const clickMethodStub = sinon.stub() + +wrapper.setMethods({ clickMethod: clickMethodStub }) +wrapper.find('button').trigger('click') +expect(clickMethodStub.called).toBe(true) +``` diff --git a/docs/pt-br/api/wrapper/setProps.md b/docs/pt-br/api/wrapper/setProps.md new file mode 100644 index 000000000..7a55124c4 --- /dev/null +++ b/docs/pt-br/api/wrapper/setProps.md @@ -0,0 +1,48 @@ +# setProps(props) + +- **Arguments:** + - `{Object} props` + +- **Usage:** + +Sets `Wrapper` `vm` props and forces update. + +**Note the Wrapper must contain a Vue instance.** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +const wrapper = mount(Foo) +wrapper.setProps({ foo: 'bar' }) +expect(wrapper.vm.foo).to.equal('bar') +``` + +You can also pass a `propsData` object, which will initialize the Vue instance with passed values. + +``` js +// Foo.vue +export default { + props: { + foo: { + type: String, + required: true + } + } +} +``` + +``` js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +const wrapper = mount(Foo, { + propsData: { + foo: 'bar' + } +}) + +expect(wrapper.vm.foo).to.equal('bar') +``` diff --git a/docs/pt-br/api/wrapper/text.md b/docs/pt-br/api/wrapper/text.md new file mode 100644 index 000000000..d1ccd4b44 --- /dev/null +++ b/docs/pt-br/api/wrapper/text.md @@ -0,0 +1,16 @@ +# text() + +Returns text content of `Wrapper`. + +- **Returns:** `{string}` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +const wrapper = mount(Foo) +expect(wrapper.text()).toBe('bar') +``` diff --git a/docs/pt-br/api/wrapper/trigger.md b/docs/pt-br/api/wrapper/trigger.md new file mode 100644 index 000000000..537cda9e6 --- /dev/null +++ b/docs/pt-br/api/wrapper/trigger.md @@ -0,0 +1,38 @@ +# trigger(eventName) + +Triggers an event on the `Wrapper` DOM node. + +Trigger takes an optional `options` object. The properties in the `options` object are added to the Event. + +You can run preventDefault on the event by passing `preventDefault: true` in `options`. + +- **Arguments:** + - `{string} eventName` + - `{Object} options` + - `{boolean} preventDefault` + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import sinon from 'sinon' +import Foo from './Foo' + +const clickHandler = sinon.stub() +const wrapper = mount(Foo, { + propsData: { clickHandler } +}) + +wrapper.trigger('click') + +wrapper.trigger('click', { + button: 0 +}) + +wrapper.trigger('click', { + preventDefault: true +}) + +expect(clickHandler.called).toBe(true) +``` diff --git a/docs/pt-br/api/wrapper/update.md b/docs/pt-br/api/wrapper/update.md new file mode 100644 index 000000000..15d13be89 --- /dev/null +++ b/docs/pt-br/api/wrapper/update.md @@ -0,0 +1,19 @@ +# update() + +Force root Vue component to re-render. + +If called on a `Wrapper` containing a `vm`, it will force the `Wrapper` `vm` to re-render. + +- **Example:** + +```js +import { mount } from 'vue-test-utils' +import { expect } from 'chai' +import Foo from './Foo.vue' + +const wrapper = mount(Foo) +expect(wrapper.vm.bar).toBe('bar') +wrapper.vm.bar = 'new value' +wrapper.update() +expect(wrapper.vm.bar).toBe('new value') +``` diff --git a/docs/pt-br/guides/README.md b/docs/pt-br/guides/README.md new file mode 100644 index 000000000..0983fe375 --- /dev/null +++ b/docs/pt-br/guides/README.md @@ -0,0 +1,10 @@ +# Guia + +* [Iniciando](./getting-started.md) +* [Dicas comuns](./common-tips.md) +* [Escolhendo um executador de testes](./choosing-a-test-runner.md) +* [Usando com o Jest](./using-with-jest.md) +* [Testando SFCs com Jest](./testing-SFCs-with-jest.md) +* [Testando SFCs com Mocha + webpack](./testing-SFCs-with-mocha-webpack.md) +* [Usando com o Vue Router](./using-with-vue-router.md) +* [Usando com o Vuex](./using-with-vuex.md) diff --git a/docs/pt-br/guides/choosing-a-test-runner.md b/docs/pt-br/guides/choosing-a-test-runner.md new file mode 100644 index 000000000..8d69377b1 --- /dev/null +++ b/docs/pt-br/guides/choosing-a-test-runner.md @@ -0,0 +1,45 @@ +# Choosing a test runner + +A test runner is a program that runs tests. + +There are many popular JavaScript test runners, and `vue-test-utils` works with all of them. It's test runner agnostic. + +There are a few things to consider when choosing a test runner though: feature set, performance, and support for single-file component (SFC) pre-compilation. After carefully comparing existing libraries, here are two test runners that we recommend: + +- [Jest](https://facebook.github.io/jest/docs/en/getting-started.html#content) is the most fully featured test runner. It requires the least configuration, sets up JSDOM by default, provides built-in assertions, and has a great command line user experience. However, you will need a preprocessor to be able to import SFC components in your tests. We have created the `vue-jest` preprocessor which can handle most common SFC features, but it currently does not have 100% feature parity with `vue-loader`. + +- [mocha-webpack](https://github.com/zinserjan/mocha-webpack) is a wrapper around webpack + Mocha, but with a more streamlined interface and watch mode. The benefits of this setup is that we can get complete SFC support via webpack + `vue-loader`, but it requires more configuration upfront. + +## Browser Environment + +`vue-test-utils` relies on a browser environment. Technically you can run it in a real browser, but it's not recommended due to the complexity of launching real browsers on different platforms. Instead, we recommend running the tests in Node.js with a virtual browser environment using [JSDOM](https://github.com/tmpvar/jsdom). + +The Jest test runner sets up JSDOM automatically. For other test runners, you can manually set up JSDOM for the tests using [jsdom-global](https://github.com/rstacruz/jsdom-global) in the entry for your tests: + +``` bash +npm install --save-dev jsdom jsdom-global +``` +--- +``` js +// in test setup / entry +require('jsdom-global')() +``` + +## Testing Single-File Components + +Single-file Vue components (SFCs) require pre-compilation before they can be run in Node or in the browser. There are two recommended ways to perform the compilation: with a Jest preprocessor, or directly use webpack. + +The `vue-jest` preprocessor supports basic SFC functionalities, but currently does not handle style blocks or custom blocks, which are only supported in `vue-loader`. If you rely on these features or other webpack-specific configurations, you will need to use a webpack + `vue-loader` based setup. + +Read the following guides for different setups: + +- [Testing SFCs with Jest](./testing-SFCs-with-jest.md) +- [Testing SFCs with Mocha + webpack](./testing-SFCs-with-mocha-webpack.md) + +## Resources + +- [Test runner performance comparison](https://github.com/eddyerburgh/vue-unit-test-perf-comparison) +- [Example project with Jest](https://github.com/vuejs/vue-test-utils-jest-example) +- [Example project with Mocha](https://github.com/vuejs/vue-test-utils-mocha-webpack-example) +- [Example project with tape](https://github.com/eddyerburgh/vue-test-utils-tape-example) +- [Example project with AVA](https://github.com/eddyerburgh/vue-test-utils-ava-example) diff --git a/docs/pt-br/guides/common-tips.md b/docs/pt-br/guides/common-tips.md new file mode 100644 index 000000000..abd7500a7 --- /dev/null +++ b/docs/pt-br/guides/common-tips.md @@ -0,0 +1,135 @@ +# Common Tips + +## Knowing What to Test + +For UI components, we don't recommend aiming for complete line-based coverage, because it leads to too much focus on the internal implementation details of the components and could result in brittle tests. + +Instead, we recommend writing tests that assert your component's public interface, and treat its internals as a black box. A single test case would assert that some input (user interaction or change of props) provided to the component results in the expected output (render result or emitted custom events). + +For example, for the `Counter` component which increments a display counter by 1 each time a button is clicked, its test case would simulate the click and assert that the rendered output has increased by 1. The test doesn't care about how the Counter increments the value, it only cares about the input and the output. + +The benefit of this approach is that as long as your component's public interface remains the same, your tests will pass no matter how the component's internal implementation changes over time. + +This topic is discussed with more details in a [great presentation by Matt O'Connell](http://slides.com/mattoconnell/deck#/). + +## Shallow Rendering + +In unit tests, we typically want to focus on the component being tested as an isolated unit and avoid indirectly asserting the behavior of its child components. + +In addition, for components that contain many child components, the entire rendered tree can get really big. Repeatedly rendering all child components could slow down our tests. + +`vue-test-utils` allows you to mount a component without rendering its child components (by stubbing them) with the `shallow` method: + +```js +import { shallow } from 'vue-test-utils' + +const wrapper = shallow(Component) // returns a Wrapper containing a mounted Component instance +wrapper.vm // the mounted Vue instance +``` + +## Asserting Emitted Events + +Each mounted wrapper automatically records all events emitted by the underlying Vue instance. You can retrieve the recorded events using the `wrapper.emitted()` method: + +``` js +wrapper.vm.$emit('foo') +wrapper.vm.$emit('foo', 123) + +/* +wrapper.emitted() returns the following object: +{ + foo: [[], [123]] +} +*/ +``` + +You can then make assertions based on these data: + +``` js +import { expect } from 'chai' + +// assert event has been emitted +expect(wrapper.emitted().foo).toBeTruthy() + +// assert event count +expect(wrapper.emitted().foo.length).toBe(2) + +// assert event payload +expect(wrapper.emitted().foo[1]).toEqual([123]) +``` + +You can also get an Array of the events in their emit order by calling [wrapper.emittedByOrder()](../api/wrapper/emittedByOrder.md). + +## Manipulating Component State + +You can directly manipulate the state of the component using the `setData` or `setProps` method on the wrapper: + +```js +wrapper.setData({ count: 10 }) + +wrapper.setProps({ foo: 'bar' }) +``` + +## Mocking Props + +You can pass props to the component using Vue's built-in `propsData` option: + +```js +import { mount } from 'vue-test-utils' + +mount(Component, { + propsData: { + aProp: 'some value' + } +}) +``` + +You can also update the props of an already-mounted component with the `wrapper.setProps({})` method. + +*For a full list of options, please see the [mount options section](../api/options.md) of the docs.* + +## Applying Global Plugins and Mixins + +Some of the components may rely on features injected by a global plugin or mixin, for example `vuex` and `vue-router`. + +If you are writing tests for components in a specific app, you can setup the same global plugins and mixins once in the entry of your tests. But in some cases, for example testing a generic component suite that may get shared across different apps, it's better to test your components in a more isolated setup, without polluting the global `Vue` constructor. We can use the [createLocalVue](../api/createLocalVue.md) method to achieve that: + +``` js +import createLocalVue from 'vue-test-utils' + +// create an extended Vue constructor +const localVue = createLocalVue() + +// install plugins as normal +localVue.use(MyPlugin) + +// pass the localVue to the mount options +mount(Component, { + localVue +}) +``` + +## Mocking Injections + +Another strategy for injected properties is simply mocking them. You can do that with the `mocks` option: + +```js +import { mount } from 'vue-test-utils' + +const $route = { + path: '/', + hash: '', + params: { id: '123' }, + query: { q: 'hello' } +} + +mount(Component, { + mocks: { + $route // adds the mocked $route object to the Vue instance before mounting component + } +}) +``` + +## Dealing with Routing + +Since routing by definition has to do with the overall structure of the application and involves multiple components, it is best tested via integration or end-to-end tests. For individual components that rely on `vue-router` features, you can mock them using the techniques mentioned above. diff --git a/docs/pt-br/guides/dom-events.md b/docs/pt-br/guides/dom-events.md new file mode 100644 index 000000000..1ed117610 --- /dev/null +++ b/docs/pt-br/guides/dom-events.md @@ -0,0 +1,196 @@ +# Testing Key, Mouse and other DOM events + +## Trigger events + +The `Wrapper` expose a `trigger` method. It can be used to trigger DOM events. + +```js +const wrapper = mount(MyButton) + +wrapper.trigger('click') +``` + +You should be aware, that find returns a wrapper as well. Assuming `MyComponent` contains a button, the following code clicks the button. + +```js +const wrapper = mount(MyComponent) + +wrapper.find('button').trigger('click') +``` + +## Options + +The trigger method takes an optional `options` object. The properties in the `options` object are added to the Event. + +You can run preventDefault on the event by passing `preventDefault: true` in `options`. + +```js +const wrapper = mount(MyButton) + +wrapper.trigger('click', { preventDefault: true }) +``` + + +## Mouse Click Example + +**Component under test** + +```html + + + +``` + +**Test** + +```js +import YesNoComponent from '@/components/YesNoComponent' +import { mount } from 'vue-test-utils' +import sinon from 'sinon' + +describe('Click event', () => { + it('Click on yes button calls our method with argument "yes"', () => { + const spy = sinon.spy() + const wrapper = mount(YesNoComponent, { + propsData: { + callMe: spy + } + }) + wrapper.find('button.yes').trigger('click') + + spy.should.have.been.calledWith('yes') + }) +}) +``` + +## Keyboard Example + +**Component under test** + +This component allows to increment/decrement the quantity using various keys. + +```html + + + +``` + +**Test** + +```js +import QuantityComponent from '@/components/QuantityComponent' +import { mount } from 'vue-test-utils' + +describe('Key event tests', () => { + it('Quantity is zero by default', () => { + const wrapper = mount(QuantityComponent) + expect(wrapper.vm.quantity).to.equal(0) + }) + + it('Cursor up sets quantity to 1', () => { + const wrapper = mount(QuantityComponent) + wrapper.trigger('keydown.up') + expect(wrapper.vm.quantity).to.equal(1) + }) + + it('Cursor down reduce quantity by 1', () => { + const wrapper = mount(QuantityComponent) + wrapper.vm.quantity = 5 + wrapper.trigger('keydown.down') + expect(wrapper.vm.quantity).to.equal(4) + }) + + it('Escape sets quantity to 0', () => { + const wrapper = mount(QuantityComponent) + wrapper.vm.quantity = 5 + wrapper.trigger('keydown.esc') + expect(wrapper.vm.quantity).to.equal(0) + }) + + it('Magic character "a" sets quantity to 13', () => { + const wrapper = mount(QuantityComponent) + wrapper.trigger('keydown', { + which: 65 + }) + expect(wrapper.vm.quantity).to.equal(13) + }) +}) + +``` + +**Limitations** + +A key name after the dot `keydown.up` is translated to a `keyCode`. This is supported for the following names: + +* enter, tab, delete, esc, space, up, down, left, right + +## Important + +vue-test-utils triggers event synchronously. Consequently, `vue.nextTick` is not required. diff --git a/docs/pt-br/guides/getting-started.md b/docs/pt-br/guides/getting-started.md new file mode 100644 index 000000000..5c023d6dc --- /dev/null +++ b/docs/pt-br/guides/getting-started.md @@ -0,0 +1,116 @@ +# Getting Started + +## Setup + +To get a quick taste of using `vue-test-utils`, clone our demo repository with basic setup and install the dependencies: + +``` bash +git clone https://github.com/vuejs/vue-test-utils-getting-started +cd vue-test-utils-getting-started +npm install +``` + +You will see that the project includes a simple component, `counter.js`: + +```js +// counter.js + +export default { + template: ` +
+ {{ count }} + +
+ `, + + data () { + return { + count: 0 + } + }, + + methods: { + increment () { + this.count++ + } + } +} +``` + +### Mounting Components + +`vue-test-utils` tests Vue components by mounting them in isolation, mocking the necessary inputs (props, injections and user events) and asserting the outputs (render result, emitted custom events). + +Mounted components are returned inside a [Wrapper](./api/wrapper.md), which exposes many convenience methods for manipulating, traversing and querying the underlying Vue component instance. + +You can create wrappers using the `mount` method. Let's create a file called `test.js`: + +```js +// test.js + +// Import the mount() method from the test utils +// and the component you want to test +import { mount } from 'vue-test-utils' +import Counter from './counter' + +// Now mount the component and you have the wrapper +const wrapper = mount(Counter) + +// You can access the actual Vue instance via wrapper.vm +const vm = wrapper.vm + +// To inspect the wrapper deeper just log it to the console +// and your adventure with the vue-test-utils begins +console.log(wrapper) +``` + +### Test rendered HTML output of the component + +Now that we have the wrapper, the first thing we can do is to verify that the rendered HTML output of the component matches what is expected. + +```js +import { mount } from 'vue-test-utils' +import Counter from './counter' + +describe('Counter', () => { + // Now mount the component and you have the wrapper + const wrapper = mount(Counter) + + it('renders the correct markup', () => { + expect(wrapper.html()).toContain('0') + }) + + // it's also easy to check for the existence of elements + it('has a button', () => { + expect(wrapper.contains('button')).toBe(true) + }) +}) +``` + +Now run the tests with `npm test`. You should see the tests passing. + +### Simulating User Interaction + +Our counter should increment the count when the user clicks the button. To simulate the behavior, we need to first locate the button with `wrapper.find()`, which returns a **wrapper for the button element**. We can then simulate the click by calling `.trigger()` on the button wrapper: + +```js +it('button click should increment the count', () => { + expect(wrapper.vm.count).toBe(0) + const button = wrapper.find('button') + button.trigger('click') + expect(wrapper.vm.count).toBe(1) +}) +``` + +### What about `nextTick`? + +Vue batches pending DOM updates and applies them asynchronously to prevent unnecessary re-renders caused by multiple data mutations. This is why in practice we often have to use `Vue.nextTick` to wait until Vue has performed the actual DOM update after we trigger some state change. + +To simplify usage, `vue-test-utils` applies all updates synchronously so you don't need to use `Vue.nextTick` to wait for DOM updates in your tests. + +*Note: `nextTick` is still necessary when you need to explictly advance the event loop, for operations such as asynchronous callbacks or promise resolution.* + +## What's Next + +- Integrate `vue-test-utils` into your project by [choosing a test runner](./choosing-a-test-runner.md) +- Learn more about [common techniques when writing tests](./common-tips.md) diff --git a/docs/pt-br/guides/testing-SFCs-with-jest.md b/docs/pt-br/guides/testing-SFCs-with-jest.md new file mode 100644 index 000000000..8ca1e8f60 --- /dev/null +++ b/docs/pt-br/guides/testing-SFCs-with-jest.md @@ -0,0 +1,178 @@ +# Testing Single File Components with Jest + +> An example project for this setup is available on [GitHub](https://github.com/vuejs/vue-test-utils-jest-example). + +Jest is a test runner developed by Facebook, aiming to deliver a battery-included unit testing solution. You can learn more about Jest on its [official documentation](https://facebook.github.io/jest/). + +## Setting up Jest + +We will assume you are starting with a setup that already has webpack, vue-loader and Babel properly configured - e.g. the `webpack-simple` template scaffolded by `vue-cli`. + +The first thing to do is install Jest and `vue-test-utils`: + +```bash +$ npm install --save-dev jest vue-test-utils +``` + +Next we need to define a unit script in our `package.json`. + +```json +// package.json +{ + "scripts": { + "test": "jest" + } +} +``` + +## Processing SFCs in Jest + +To teach Jest how to process `*.vue` files, we will need to install and configure the `vue-jest` preprocessor: + +``` bash +npm install --save-dev vue-jest +``` + +Next, create a `jest` block in `package.json`: + +``` json +{ + // ... + "jest": { + "moduleFileExtensions": [ + "js", + "json", + // tell Jest to handle *.vue files + "vue" + ], + "transform": { + // process *.vue files with vue-jest + ".*\\.(vue)$": "/node_modules/vue-jest" + }, + "mapCoverage": true + } +} +``` + +> **Note:** `vue-jest` currently does not support all the features of `vue-loader`, for example custom block support and style loading. In addition, some webpack-specific features such as code-splitting are not supported either. To use them, read the guide on [testing SFCs with Mocha + webpack](./testing-SFCs-with-mocha-webpack.md). + +## Handling webpack Aliases + +If you use a resolve alias in the webpack config, e.g. aliasing `@` to `/src`, you need to add a matching config for Jest as well, using the `moduleNameMapper` option: + +``` json +{ + // ... + "jest": { + // ... + // support the same @ -> src alias mapping in source code + "moduleNameMapper": { + "^@/(.*)$": "/src/$1" + } + } +} +``` + +## Configuring Babel for Jest + +Although latest versions of Node already supports most ES2015 features, you may still want to use ES modules syntax and stage-x features in your tests. For that we need to install `babel-jest`: + +``` bash +npm install --save-dev babel-jest +``` + +Next, we need to tell Jest to process JavaScript test files with `babel-jest` by adding an entry under `jest.transform` in `package.json`: + +``` json +{ + // ... + "jest": { + // ... + "transform": { + // ... + // process js with babel-jest + "^.+\\.js$": "/node_modules/babel-jest" + }, + // ... + } +} +``` + +> By default, `babel-jest` automatically configures itself as long as it's installed. However, because we have explicitly added a transform for `*.vue` files, we now need to explicitly configure `babel-jest` as well. + +Assuming using `babel-preset-env` with webpack, the default Babel config disables ES modules transpilation because webpack already knows how to handle ES modules. However, we do need to enable it for our tests because Jest tests run directly in Node. + +Also, we can tell `babel-preset-env` to target the Node version we are using. This skips transpiling unnecessary features and makes our tests boot faster. + +To apply these options only for tests, put them in a separate config under `env.test` (this will be automatically picked up by `babel-jest`). + +Example `.babelrc`: + +``` json +{ + "presets": [ + ["env", { "modules": false }] + ], + "env": { + "test": { + "presets": [ + ["env", { "targets": { "node": "current" }}] + ] + } + } +} +``` + +### Snapshot Testing + +You can use [`vue-server-renderer`](https://github.com/vuejs/vue/tree/dev/packages/vue-server-renderer) to render a component into a string so that it can be saved as a snapshot for [Jest snapshot testing](https://facebook.github.io/jest/docs/en/snapshot-testing.html). + +The render result of `vue-server-renderer` includes a few SSR-specific attributes, and it ignores whitespaces, making it harder to scan a diff. We can improve the saved snapshot with a custom serializer: + +``` bash +npm install --save-dev jest-serializer-vue +``` + +Then configure it in `package.json`: + +``` json +{ + // ... + "jest": { + // ... + // serializer for snapshots + "snapshotSerializers": [ + "/node_modules/jest-serializer-vue" + ] + } +} +``` + +### Placing Test Files + +By default, jest will recursively pick up all files that have a `.spec.js` or `.test.js` extension in the entire project. If this does not fit your needs, it's possible [to change the testRegex](https://facebook.github.io/jest/docs/en/configuration.html#testregex-string) in the config section in the `package.json` file. + +Jest recommends creating a `__tests__` directory right next to the code being tested, but feel free to structure your tests as you see fit. Just beware that Jest would create a `__snapshots__` directory next to test files that performs snapshot testing. + +### Example Spec + +If you are familiar with Jasmine, you should feel right at home with Jest's [assertion API](https://facebook.github.io/jest/docs/en/expect.html#content): + +```js +import { mount } from 'vue-test-utils' +import Component from './component' + +describe('Component', () => { + test('is a Vue instance', () => { + const wrapper = mount(Component) + expect(wrapper.isVueInstance()).toBeTruthy() + }) +}) +``` + +### Resources + +- [Example project for this setup](https://github.com/vuejs/vue-test-utils-jest-example) +- [Examples and slides from Vue Conf 2017](https://github.com/codebryo/vue-testing-with-jest-conf17) +- [Jest](https://facebook.github.io/jest/) +- [Babel preset env](https://github.com/babel/babel-preset-env) diff --git a/docs/pt-br/guides/testing-SFCs-with-mocha-webpack.md b/docs/pt-br/guides/testing-SFCs-with-mocha-webpack.md new file mode 100644 index 000000000..f7013a015 --- /dev/null +++ b/docs/pt-br/guides/testing-SFCs-with-mocha-webpack.md @@ -0,0 +1,180 @@ +# Testing Single File Components with Mocha + webpack + +> An example project for this setup is available on [GitHub](https://github.com/vuejs/vue-test-utils-mocha-webpack-example). + +Another strategy for testing SFCs is compiling all our tests via webpack and then run it in a test runner. The advantage of this approach is that it gives us full support for all webpack and `vue-loader` features, so we don't have to make compromises in our source code. + +You can technically use any test runner you like and manually wire things together, but we've found [`mocha-webpack`](https://github.com/zinserjan/mocha-webpack) to provide a very streamlined experience for this particular task. + +## Setting Up `mocha-webpack` + +We will assume you are starting with a setup that already has webpack, vue-loader and Babel properly configured - e.g. the `webpack-simple` template scaffolded by `vue-cli`. + +The first thing to do is installing test dependencies: + +``` bash +npm install --save-dev vue-test-utils mocha mocha-webpack +``` + +Next we need to define a test script in our `package.json`. + +```json +// package.json +{ + "scripts": { + "test": "mocha-webpack --webpack-config webpack.config.js --require test/setup.js test/**/*.spec.js" + } +} +``` + +A few things to note here: + +- The `--webpack-config` flag specifies the webpack config file to use for the tests. In most cases, this would be identical to the config you use for the actual project with one small tweak. We will talk about this later. + +- The `--require` flag ensures the file `test/setup.js` is run before any tests, in which we can setup the global environment for our tests to be run in. + +- The final argument is a glob for the test files to be included in the test bundle. + +### Extra webpack Configuration + +#### Externalizing NPM Dependencies + +In our tests we will likely import a number of NPM dependencies - some of these modules may be written without browser usage in mind and simply cannot be bundled properly by webpack. Another consideration is externalizing dependencies greatly improves test boot up speed. We can externalize all NPM dependencies with `webpack-node-externals`: + +```js +// webpack.config.js +const nodeExternals = require('webpack-node-externals') + +module.exports = { + // ... + externals: [nodeExternals()] +} +``` + +#### Source Maps + +Source maps need to be inlined to be picked up by `mocha-webpack`. The recommended config is: + +``` js +module.exports = { + // ... + devtool: 'inline-cheap-module-source-map' +} +``` + +If debugging via IDE, it's also recommended to add the following: + +``` js +module.exports = { + // ... + output: { + // ... + // use absolute paths in sourcemaps (important for debugging via IDE) + devtoolModuleFilenameTemplate: '[absolute-resource-path]', + devtoolFallbackModuleFilenameTemplate: '[absolute-resource-path]?[hash]' + } +} +``` + +### Setting Up Browser Environment + +`vue-test-utils` requires a browser environment to run. We can simulate it in Node.js using `jsdom-global`: + +```bash +npm install --save-dev jsdom jsdom-global +``` + +Then in `test/setup.js`: + +``` js +require('jsdom-global')() +``` + +This adds a browser environment to node, so that `vue-test-utils` can run correctly. + +### Picking an Assertion Library + +[Chai](http://chaijs.com/) is a popular assertion library that is commonly used alongside Mocha. You may also want to check out [Sinon](http://sinonjs.org/) for creating spies and stubs. + +Alternatively you can use `expect` which is now part of Jest, and exposes [the exact same API](http://facebook.github.io/jest/docs/en/expect.html#content) in Jest docs. + +We will be using `expect` here and make it globally available so that we don't have to import it in every test: + +``` bash +npm install --save-dev expect +``` + +Then in `test/setup.js`: + +``` js +require('jsdom-global')() + +global.expect = require('expect') +``` + +### Optimizing Babel for Tests + +Notice that we are using `babel-loader` to handle JavaScript. You should already have Babel configured if you are using it in your app via a `.babelrc` file. Here `babel-loader` will automatically use the same config file. + +One thing to note is that if you are using Node 6+, which already supports the majority of ES2015 features, you can configure a separate Babel [env option](https://babeljs.io/docs/usage/babelrc/#env-option) that only transpiles features that are not already supported in the Node version you are using (e.g. `stage-2` or flow syntax support, etc.) + +### Adding a test + +Create a file in `src` named `Counter.vue`: + +``` html + + + +``` + +And create a test file named `test/Counter.spec.js` with the following code: + +```js +import { shallow } from 'vue-test-utils' +import Counter from '../src/Counter.vue' + +describe('Counter.vue', () => { + it('increments count when button is clicked', () => { + const wrapper = shallow(Counter) + wrapper.find('button').trigger('click') + expect(wrapper.find('div').text()).toMatch('1') + }) +}) +``` + +And now we can run the test: + +``` +npm run unit +``` + +Woohoo, we got our tests running! + +### Resources + +- [Example project for this setup](https://github.com/vuejs/vue-test-utils-mocha-webpack-example) +- [Mocha](https://mochajs.org/) +- [mocha-webpack](http://zinserjan.github.io/mocha-webpack/) +- [Chai](http://chaijs.com/) +- [Sinon](http://sinonjs.org/) +- [jest/expect](http://facebook.github.io/jest/docs/en/expect.html#content) diff --git a/docs/pt-br/guides/using-with-vue-router.md b/docs/pt-br/guides/using-with-vue-router.md new file mode 100644 index 000000000..d69353af0 --- /dev/null +++ b/docs/pt-br/guides/using-with-vue-router.md @@ -0,0 +1,71 @@ +# Using with Vue Router + +## Installing Vue Router in tests + +You should never install Vue Router on the Vue base constructor in tests. Installing Vue Router adds `$route` and `$router` as read-only properties on Vue prototype. + +To avoid this, we can create a localVue, and install Vue Router on that. + +```js +import VueRouter from 'vue-router' +const localVue = createLocalVue() + +localVue.use(VueRouter) + +shallow(Component, { + localVue +}) +``` + +## Testing components that use `router-link` or `router-view` + +When you install Vue Router, the `router-link` and `router-view` components are registered. This means we can use them anywhere in our application without needing to import them. + +When we run tests, we need to make these vue-router components available to the component we're mounting. There are two methods to do this. + +### Using stubs + +```js +shallow(Component, { + stubs: ['router-link', 'router-view'] +}) +``` + +### Installing Vue Router with localVue + +```js +import VueRouter from 'vue-router' +const localVue = createLocalVue() + +localVue.use(VueRouter) + +shallow(Component, { + localVue +}) +``` + +## Mocking `$route` and `$router` + +Sometimes you want to test that a component does something with parameters from the `$route` and `$router` objects. To do that, you can pass custom mocks to the Vue instance. + +```js +const $route = { + path: '/some/path' +} + +const wrapper = shallow(Component, { + mocks: { + $route + } +}) + +wrapper.vm.$router // /some/path +``` + +## Common gotchas + +Installing Vue Router adds `$route` and `$router` as read-only properties on Vue prototype. + +This means any future tests that try to mock `$route` or `$router` will fail. + +To avoid this, never install Vue Router when you're running tests. diff --git a/docs/pt-br/guides/using-with-vuex.md b/docs/pt-br/guides/using-with-vuex.md new file mode 100644 index 000000000..85f40d7fd --- /dev/null +++ b/docs/pt-br/guides/using-with-vuex.md @@ -0,0 +1,264 @@ +# Using with Vuex + +In this guide, we'll see how to test Vuex in components with `vue-test-utils`. + +## Mocking Actions + +Let’s look at some code. + +This is the component we want to test. It calls Vuex actions. + +``` html + + + +``` + +For the purposes of this test, we don’t care what the actions do, or what the store looks like. We just need to know that these actions are being fired when they should, and that they are fired with the expected value. + +To test this, we need to pass a mock store to Vue when we shallow our component. + +Instead of passing the store to the base Vue constructor, we can pass it to a - [localVue](../api/options.md#localvue). A localVue is a scoped Vue constructor that we can make changes to without affecting the global Vue constructor. + +Let’s see what this looks like: + +``` js +import { shallow, createLocalVue } from 'vue-test-utils' +import Vuex from 'vuex' +import Actions from '../../../src/components/Actions' + +const localVue = createLocalVue() + +localVue.use(Vuex) + +describe('Actions.vue', () => { + let actions + let store + + beforeEach(() => { + actions = { + actionClick: jest.fn(), + actionInput: jest.fn() + } + store = new Vuex.Store({ + state: {}, + actions + }) + }) + + it('calls store action actionInput when input value is input and an input event is fired', () => { + const wrapper = shallow(Actions, { store, localVue }) + const input = wrapper.find('input') + input.element.value = 'input' + input.trigger('input') + expect(actions.actionInput).toHaveBeenCalled() + }) + + it('does not call store action actionInput when input value is not input and an input event is fired', () => { + const wrapper = shallow(Actions, { store, localVue }) + const input = wrapper.find('input') + input.element.value = 'not input' + input.trigger('input') + expect(actions.actionInput).not.toHaveBeenCalled() + }) + + it('calls store action actionClick when button is clicked', () => { + const wrapper = shallow(Actions, { store, localVue }) + wrapper.find('button').trigger('click') + expect(actions.actionClick).toHaveBeenCalled() + }) +}) +``` + +What’s happening here? First we tell Vue to use Vuex with the `Vue.use` method. This is just a wrapper around `Vue.use`. + +We then make a mock store by calling new `Vuex.store` with our mock values. We only pass it the actions, since that’s all we care about. + +The actions are [jest mock functions](https://facebook.github.io/jest/docs/en/mock-functions.html). These mock functions give us methods to assert whether the actions were called or not. + +We can then assert in our tests that the action stub was called when expected. + +Now the way we define the store might look a bit foreign to you. + +We’re using `beforeEach` to ensure we have a clean store before each test. `beforeEach` is a mocha hook that’s called before each test. In our test, we are reassigning the store variables value. If we didn’t do this, the mock functions would need to be automatically reset. It also lets us change the state in our tests, without it affecting later tests. + +The most important thing to note in this test is that **we create a mock Vuex store and then pass it to vue-test-utils**. + +Great, so now we can mock actions, let’s look at mocking getters. + +## Mocking Getters + + +``` html + + + +``` + +This is a fairly simple component. It renders the result of the getters `clicks` and `inputValue`. Again, we don’t really care about what those getters returns – just that the result of them is being rendered correctly. + +Let’s see the test: + +``` js +import { shallow, createLocalVue } from 'vue-test-utils' +import Vuex from 'vuex' +import Actions from '../../../src/components/Getters' + +const localVue = createLocalVue() + +localVue.use(Vuex) + +describe('Getters.vue', () => { + let getters + let store + + beforeEach(() => { + getters = { + clicks: () => 2, + inputValue: () => 'input' + } + + store = new Vuex.Store({ + getters + }) + }) + + it('Renders state.inputValue in first p tag', () => { + const wrapper = shallow(Actions, { store, localVue }) + const p = wrapper.find('p') + expect(p.text()).toBe(getters.inputValue()) + }) + + it('Renders state.clicks in second p tag', () => { + const wrapper = shallow(Actions, { store, localVue }) + const p = wrapper.findAll('p').at(1) + expect(p.text()).toBe(getters.clicks().toString()) + }) +}) +``` +This test is similar to our actions test. We create a mock store before each test, pass it as an option when we call `shallow`, and assert that the value returned by our mock getters is being rendered. + +This is great, but what if we want to check our getters are returning the correct part of our state? + +## Mocking with Modules + +[Modules](https://vuex.vuejs.org/en/modules.html) are useful for separating out our store into manageable chunks. They also export getters. We can use these in our tests. + +Let’s look at our component: + +``` html + + + +``` +Simple component that includes one action and one getter. + +And the test: + +``` js +import { shallow, createLocalVue } from 'vue-test-utils' +import Vuex from 'vuex' +import Modules from '../../../src/components/Modules' +import module from '../../../src/store/module' + +const localVue = createLocalVue() + +localVue.use(Vuex) + +describe('Modules.vue', () => { + let actions + let state + let store + + beforeEach(() => { + state = { + module: { + clicks: 2 + } + } + + actions = { + moduleActionClick: jest.fn() + } + + store = new Vuex.Store({ + state, + actions, + getters: module.getters + }) + }) + + it('calls store action moduleActionClick when button is clicked', () => { + const wrapper = shallow(Modules, { store, localVue }) + const button = wrapper.find('button') + button.trigger('click') + expect(actions.moduleActionClick).toHaveBeenCalled() + }) + + it('Renders state.inputValue in first p tag', () => { + const wrapper = shallow(Modules, { store, localVue }) + const p = wrapper.find('p') + expect(p.text()).toBe(state.module.clicks.toString()) + }) +}) +``` + +### Resources + +- [Example project for this guide](https://github.com/eddyerburgh/vue-test-utils-vuex-example) +- [localVue](../api/options.md#localvue) +- [createLocalVue](../api/createLocalVue.md) From 683d484154df876b62d619d6a106c8b2e5295efd Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Thu, 16 Nov 2017 13:48:18 +0000 Subject: [PATCH 02/71] fix menu title --- docs/pt-br/README.md | 2 +- docs/pt-br/SUMMARY.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/pt-br/README.md b/docs/pt-br/README.md index a3eaf2bdc..b75cdba1e 100644 --- a/docs/pt-br/README.md +++ b/docs/pt-br/README.md @@ -2,7 +2,7 @@ `vue-test-utils` é a biblioteca oficial de testes de unidade para o Vue.js. -## Tabela de conteúdo +## Índice * [Guia](guides/README.md) * [Iniciando](guides/getting-started.md) diff --git a/docs/pt-br/SUMMARY.md b/docs/pt-br/SUMMARY.md index 0ba7935c8..48116aa5d 100644 --- a/docs/pt-br/SUMMARY.md +++ b/docs/pt-br/SUMMARY.md @@ -1,4 +1,4 @@ -## Tabela de conteúdo +## Índice * [Guia](guides/README.md) * [Iniciando](guides/getting-started.md) From ecd089b7e3433cb7d2dd5a4e7d37e02a0eb32290 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Thu, 16 Nov 2017 14:34:06 +0000 Subject: [PATCH 03/71] [to pt-br] translating getting started section --- docs/pt-br/guides/getting-started.md | 64 ++++++++++++++-------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/docs/pt-br/guides/getting-started.md b/docs/pt-br/guides/getting-started.md index 5c023d6dc..db5b1bf0e 100644 --- a/docs/pt-br/guides/getting-started.md +++ b/docs/pt-br/guides/getting-started.md @@ -1,8 +1,8 @@ -# Getting Started +# Iniciando -## Setup +## Configuração -To get a quick taste of using `vue-test-utils`, clone our demo repository with basic setup and install the dependencies: +Para obter um exemplo rápido de uso do `vue-test-utils` clone nosso repositório de demonstração que contém as configurações básicas e instale as dependências: ``` bash git clone https://github.com/vuejs/vue-test-utils-getting-started @@ -10,7 +10,7 @@ cd vue-test-utils-getting-started npm install ``` -You will see that the project includes a simple component, `counter.js`: +Você verá que o projeto inclui um componente simples, chamado `counter.js`: ```js // counter.js @@ -19,7 +19,7 @@ export default { template: `
{{ count }} - +
`, @@ -37,64 +37,64 @@ export default { } ``` -### Mounting Components +### Montando seus componentes -`vue-test-utils` tests Vue components by mounting them in isolation, mocking the necessary inputs (props, injections and user events) and asserting the outputs (render result, emitted custom events). +O `vue-test-utils` testa os componentes do Vue montando-os isoladamente, mockando as entradas necessárias (propriedades, slots e eventos de usuário) e verificando as saídas (renderização, eventos personalizados emitidos). -Mounted components are returned inside a [Wrapper](./api/wrapper.md), which exposes many convenience methods for manipulating, traversing and querying the underlying Vue component instance. +Os componentes montados são retornados em um embrulho (wrapper) que expõe muitos métodos para manipular, percorrer e consultar a instância do componente Vue correspondente. -You can create wrappers using the `mount` method. Let's create a file called `test.js`: +Você pode criar essses embrulhos usando o método `mount`. Vamos criar um chamado `test.js`: ```js // test.js -// Import the mount() method from the test utils -// and the component you want to test +// Importando o método mount() do test utils +// e o componente Counter para ser testado import { mount } from 'vue-test-utils' import Counter from './counter' -// Now mount the component and you have the wrapper +// Agora montamos o componente e obtermos o embrulho const wrapper = mount(Counter) -// You can access the actual Vue instance via wrapper.vm +// Você pode acessar a instância atual do Vue através de wrapper.vm const vm = wrapper.vm -// To inspect the wrapper deeper just log it to the console -// and your adventure with the vue-test-utils begins +// Para inspecionar a composição do embrulho exiba-o no console +// ...Sua aventura com o vue-test-utils começa agora :) console.log(wrapper) ``` -### Test rendered HTML output of the component +### Testar a saída HTML do componente -Now that we have the wrapper, the first thing we can do is to verify that the rendered HTML output of the component matches what is expected. +Agora que nós já temos o embrulho, a primeira coisa que podemos fazer é verificar se a saída HTML que componente nos entrega é a esperada. ```js import { mount } from 'vue-test-utils' import Counter from './counter' describe('Counter', () => { - // Now mount the component and you have the wrapper + // Montando o componente e obtendo o embrulho const wrapper = mount(Counter) - it('renders the correct markup', () => { + it('renderiza o HTML correto', () => { expect(wrapper.html()).toContain('0') }) - // it's also easy to check for the existence of elements - it('has a button', () => { + // Também é fácil verificar se um elemento existe + it('verifica se o botão foi desenhado', () => { expect(wrapper.contains('button')).toBe(true) }) }) ``` -Now run the tests with `npm test`. You should see the tests passing. +Agora execute os testes com o comando `npm tests`. Você deve ver os testes passando. -### Simulating User Interaction +### Simulando a interação do usuário -Our counter should increment the count when the user clicks the button. To simulate the behavior, we need to first locate the button with `wrapper.find()`, which returns a **wrapper for the button element**. We can then simulate the click by calling `.trigger()` on the button wrapper: +Nosso `Counter` deve incrementar o contador quando o usuário clica no botão. Para simular esse comportamento, primeiro precisamos localizar o botão com `wrapper.find()`, que retorna um embrulho (wrapper) para o elemento do botão. Agora nós podemos simular o evento de clique, chamando o método `trigger()` no embrulho do botão: ```js -it('button click should increment the count', () => { +it('o clique do botão deve incrementar a contagem', () => { expect(wrapper.vm.count).toBe(0) const button = wrapper.find('button') button.trigger('click') @@ -102,15 +102,15 @@ it('button click should increment the count', () => { }) ``` -### What about `nextTick`? +### E quanto ao `nextTick`? -Vue batches pending DOM updates and applies them asynchronously to prevent unnecessary re-renders caused by multiple data mutations. This is why in practice we often have to use `Vue.nextTick` to wait until Vue has performed the actual DOM update after we trigger some state change. +Os lotes Vue estão pendentes de atualizações do DOM, aplicando-as de forma assíncrona para evitar re-renders desnecessários causados por múltiplas mutações de dados. É por isso que, na prática, muitas vezes temos que usar `Vue.nextTick` para esperar até que o Vue realize a atualização real do DOM, depois de ativar algumas mudanças de estado. -To simplify usage, `vue-test-utils` applies all updates synchronously so you don't need to use `Vue.nextTick` to wait for DOM updates in your tests. +Para simplificar o uso, o `vue-test-utils` aplica todas as atualizações de forma síncrona, então você não precisa usar o `Vue.nextTick` para esperar por atualizações do DOM nos seus testes. -*Note: `nextTick` is still necessary when you need to explictly advance the event loop, for operations such as asynchronous callbacks or promise resolution.* +*Nota: o `nextTick` ainda é necessário para quando você precisa avançar explicitamente o ciclo do evento, ou seja, para operações como retorno de chamadas assíncronas ou resultados de uma Promise.* -## What's Next +## A seguir -- Integrate `vue-test-utils` into your project by [choosing a test runner](./choosing-a-test-runner.md) -- Learn more about [common techniques when writing tests](./common-tips.md) +- Integre o `vue-test-utils` no seu projeto [escolhendo seu executador de testes](./choosing-a-test-runner.md) +- Leia mais sobre [técnicas comuns ao escrever testes](./common-tips.md) From e11ce651d1e515e1be3844de89a56b1cd8a94ca1 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Thu, 16 Nov 2017 16:49:45 +0000 Subject: [PATCH 04/71] [to pt-br] translating common tips section --- docs/pt-br/guides/common-tips.md | 95 ++++++++++++++++---------------- 1 file changed, 49 insertions(+), 46 deletions(-) diff --git a/docs/pt-br/guides/common-tips.md b/docs/pt-br/guides/common-tips.md index abd7500a7..07435778c 100644 --- a/docs/pt-br/guides/common-tips.md +++ b/docs/pt-br/guides/common-tips.md @@ -1,117 +1,118 @@ -# Common Tips +# Dicas comuns -## Knowing What to Test +## Sabendo o que testar -For UI components, we don't recommend aiming for complete line-based coverage, because it leads to too much focus on the internal implementation details of the components and could result in brittle tests. +Para componentes com interface não recomendamos o foco na cobertura completa baseada em linha, porque ela leva muito o foco para detalhes internos da implementação dos componentes, podendo resultar em testes frágeis. -Instead, we recommend writing tests that assert your component's public interface, and treat its internals as a black box. A single test case would assert that some input (user interaction or change of props) provided to the component results in the expected output (render result or emitted custom events). +Em vez disso, nós recomendamos escrever testes que verifiquem seus componentes com interface pública e trate os internos como uma caixa preta. Um caso de teste único irá verificar se a entrada (interações do usuário ou troca de props) forneceu o resultado (renderização ou emissão de eventos) esperado para o componente. -For example, for the `Counter` component which increments a display counter by 1 each time a button is clicked, its test case would simulate the click and assert that the rendered output has increased by 1. The test doesn't care about how the Counter increments the value, it only cares about the input and the output. +Por exemplo, para o componente `Counter` que incrementa um contador em cada vez que um botão é clicado, seu caso de teste teria que silumar o clique e verificar se a saída renderizada se incrementou. O teste não se importa sobre como `Counter` incrementou o valor, ele apenas se preocupa com a entrada e a saída dos dados. -The benefit of this approach is that as long as your component's public interface remains the same, your tests will pass no matter how the component's internal implementation changes over time. +O benefício desta abordagem é que enquanto a interface pública do seu componente permanece a mesma, seus testes irão passar sem se importar de como o componente faz a implementação do código interno e se houve ou não mudanças por lá. -This topic is discussed with more details in a [great presentation by Matt O'Connell](http://slides.com/mattoconnell/deck#/). +Esse tópico é discutido com mais detalhes em uma [excelente apresentação de Matt O'Connell](http://slides.com/mattoconnell/deck#/). -## Shallow Rendering +## Renderização superficial -In unit tests, we typically want to focus on the component being tested as an isolated unit and avoid indirectly asserting the behavior of its child components. +Em testes de unidade, normalmente queremos nos focar no componente a ser testeado, isolando-o como uma unidade e evitando verificações indiretas em comportamentos dos seus filhos. -In addition, for components that contain many child components, the entire rendered tree can get really big. Repeatedly rendering all child components could slow down our tests. +Além disso, para componentes que possuem muitos componentes filhos, toda a árvore de renderização pode ficar realmente grande. A repetição de renderização de todos componentes filhos vão deixar seus testes lentos. -`vue-test-utils` allows you to mount a component without rendering its child components (by stubbing them) with the `shallow` method: +O `vue-test-utils` permite que você monte um componente sem renderizar seus componentes filhos, para isso, use o método `shallow`: ```js import { shallow } from 'vue-test-utils' -const wrapper = shallow(Component) // returns a Wrapper containing a mounted Component instance -wrapper.vm // the mounted Vue instance +// obtém o embrulho contendo a instância montada de Componente +const wrapper = shallow(Componente) +wrapper.vm // instância do Vue já montada ``` -## Asserting Emitted Events +## Verificando os eventos emitidos -Each mounted wrapper automatically records all events emitted by the underlying Vue instance. You can retrieve the recorded events using the `wrapper.emitted()` method: +Cada embrulho montado grava automaticamente todos os eventos emitidos pela instância Vue contida. Você pode recuperar os eventos registrados usando o método `emitted`: ``` js wrapper.vm.$emit('foo') wrapper.vm.$emit('foo', 123) /* -wrapper.emitted() returns the following object: +wrapper.emitted() retorna o objeto a seguir: { - foo: [[], [123]] + foo: [ [], [123] ] } */ ``` -You can then make assertions based on these data: +Então você pode criar asserções baseadas nesses dados: ``` js import { expect } from 'chai' -// assert event has been emitted -expect(wrapper.emitted().foo).toBeTruthy() +// verifica se o evento 'foo' foi emitido +expect( wrapper.emitted().foo ).toBeTruthy() -// assert event count -expect(wrapper.emitted().foo.length).toBe(2) +// verifica as vezes que o evento 'foo' doi emitido +expect( wrapper.emitted().foo.length ).toBe(2) -// assert event payload -expect(wrapper.emitted().foo[1]).toEqual([123]) +// verifica a carga do segundo evento 'foo' emitido +expect( wrapper.emitted().foo[1] ).toEqual([123]) ``` -You can also get an Array of the events in their emit order by calling [wrapper.emittedByOrder()](../api/wrapper/emittedByOrder.md). +Além disso, você pode pegar um Array dos eventos emitidos em ordem de chamada com o método [wrapper.emittedByOrder()](../api/wrapper/emittedByOrder.md). -## Manipulating Component State +## Manupulando o estado do componente -You can directly manipulate the state of the component using the `setData` or `setProps` method on the wrapper: +Você pode manipular diretamente o estado do componente usando os métodos `setData` ou `setProps` no embrulho: ```js -wrapper.setData({ count: 10 }) +wrapper.setData({ contador: 10 }) wrapper.setProps({ foo: 'bar' }) ``` -## Mocking Props +## Mockando propriedades -You can pass props to the component using Vue's built-in `propsData` option: +Você pode passar propriedades para o componente usando a opção `propsData` integrada no Vue: ```js import { mount } from 'vue-test-utils' mount(Component, { propsData: { - aProp: 'some value' + umaProp: 'qualquer valor' } }) ``` -You can also update the props of an already-mounted component with the `wrapper.setProps({})` method. +Você também pode atualizar as propriedades mesmo com o componente já montado, para isso use o método `wrapper.setProps({})`. -*For a full list of options, please see the [mount options section](../api/options.md) of the docs.* +*Para ver a lista completa de opções, por favor veja a seção [opções de montagem](../api/options.md) nessa documentação.* -## Applying Global Plugins and Mixins +## Aplicando plugins e mixins globais -Some of the components may rely on features injected by a global plugin or mixin, for example `vuex` and `vue-router`. +Alguns dos seus componentes podem ter características injetadas por um plugin ou mixin global, por exemplo o `vuex`, `vue-router` e `vue-multilanguage`. -If you are writing tests for components in a specific app, you can setup the same global plugins and mixins once in the entry of your tests. But in some cases, for example testing a generic component suite that may get shared across different apps, it's better to test your components in a more isolated setup, without polluting the global `Vue` constructor. We can use the [createLocalVue](../api/createLocalVue.md) method to achieve that: +Se você está escrevendo testes para componentes de uma aplicação específica, você pode configurar os plugins e mixins globais uma vez na entrada dos seus testes. Mas, em alguns casos, por exemplo, testando um pacote de componentes genéricos que podem ser compartilhados em diferentes aplicações, será melhor testar seus componentes com uma configuração mais isolada, sem popular o construtor global do Vue. Nós podemos usar o método [createLocalVue](../api/createLocalVue.md) para conseguir isso: ``` js import createLocalVue from 'vue-test-utils' -// create an extended Vue constructor +// criando um construtor ampliado do Vue const localVue = createLocalVue() -// install plugins as normal -localVue.use(MyPlugin) +// Instalando normalmente os seus plugins +localVue.use(MeuPlugin) -// pass the localVue to the mount options -mount(Component, { +// Passe o localVue para o embrulho do componente +mount(Componente, { localVue }) ``` -## Mocking Injections +## Mockando injeções -Another strategy for injected properties is simply mocking them. You can do that with the `mocks` option: +Outra estratégia para injetar propriedades é simplismente mockar ela. Você pode fazer isso com a opção `mocks`: ```js import { mount } from 'vue-test-utils' @@ -125,11 +126,13 @@ const $route = { mount(Component, { mocks: { - $route // adds the mocked $route object to the Vue instance before mounting component + // adiciona o objeto $route mockado na instância Vue + // antes da montagem do componente + $route } }) ``` -## Dealing with Routing +## Lidando com o roteamento -Since routing by definition has to do with the overall structure of the application and involves multiple components, it is best tested via integration or end-to-end tests. For individual components that rely on `vue-router` features, you can mock them using the techniques mentioned above. +Uma vez que o roteamento, por definição, tem a ver com a estrutura geral da aplicação e envolve muitos componentes, é melhor testado atráves de testes de integração ou de ponta a ponta. Para componentes individuais que dependem dos recursos do `vue-router`, você pode mocka-lo usando as técnicas mencionadas acima. From 437ff13159be33780392591dea6052b7ba46b4cc Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Thu, 16 Nov 2017 17:57:50 +0000 Subject: [PATCH 05/71] [to pt-br] translating dom events section --- docs/pt-br/guides/dom-events.md | 154 ++++++++++++++++---------------- 1 file changed, 77 insertions(+), 77 deletions(-) diff --git a/docs/pt-br/guides/dom-events.md b/docs/pt-br/guides/dom-events.md index 1ed117610..1ccfd0ce3 100644 --- a/docs/pt-br/guides/dom-events.md +++ b/docs/pt-br/guides/dom-events.md @@ -1,61 +1,60 @@ -# Testing Key, Mouse and other DOM events +# Testando mouse, teclas e outros eventos do DOM -## Trigger events +## Desencadear eventos -The `Wrapper` expose a `trigger` method. It can be used to trigger DOM events. +O embrulho (wrapper) expõe o método `trigger`. Ele pode ser usado para desencadear eventos do DOM. ```js -const wrapper = mount(MyButton) +const wrapper = mount(MeuBotao) wrapper.trigger('click') ``` -You should be aware, that find returns a wrapper as well. Assuming `MyComponent` contains a button, the following code clicks the button. +Você deve estar ciente que esse método também retorna um embrulho. Assumindo que em `MeuComponente` há um botão, o código a seguir simula o clique no botão. ```js -const wrapper = mount(MyComponent) +const wrapper = mount(MeuComponente) wrapper.find('button').trigger('click') ``` -## Options +## Opções -The trigger method takes an optional `options` object. The properties in the `options` object are added to the Event. +O método `trigger` pode receber um objeto `options` opcional. As propriedades no objeto `options` serão adicionadas no evento. -You can run preventDefault on the event by passing `preventDefault: true` in `options`. +Você pode executar `preventDefault` no evento passando `preventDefault: true` no objeto `options`: ```js -const wrapper = mount(MyButton) +const wrapper = mount(MeuBotao) wrapper.trigger('click', { preventDefault: true }) ``` +## Exemplo de clique no mouse -## Mouse Click Example - -**Component under test** +**Componente que será testado** ```html ``` -And create a test file named `test/Counter.spec.js` with the following code: +Agora crie um arquivo de teste chamado `test/Contador.spec.js` com o código a seguir: ```js import { shallow } from 'vue-test-utils' -import Counter from '../src/Counter.vue' +import Contador from '../src/Contador.vue' -describe('Counter.vue', () => { - it('increments count when button is clicked', () => { - const wrapper = shallow(Counter) +describe('Contador.vue', () => { + it('incrementa o contador quando o botão é clicado, () => { + const wrapper = shallow(Contador) wrapper.find('button').trigger('click') expect(wrapper.find('div').text()).toMatch('1') }) }) ``` -And now we can run the test: +Agora nós podemos executar o teste usando: ``` npm run unit ``` -Woohoo, we got our tests running! +Woohoo :o, nossos testes estão rodando! -### Resources +### Recursos -- [Example project for this setup](https://github.com/vuejs/vue-test-utils-mocha-webpack-example) +- [Projeto de exemplo com essa configuração](https://github.com/vuejs/vue-test-utils-mocha-webpack-example) - [Mocha](https://mochajs.org/) - [mocha-webpack](http://zinserjan.github.io/mocha-webpack/) - [Chai](http://chaijs.com/) From 85160dd1c70ff07983283b9723b33971b6a1b638 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 03:07:10 +0000 Subject: [PATCH 09/71] [to pt-br] translating using with vue router section --- docs/pt-br/guides/using-with-vue-router.md | 38 +++++++++++----------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/docs/pt-br/guides/using-with-vue-router.md b/docs/pt-br/guides/using-with-vue-router.md index d69353af0..ac1be87be 100644 --- a/docs/pt-br/guides/using-with-vue-router.md +++ b/docs/pt-br/guides/using-with-vue-router.md @@ -1,10 +1,10 @@ -# Using with Vue Router +# Usando com o Vue Router -## Installing Vue Router in tests +## Instalando o Vue Router nos testes -You should never install Vue Router on the Vue base constructor in tests. Installing Vue Router adds `$route` and `$router` as read-only properties on Vue prototype. +Você nunca deveria instalar o Vue Router no construtor base do Vue dos seus testes. A instalação do Vue Router adiciona `$route` e `$router` como propriedades de somente leitura no protótipo dos componentes Vue. -To avoid this, we can create a localVue, and install Vue Router on that. +Para evitar isso, nós criamos o `localVue` e instalamos o Vue Router no seu interior. ```js import VueRouter from 'vue-router' @@ -17,21 +17,21 @@ shallow(Component, { }) ``` -## Testing components that use `router-link` or `router-view` +## Testando componentes que usam `router-link` ou `router-view` -When you install Vue Router, the `router-link` and `router-view` components are registered. This means we can use them anywhere in our application without needing to import them. +Quando você instala o Vue Router, os componentes `router-link` e `router-view` são registrados. Isso significa que podemos usa-los em qualquer lugar da nossa aplicação sem precisar importá-los. -When we run tests, we need to make these vue-router components available to the component we're mounting. There are two methods to do this. +Quando executamos os testes, nós precisamos disponibilizar os componentes do Vue Router para os componentes que estamos montando. Existem dois métodos para se fazer isso. -### Using stubs +### Usando stubs ```js -shallow(Component, { +shallow(Componente, { stubs: ['router-link', 'router-view'] }) ``` -### Installing Vue Router with localVue +### Instalando o Vue Router com o localVue ```js import VueRouter from 'vue-router' @@ -39,18 +39,18 @@ const localVue = createLocalVue() localVue.use(VueRouter) -shallow(Component, { +shallow(Componente, { localVue }) ``` -## Mocking `$route` and `$router` +## Mockando o `$route` e o `$router` -Sometimes you want to test that a component does something with parameters from the `$route` and `$router` objects. To do that, you can pass custom mocks to the Vue instance. +Às vezes você quer testar que um componente faz algo com os parâmetros dos objetos `$route` e `$router`. Para fazer isso você pode passar mocks personalizados para a instância do Vue. ```js const $route = { - path: '/some/path' + path: '/rota/qualquer' } const wrapper = shallow(Component, { @@ -59,13 +59,13 @@ const wrapper = shallow(Component, { } }) -wrapper.vm.$router // /some/path +wrapper.vm.$router // /rota/qualquer ``` -## Common gotchas +## Obstáculos comuns -Installing Vue Router adds `$route` and `$router` as read-only properties on Vue prototype. +A instalação do Vue Router adiciona `$route` e `$router` como propriedades de somente leitura do protótipo Vue. -This means any future tests that try to mock `$route` or `$router` will fail. +Isso significa que todos os testes futuros que tentam mockar o `$route` ou o `$router` irão falhar. -To avoid this, never install Vue Router when you're running tests. +Para evitar isso, nunca instale o Vue Router quando estiver executando seus testes. From 72af7228043e8cddbe3fec04085bd35af09af486 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 03:25:16 +0000 Subject: [PATCH 10/71] [to pt-br] translating partially using with vuex section --- docs/pt-br/guides/using-with-vuex.md | 63 ++++++++++++++-------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/docs/pt-br/guides/using-with-vuex.md b/docs/pt-br/guides/using-with-vuex.md index 85f40d7fd..b27169a8f 100644 --- a/docs/pt-br/guides/using-with-vuex.md +++ b/docs/pt-br/guides/using-with-vuex.md @@ -1,18 +1,18 @@ -# Using with Vuex +# Usando com o Vuex -In this guide, we'll see how to test Vuex in components with `vue-test-utils`. +Nesse guia verems como testar o Vuex nos componentes com o `vue-test-utils`. -## Mocking Actions +## Mockando ações -Let’s look at some code. +Vejamos algum código... -This is the component we want to test. It calls Vuex actions. +Esse é o componente que queremos testar. Ele chama ações do Vuex. ``` html @@ -22,12 +22,12 @@ import { mapActions } from 'vuex' export default{ methods: { ...mapActions([ - 'actionClick' + 'acaoDeClique' ]), - actionInputIfTrue: function actionInputIfTrue (event) { - const inputValue = event.target.value - if (inputValue === 'input') { - this.$store.dispatch('actionInput', { inputValue }) + acaoSeVerdade: function (event) { + const valorInput = event.target.value + if (valorInput === 'input') { + this.$store.dispatch('acaoInput', { valorInput }) } } } @@ -35,52 +35,53 @@ export default{ ``` -For the purposes of this test, we don’t care what the actions do, or what the store looks like. We just need to know that these actions are being fired when they should, and that they are fired with the expected value. +Para os fins desse teste, não nos importa o que cada ação do Vuex faz ou como a store é criada. Nos precisamos apenas saber que essas ações estão sendo disparadas quando deveriam, e que elas são disparadas com os valores esperados. -To test this, we need to pass a mock store to Vue when we shallow our component. +Para testar isso, precisamos passar um mock da store para o Vue quando envelopamos nosso componente. -Instead of passing the store to the base Vue constructor, we can pass it to a - [localVue](../api/options.md#localvue). A localVue is a scoped Vue constructor that we can make changes to without affecting the global Vue constructor. +Em vez de passar a store para o construtor do Vue, nós passamos um [localVue](../api/options.md#localvue). Um localVue é um construtor local do Vue com escopo que permite alterações sem afetar o construtor global. -Let’s see what this looks like: +Vamos ver como isso se apreenta no código: ``` js import { shallow, createLocalVue } from 'vue-test-utils' import Vuex from 'vuex' -import Actions from '../../../src/components/Actions' +import Acoes from '../../../src/componentes/Acoes' const localVue = createLocalVue() localVue.use(Vuex) -describe('Actions.vue', () => { - let actions +describe('Acoes.vue', () => { + let acoes let store beforeEach(() => { - actions = { - actionClick: jest.fn(), - actionInput: jest.fn() + acoes = { + acaoDeClique: jest.fn(), + acaoInput: jest.fn() } + store = new Vuex.Store({ state: {}, - actions + acoes }) }) - it('calls store action actionInput when input value is input and an input event is fired', () => { - const wrapper = shallow(Actions, { store, localVue }) + it('chama a ação acaoInput da store quando o valor do input é inserido e um evento do input é disparado', () => { + const wrapper = shallow(Acoes, { store, localVue }) const input = wrapper.find('input') input.element.value = 'input' input.trigger('input') - expect(actions.actionInput).toHaveBeenCalled() + expect( acoes.acaoInput ).toHaveBeenCalled() }) - it('does not call store action actionInput when input value is not input and an input event is fired', () => { - const wrapper = shallow(Actions, { store, localVue }) + it('não liga a ação acaoInput da store quando o valor do input não é inserido e um evento do input é disparado', () => { + const wrapper = shallow(Acoes, { store, localVue }) const input = wrapper.find('input') input.element.value = 'not input' input.trigger('input') - expect(actions.actionInput).not.toHaveBeenCalled() + expect( acoes.acaoInput ).not.toHaveBeenCalled() }) it('calls store action actionClick when button is clicked', () => { @@ -91,9 +92,9 @@ describe('Actions.vue', () => { }) ``` -What’s happening here? First we tell Vue to use Vuex with the `Vue.use` method. This is just a wrapper around `Vue.use`. +O que está acontecendo aqui? Primeiro contamos ao localVue que ele usará o Vuex no método `localVue.use`. Este é apenas um embrulho do `Vue.use`. -We then make a mock store by calling new `Vuex.store` with our mock values. We only pass it the actions, since that’s all we care about. +Em seguida, fazemos uma store mockada chamando o método `Vuex.Store` com os valores do mock. Nós apenas passamos as ações, já que é o que nos importa no momento. The actions are [jest mock functions](https://facebook.github.io/jest/docs/en/mock-functions.html). These mock functions give us methods to assert whether the actions were called or not. From 2c19d3212fe35daee6507aecee6b01f960a54000 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 13:08:31 +0000 Subject: [PATCH 11/71] feat(docs): add pt-br, add docs:serve command and lint markdown errors --- docs/LANGS.md | 1 + docs/pt-br/guides/choosing-a-test-runner.md | 2 +- docs/pt-br/guides/common-tips.md | 6 +- .../guides/testing-SFCs-with-mocha-webpack.md | 2 +- docs/pt-br/guides/using-with-vuex.md | 4 +- package-lock.json | 902 +----------------- package.json | 1 + 7 files changed, 10 insertions(+), 908 deletions(-) diff --git a/docs/LANGS.md b/docs/LANGS.md index 734a128c2..2a971c5a0 100644 --- a/docs/LANGS.md +++ b/docs/LANGS.md @@ -1,3 +1,4 @@ * [English](en/) * [日本語](ja/) * [简体中文](zh-cn/) +* [Portuguese (Brazil)](pt-br/) diff --git a/docs/pt-br/guides/choosing-a-test-runner.md b/docs/pt-br/guides/choosing-a-test-runner.md index 6c087e7bc..87714fe09 100644 --- a/docs/pt-br/guides/choosing-a-test-runner.md +++ b/docs/pt-br/guides/choosing-a-test-runner.md @@ -6,7 +6,7 @@ Existem muitos executadores de testes populares no Javascript, o `vue-test-utils Há algumas coisas a considerar ao escolher um *test runner*: conjunto de recursos, desempenho e suporte a pré-compilação de componentes arquivos de únicos (SFC). Depois de comparar cuidadosamente as bibliotecas existentes, aqui estão dois *test runner* que recomendamos: -- [Jest](https://facebook.github.io/jest/docs/en/getting-started.html#content) é o executador de testes mais completo. Ele requer menos configuração, usa JSDOM por padrão, e fornece uma ótima experiência de usuário na linha de comando. Contudo, você vai precisar de um pré-processador para ser possível importar componentes SFC em seus testes. Nos criamos o pré-processador `vue-jest`, para lidar com os recursos SFC mais comuns, mas atualmente não possuímos 100% de compatibilidade com o `vue-loader. +- [Jest](https://facebook.github.io/jest/docs/en/getting-started.html#content) é o executador de testes mais completo. Ele requer menos configuração, usa JSDOM por padrão, e fornece uma ótima experiência de usuário na linha de comando. Contudo, você vai precisar de um pré-processador para ser possível importar componentes SFC em seus testes. Nos criamos o pré-processador `vue-jest`, para lidar com os recursos SFC mais comuns, mas atualmente não possuímos 100% de compatibilidade com o `vue-loader`. - [mocha-webpack](https://github.com/zinserjan/mocha-webpack) é um embrulho que envolve o webpack e o Mocha, mas com uma interface simplificada e um modo observador. O benefício dessa configuração é o suporte SFC completo via webpack + `vue-loader`, mas isso requer maiores configurações antecipadas. diff --git a/docs/pt-br/guides/common-tips.md b/docs/pt-br/guides/common-tips.md index 07435778c..64023de70 100644 --- a/docs/pt-br/guides/common-tips.md +++ b/docs/pt-br/guides/common-tips.md @@ -50,13 +50,13 @@ Então você pode criar asserções baseadas nesses dados: import { expect } from 'chai' // verifica se o evento 'foo' foi emitido -expect( wrapper.emitted().foo ).toBeTruthy() +expect(wrapper.emitted().foo).toBeTruthy() // verifica as vezes que o evento 'foo' doi emitido -expect( wrapper.emitted().foo.length ).toBe(2) +expect(wrapper.emitted().foo.length).toBe(2) // verifica a carga do segundo evento 'foo' emitido -expect( wrapper.emitted().foo[1] ).toEqual([123]) +expect(wrapper.emitted().foo[1]).toEqual([123]) ``` Além disso, você pode pegar um Array dos eventos emitidos em ordem de chamada com o método [wrapper.emittedByOrder()](../api/wrapper/emittedByOrder.md). diff --git a/docs/pt-br/guides/testing-SFCs-with-mocha-webpack.md b/docs/pt-br/guides/testing-SFCs-with-mocha-webpack.md index fa79320d0..01630def6 100644 --- a/docs/pt-br/guides/testing-SFCs-with-mocha-webpack.md +++ b/docs/pt-br/guides/testing-SFCs-with-mocha-webpack.md @@ -154,7 +154,7 @@ import { shallow } from 'vue-test-utils' import Contador from '../src/Contador.vue' describe('Contador.vue', () => { - it('incrementa o contador quando o botão é clicado, () => { + it('incrementa o contador quando o botão é clicado', () => { const wrapper = shallow(Contador) wrapper.find('button').trigger('click') expect(wrapper.find('div').text()).toMatch('1') diff --git a/docs/pt-br/guides/using-with-vuex.md b/docs/pt-br/guides/using-with-vuex.md index b27169a8f..08bdf6cfa 100644 --- a/docs/pt-br/guides/using-with-vuex.md +++ b/docs/pt-br/guides/using-with-vuex.md @@ -73,7 +73,7 @@ describe('Acoes.vue', () => { const input = wrapper.find('input') input.element.value = 'input' input.trigger('input') - expect( acoes.acaoInput ).toHaveBeenCalled() + expect(acoes.acaoInput).toHaveBeenCalled() }) it('não liga a ação acaoInput da store quando o valor do input não é inserido e um evento do input é disparado', () => { @@ -81,7 +81,7 @@ describe('Acoes.vue', () => { const input = wrapper.find('input') input.element.value = 'not input' input.trigger('input') - expect( acoes.acaoInput ).not.toHaveBeenCalled() + expect(acoes.acaoInput).not.toHaveBeenCalled() }) it('calls store action actionClick when button is clicked', () => { diff --git a/package-lock.json b/package-lock.json index 13c90f371..3386e28e1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "vue-test-utils", - "version": "1.0.0-beta.4", + "version": "1.0.0-beta.5", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1710,7 +1710,6 @@ "requires": { "anymatch": "1.3.2", "async-each": "1.0.1", - "fsevents": "1.1.2", "glob-parent": "2.0.0", "inherits": "2.0.3", "is-binary-path": "1.0.1", @@ -3628,905 +3627,6 @@ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, - "fsevents": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.1.2.tgz", - "integrity": "sha512-Sn44E5wQW4bTHXvQmvSHwqbuiXtduD6Rrjm2ZtUEGbyrig+nUH3t/QD4M4/ZXViY556TBpRgZkHLDx3JxPwxiw==", - "dev": true, - "optional": true, - "requires": { - "nan": "2.7.0", - "node-pre-gyp": "0.6.36" - }, - "dependencies": { - "abbrev": { - "version": "1.1.0", - "bundled": true, - "dev": true, - "optional": true - }, - "ajv": { - "version": "4.11.8", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "co": "4.6.0", - "json-stable-stringify": "1.0.1" - } - }, - "ansi-regex": { - "version": "2.1.1", - "bundled": true, - "dev": true - }, - "aproba": { - "version": "1.1.1", - "bundled": true, - "dev": true, - "optional": true - }, - "are-we-there-yet": { - "version": "1.1.4", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "delegates": "1.0.0", - "readable-stream": "2.2.9" - } - }, - "asn1": { - "version": "0.2.3", - "bundled": true, - "dev": true, - "optional": true - }, - "assert-plus": { - "version": "0.2.0", - "bundled": true, - "dev": true, - "optional": true - }, - "asynckit": { - "version": "0.4.0", - "bundled": true, - "dev": true, - "optional": true - }, - "aws-sign2": { - "version": "0.6.0", - "bundled": true, - "dev": true, - "optional": true - }, - "aws4": { - "version": "1.6.0", - "bundled": true, - "dev": true, - "optional": true - }, - "balanced-match": { - "version": "0.4.2", - "bundled": true, - "dev": true - }, - "bcrypt-pbkdf": { - "version": "1.0.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "tweetnacl": "0.14.5" - } - }, - "block-stream": { - "version": "0.0.9", - "bundled": true, - "dev": true, - "requires": { - "inherits": "2.0.3" - } - }, - "boom": { - "version": "2.10.1", - "bundled": true, - "dev": true, - "requires": { - "hoek": "2.16.3" - } - }, - "brace-expansion": { - "version": "1.1.7", - "bundled": true, - "dev": true, - "requires": { - "balanced-match": "0.4.2", - "concat-map": "0.0.1" - } - }, - "buffer-shims": { - "version": "1.0.0", - "bundled": true, - "dev": true - }, - "caseless": { - "version": "0.12.0", - "bundled": true, - "dev": true, - "optional": true - }, - "co": { - "version": "4.6.0", - "bundled": true, - "dev": true, - "optional": true - }, - "code-point-at": { - "version": "1.1.0", - "bundled": true, - "dev": true - }, - "combined-stream": { - "version": "1.0.5", - "bundled": true, - "dev": true, - "requires": { - "delayed-stream": "1.0.0" - } - }, - "concat-map": { - "version": "0.0.1", - "bundled": true, - "dev": true - }, - "console-control-strings": { - "version": "1.1.0", - "bundled": true, - "dev": true - }, - "core-util-is": { - "version": "1.0.2", - "bundled": true, - "dev": true - }, - "cryptiles": { - "version": "2.0.5", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "boom": "2.10.1" - } - }, - "dashdash": { - "version": "1.14.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "assert-plus": "1.0.0" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - } - } - }, - "debug": { - "version": "2.6.8", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "ms": "2.0.0" - } - }, - "deep-extend": { - "version": "0.4.2", - "bundled": true, - "dev": true, - "optional": true - }, - "delayed-stream": { - "version": "1.0.0", - "bundled": true, - "dev": true - }, - "delegates": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "ecc-jsbn": { - "version": "0.1.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "jsbn": "0.1.1" - } - }, - "extend": { - "version": "3.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "extsprintf": { - "version": "1.0.2", - "bundled": true, - "dev": true - }, - "forever-agent": { - "version": "0.6.1", - "bundled": true, - "dev": true, - "optional": true - }, - "form-data": { - "version": "2.1.4", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "asynckit": "0.4.0", - "combined-stream": "1.0.5", - "mime-types": "2.1.15" - } - }, - "fs.realpath": { - "version": "1.0.0", - "bundled": true, - "dev": true - }, - "fstream": { - "version": "1.0.11", - "bundled": true, - "dev": true, - "requires": { - "graceful-fs": "4.1.11", - "inherits": "2.0.3", - "mkdirp": "0.5.1", - "rimraf": "2.6.1" - } - }, - "fstream-ignore": { - "version": "1.0.5", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "fstream": "1.0.11", - "inherits": "2.0.3", - "minimatch": "3.0.4" - } - }, - "gauge": { - "version": "2.7.4", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "aproba": "1.1.1", - "console-control-strings": "1.1.0", - "has-unicode": "2.0.1", - "object-assign": "4.1.1", - "signal-exit": "3.0.2", - "string-width": "1.0.2", - "strip-ansi": "3.0.1", - "wide-align": "1.1.2" - } - }, - "getpass": { - "version": "0.1.7", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "assert-plus": "1.0.0" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - } - } - }, - "glob": { - "version": "7.1.2", - "bundled": true, - "dev": true, - "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" - } - }, - "graceful-fs": { - "version": "4.1.11", - "bundled": true, - "dev": true - }, - "har-schema": { - "version": "1.0.5", - "bundled": true, - "dev": true, - "optional": true - }, - "har-validator": { - "version": "4.2.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "ajv": "4.11.8", - "har-schema": "1.0.5" - } - }, - "has-unicode": { - "version": "2.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "hawk": { - "version": "3.1.3", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "boom": "2.10.1", - "cryptiles": "2.0.5", - "hoek": "2.16.3", - "sntp": "1.0.9" - } - }, - "hoek": { - "version": "2.16.3", - "bundled": true, - "dev": true - }, - "http-signature": { - "version": "1.1.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "assert-plus": "0.2.0", - "jsprim": "1.4.0", - "sshpk": "1.13.0" - } - }, - "inflight": { - "version": "1.0.6", - "bundled": true, - "dev": true, - "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" - } - }, - "inherits": { - "version": "2.0.3", - "bundled": true, - "dev": true - }, - "ini": { - "version": "1.3.4", - "bundled": true, - "dev": true, - "optional": true - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "requires": { - "number-is-nan": "1.0.1" - } - }, - "is-typedarray": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "isarray": { - "version": "1.0.0", - "bundled": true, - "dev": true - }, - "isstream": { - "version": "0.1.2", - "bundled": true, - "dev": true, - "optional": true - }, - "jodid25519": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "jsbn": "0.1.1" - } - }, - "jsbn": { - "version": "0.1.1", - "bundled": true, - "dev": true, - "optional": true - }, - "json-schema": { - "version": "0.2.3", - "bundled": true, - "dev": true, - "optional": true - }, - "json-stable-stringify": { - "version": "1.0.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "jsonify": "0.0.0" - } - }, - "json-stringify-safe": { - "version": "5.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "jsonify": { - "version": "0.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "jsprim": { - "version": "1.4.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "assert-plus": "1.0.0", - "extsprintf": "1.0.2", - "json-schema": "0.2.3", - "verror": "1.3.6" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - } - } - }, - "mime-db": { - "version": "1.27.0", - "bundled": true, - "dev": true - }, - "mime-types": { - "version": "2.1.15", - "bundled": true, - "dev": true, - "requires": { - "mime-db": "1.27.0" - } - }, - "minimatch": { - "version": "3.0.4", - "bundled": true, - "dev": true, - "requires": { - "brace-expansion": "1.1.7" - } - }, - "minimist": { - "version": "0.0.8", - "bundled": true, - "dev": true - }, - "mkdirp": { - "version": "0.5.1", - "bundled": true, - "dev": true, - "requires": { - "minimist": "0.0.8" - } - }, - "ms": { - "version": "2.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "node-pre-gyp": { - "version": "0.6.36", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "mkdirp": "0.5.1", - "nopt": "4.0.1", - "npmlog": "4.1.0", - "rc": "1.2.1", - "request": "2.81.0", - "rimraf": "2.6.1", - "semver": "5.3.0", - "tar": "2.2.1", - "tar-pack": "3.4.0" - } - }, - "nopt": { - "version": "4.0.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "abbrev": "1.1.0", - "osenv": "0.1.4" - } - }, - "npmlog": { - "version": "4.1.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "are-we-there-yet": "1.1.4", - "console-control-strings": "1.1.0", - "gauge": "2.7.4", - "set-blocking": "2.0.0" - } - }, - "number-is-nan": { - "version": "1.0.1", - "bundled": true, - "dev": true - }, - "oauth-sign": { - "version": "0.8.2", - "bundled": true, - "dev": true, - "optional": true - }, - "object-assign": { - "version": "4.1.1", - "bundled": true, - "dev": true, - "optional": true - }, - "once": { - "version": "1.4.0", - "bundled": true, - "dev": true, - "requires": { - "wrappy": "1.0.2" - } - }, - "os-homedir": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "os-tmpdir": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "osenv": { - "version": "0.1.4", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "os-homedir": "1.0.2", - "os-tmpdir": "1.0.2" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "bundled": true, - "dev": true - }, - "performance-now": { - "version": "0.2.0", - "bundled": true, - "dev": true, - "optional": true - }, - "process-nextick-args": { - "version": "1.0.7", - "bundled": true, - "dev": true - }, - "punycode": { - "version": "1.4.1", - "bundled": true, - "dev": true, - "optional": true - }, - "qs": { - "version": "6.4.0", - "bundled": true, - "dev": true, - "optional": true - }, - "rc": { - "version": "1.2.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "deep-extend": "0.4.2", - "ini": "1.3.4", - "minimist": "1.2.0", - "strip-json-comments": "2.0.1" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "bundled": true, - "dev": true, - "optional": true - } - } - }, - "readable-stream": { - "version": "2.2.9", - "bundled": true, - "dev": true, - "requires": { - "buffer-shims": "1.0.0", - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "string_decoder": "1.0.1", - "util-deprecate": "1.0.2" - } - }, - "request": { - "version": "2.81.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "aws-sign2": "0.6.0", - "aws4": "1.6.0", - "caseless": "0.12.0", - "combined-stream": "1.0.5", - "extend": "3.0.1", - "forever-agent": "0.6.1", - "form-data": "2.1.4", - "har-validator": "4.2.1", - "hawk": "3.1.3", - "http-signature": "1.1.1", - "is-typedarray": "1.0.0", - "isstream": "0.1.2", - "json-stringify-safe": "5.0.1", - "mime-types": "2.1.15", - "oauth-sign": "0.8.2", - "performance-now": "0.2.0", - "qs": "6.4.0", - "safe-buffer": "5.0.1", - "stringstream": "0.0.5", - "tough-cookie": "2.3.2", - "tunnel-agent": "0.6.0", - "uuid": "3.0.1" - } - }, - "rimraf": { - "version": "2.6.1", - "bundled": true, - "dev": true, - "requires": { - "glob": "7.1.2" - } - }, - "safe-buffer": { - "version": "5.0.1", - "bundled": true, - "dev": true - }, - "semver": { - "version": "5.3.0", - "bundled": true, - "dev": true, - "optional": true - }, - "set-blocking": { - "version": "2.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "signal-exit": { - "version": "3.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "sntp": { - "version": "1.0.9", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "hoek": "2.16.3" - } - }, - "sshpk": { - "version": "1.13.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "asn1": "0.2.3", - "assert-plus": "1.0.0", - "bcrypt-pbkdf": "1.0.1", - "dashdash": "1.14.1", - "ecc-jsbn": "0.1.1", - "getpass": "0.1.7", - "jodid25519": "1.0.2", - "jsbn": "0.1.1", - "tweetnacl": "0.14.5" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - } - } - }, - "string-width": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", - "strip-ansi": "3.0.1" - } - }, - "string_decoder": { - "version": "1.0.1", - "bundled": true, - "dev": true, - "requires": { - "safe-buffer": "5.0.1" - } - }, - "stringstream": { - "version": "0.0.5", - "bundled": true, - "dev": true, - "optional": true - }, - "strip-ansi": { - "version": "3.0.1", - "bundled": true, - "dev": true, - "requires": { - "ansi-regex": "2.1.1" - } - }, - "strip-json-comments": { - "version": "2.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "tar": { - "version": "2.2.1", - "bundled": true, - "dev": true, - "requires": { - "block-stream": "0.0.9", - "fstream": "1.0.11", - "inherits": "2.0.3" - } - }, - "tar-pack": { - "version": "3.4.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "debug": "2.6.8", - "fstream": "1.0.11", - "fstream-ignore": "1.0.5", - "once": "1.4.0", - "readable-stream": "2.2.9", - "rimraf": "2.6.1", - "tar": "2.2.1", - "uid-number": "0.0.6" - } - }, - "tough-cookie": { - "version": "2.3.2", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "punycode": "1.4.1" - } - }, - "tunnel-agent": { - "version": "0.6.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "safe-buffer": "5.0.1" - } - }, - "tweetnacl": { - "version": "0.14.5", - "bundled": true, - "dev": true, - "optional": true - }, - "uid-number": { - "version": "0.0.6", - "bundled": true, - "dev": true, - "optional": true - }, - "util-deprecate": { - "version": "1.0.2", - "bundled": true, - "dev": true - }, - "uuid": { - "version": "3.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "verror": { - "version": "1.3.6", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "extsprintf": "1.0.2" - } - }, - "wide-align": { - "version": "1.1.2", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "string-width": "1.0.2" - } - }, - "wrappy": { - "version": "1.0.2", - "bundled": true, - "dev": true - } - } - }, "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", diff --git a/package.json b/package.json index cbce42e2b..2cb48fea9 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "build": "node build/build.js", "docs": "cd docs && gitbook install && gitbook serve", "docs:deploy": "build/update-docs.sh", + "docs:serve": "cd docs && gitbook serve", "flow": "flow check", "lint": "eslint --ext js,vue src test flow build --ignore-path .gitignore", "lint:docs": "eslint --ext js,vue,md docs --ignore-path .gitignore", From e6d96bcd37679718219b62b3d2ca91e88f151f22 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 13:42:30 +0000 Subject: [PATCH 12/71] feat(docs): [to pt-br] translating using with vuex section --- docs/pt-br/guides/using-with-vuex.md | 101 ++++++++++++++------------- 1 file changed, 51 insertions(+), 50 deletions(-) diff --git a/docs/pt-br/guides/using-with-vuex.md b/docs/pt-br/guides/using-with-vuex.md index 08bdf6cfa..6975c9115 100644 --- a/docs/pt-br/guides/using-with-vuex.md +++ b/docs/pt-br/guides/using-with-vuex.md @@ -96,26 +96,25 @@ O que está acontecendo aqui? Primeiro contamos ao localVue que ele usará o Vue Em seguida, fazemos uma store mockada chamando o método `Vuex.Store` com os valores do mock. Nós apenas passamos as ações, já que é o que nos importa no momento. -The actions are [jest mock functions](https://facebook.github.io/jest/docs/en/mock-functions.html). These mock functions give us methods to assert whether the actions were called or not. +As ações são [funções de mock do Jest](https://facebook.github.io/jest/docs/en/mock-functions.html). Essas funções simuladas nos dão alguns métodos para verificar se as determinadas ações foram ou não chamadas. -We can then assert in our tests that the action stub was called when expected. +Então, podemos fazer a asserção nos nossos testes esperando que essas ações do Vuex foram chamadas no momento esperado. -Now the way we define the store might look a bit foreign to you. +A forma como definimos a store pode parecer um pouco estranha para você. -We’re using `beforeEach` to ensure we have a clean store before each test. `beforeEach` is a mocha hook that’s called before each test. In our test, we are reassigning the store variables value. If we didn’t do this, the mock functions would need to be automatically reset. It also lets us change the state in our tests, without it affecting later tests. +Nós usamos o `beforeEach` para garantir que teremos uma store limpa antes de cada teste. O `beforeEach` é um método gancho do Mocha que é chamado antes de cada teste. Em nosso teste, reatribuímos os valores da store. Se nós não fizessemos isso, as funções mockadas deveriam ser reiniciadas automaticamente. Esse método também permite que alteremos o estado nos testes sem que afete os testes posteriores, pois ele será redefinido entre esses testes. -The most important thing to note in this test is that **we create a mock Vuex store and then pass it to vue-test-utils**. +A coisa mais impotante a ser notada neste teste é que **criamos um mock da store e depois passamos ela para o vue-test-utils**. -Great, so now we can mock actions, let’s look at mocking getters. - -## Mocking Getters +Ótimo, agora que nós já conseguimos mockar as actions, vamos ver como mockars o getters. +## Mockando os getters ``` html @@ -124,34 +123,34 @@ import { mapGetters } from 'vuex' export default{ computed: mapGetters([ - 'clicks', - 'inputValue' + 'cliques', + 'valorDoInput' ]) } ``` -This is a fairly simple component. It renders the result of the getters `clicks` and `inputValue`. Again, we don’t really care about what those getters returns – just that the result of them is being rendered correctly. +Esse é um componente bastante simples, Ele mostra os resultados capturados pelos getters `cliques` e `valorDoInput`. Mais um vez, nós não importamos com o que esses getters retornam e o que fazem no seu interior, mas sim com o resultado que ele acarretará no componente a ser testado. -Let’s see the test: +Valos ver o teste do componente: ``` js import { shallow, createLocalVue } from 'vue-test-utils' import Vuex from 'vuex' -import Actions from '../../../src/components/Getters' +import GettersComponente from '../../../src/componentes/GettersComponente' const localVue = createLocalVue() localVue.use(Vuex) -describe('Getters.vue', () => { +describe('GettersComponente.vue', () => { let getters let store beforeEach(() => { getters = { - clicks: () => 2, - inputValue: () => 'input' + cliques: () => 2, + valorDoInput: () => 'input' } store = new Vuex.Store({ @@ -159,34 +158,35 @@ describe('Getters.vue', () => { }) }) - it('Renders state.inputValue in first p tag', () => { - const wrapper = shallow(Actions, { store, localVue }) + it('Renderiza o valor do input na primeira tag P', () => { + const wrapper = shallow(GettersComponente, { store, localVue }) const p = wrapper.find('p') - expect(p.text()).toBe(getters.inputValue()) + expect(p.text()).toBe(getters.valorDoInput()) }) - it('Renders state.clicks in second p tag', () => { - const wrapper = shallow(Actions, { store, localVue }) + it('Renderiza o valor de cliques na segunda tag P', () => { + const wrapper = shallow(GettersComponente, { store, localVue }) const p = wrapper.findAll('p').at(1) - expect(p.text()).toBe(getters.clicks().toString()) + expect(p.text()).toBe(getters.cliques().toString()) }) }) ``` -This test is similar to our actions test. We create a mock store before each test, pass it as an option when we call `shallow`, and assert that the value returned by our mock getters is being rendered. -This is great, but what if we want to check our getters are returning the correct part of our state? +Esse teste é bastante similar com nosso teste de actions. Criamos um mock da store antes de cada teste, passamos ele como uma opção do método `shallow`, e verificamos o valor retornado pelo getter, verificando se o mesmo foi renderizado no template do componente. -## Mocking with Modules +Isso é ótimo, mas se quisermos garantir que nossos getters estão retornando a parte correta do nosso state? -[Modules](https://vuex.vuejs.org/en/modules.html) are useful for separating out our store into manageable chunks. They also export getters. We can use these in our tests. +## Criando mocks com módulos -Let’s look at our component: +Os [módulos](https://vuex.vuejs.org/en/modules.html) são úteis para separar nossa store em partes gerenciáveis. Podemos usa-los em nossos testes. + +Dê uma olhada nesse nosso componente: ``` html @@ -196,70 +196,71 @@ import { mapActions, mapGetters } from 'vuex' export default{ methods: { ...mapActions([ - 'moduleActionClick' + 'cliqueEmModulo' ]) }, computed: mapGetters([ - 'moduleClicks' + 'cliquesModulo' ]) } ``` -Simple component that includes one action and one getter. -And the test: +Esse simples componente incluí uma ação e um getter. + +E seu teste fica assim: ``` js import { shallow, createLocalVue } from 'vue-test-utils' import Vuex from 'vuex' -import Modules from '../../../src/components/Modules' -import module from '../../../src/store/module' +import ModuloComponente from '../../../src/componentes/ModuloComponente' +import modulo from '../../../src/store/modulo' const localVue = createLocalVue() localVue.use(Vuex) -describe('Modules.vue', () => { +describe('ModuloComponente.vue', () => { let actions let state let store beforeEach(() => { state = { - module: { - clicks: 2 + modulo: { + cliques: 2 } } actions = { - moduleActionClick: jest.fn() + cliqueEmModulo: jest.fn() } store = new Vuex.Store({ state, actions, - getters: module.getters + getters: modulo.getters }) }) - it('calls store action moduleActionClick when button is clicked', () => { - const wrapper = shallow(Modules, { store, localVue }) + it('chama a ação cliqueEmModulo quand o botão é clicado', () => { + const wrapper = shallow(ModuloComponente, { store, localVue }) const button = wrapper.find('button') button.trigger('click') - expect(actions.moduleActionClick).toHaveBeenCalled() + expect(actions.cliqueEmModulo).toHaveBeenCalled() }) - it('Renders state.inputValue in first p tag', () => { - const wrapper = shallow(Modules, { store, localVue }) + it('Renderiza os cliques do state do módulo no primeiro P', () => { + const wrapper = shallow(ModuloComponente, { store, localVue }) const p = wrapper.find('p') - expect(p.text()).toBe(state.module.clicks.toString()) + expect(p.text()).toBe(state.modulo.cliques.toString()) }) }) ``` -### Resources +### Recursos -- [Example project for this guide](https://github.com/eddyerburgh/vue-test-utils-vuex-example) +- [Projeto de exemplo com essa configuração](https://github.com/eddyerburgh/vue-test-utils-vuex-example) - [localVue](../api/options.md#localvue) - [createLocalVue](../api/createLocalVue.md) From 07f7e00448be13af9cc3e470ee0c86d5df2e2308 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 13:56:31 +0000 Subject: [PATCH 13/71] feat(docs): [to pt-br] translating mount section --- docs/pt-br/api/mount.md | 56 +++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/docs/pt-br/api/mount.md b/docs/pt-br/api/mount.md index aaddd3e2f..b49b44e77 100644 --- a/docs/pt-br/api/mount.md +++ b/docs/pt-br/api/mount.md @@ -1,23 +1,23 @@ -# mount(component {, options}]) +# mount(componente {, opcoes}]) -- **Arguments:** +- **Argumentos:** - - `{Component} component` - - `{Object} options` + - `{Component} componente` + - `{Object} opcoes` -- **Returns:** `{Wrapper}` +- **Retorna:** `{Wrapper}` -- **Options:** +- **Opções:** -See [options](options.md) +Veja [opções](options.md) -- **Usage:** +- **Uso:** -Returns [`Wrapper`](wrapper/README.md) of first DOM node or Vue component matching selector. +Retorna um [`Wrapper`](wrapper/README.md) do primeiro elemento do DOM ou o componente Vue correspondente ao seletor. -Use any valid [selector](selectors.md). +Use qualquer [seletor](selectors.md) válido. -**Without options:** +**Sem opções:** ```js import { mount } from 'vue-test-utils' @@ -25,13 +25,14 @@ import { expect } from 'chai' import Foo from './Foo.vue' describe('Foo', () => { - it('renders a div', () => { + it('renderiza uma div', () => { const wrapper = mount(Foo) expect(wrapper.contains('div')).toBe(true) }) }) ``` -**With Vue options:** + +**Com opções do Vue:** ```js import { mount } from 'vue-test-utils' @@ -39,18 +40,18 @@ import { expect } from 'chai' import Foo from './Foo.vue' describe('Foo', () => { - it('renders a div', () => { + it('verifica valor padrão da cor', () => { const wrapper = mount(Foo, { propsData: { - color: 'red' + cor: 'vermelha' } }) - expect(wrapper.hasProp('color', 'red')).toBe(true) + expect(wrapper.hasProp('cor', 'vermelha')).toBe(true) }) }) ``` -**Attach to DOM:** +**Anexar ao DOM:** ```js import { mount } from 'vue-test-utils' @@ -58,7 +59,7 @@ import { expect } from 'chai' import Foo from './Foo.vue' describe('Foo', () => { - it('renders a div', () => { + it('adiciona variável ao DOM', () => { const wrapper = mount(Foo, { attachToDocument: true }) @@ -66,7 +67,8 @@ describe('Foo', () => { }) }) ``` -**Default and named slots:** + +**Com slots padrões ou nomeados:** ```js import { mount } from 'vue-test-utils' @@ -76,11 +78,11 @@ import Bar from './Bar.vue' import FooBar from './FooBar.vue' describe('Foo', () => { - it('renders a div', () => { + it('registra slots padrões e nomeados', () => { const wrapper = mount(Foo, { slots: { default: [Bar, FooBar], - fooBar: FooBar, // Will match , + fooBar: FooBar, // Corresponde a , foo: '
' } }) @@ -89,7 +91,7 @@ describe('Foo', () => { }) ``` -**Stubbing global properties:** +**Adicionando propriedades globais:** ```js import { mount } from 'vue-test-utils' @@ -97,8 +99,8 @@ import { expect } from 'chai' import Foo from './Foo.vue' describe('Foo', () => { - it('renders a div', () => { - const $route = { path: 'http://www.example-path.com' } + it('adicionando mock global do $route', () => { + const $route = { path: 'http://www.meusite.com.br' } const wrapper = mount(Foo, { mocks: { $route @@ -109,7 +111,7 @@ describe('Foo', () => { }) ``` -**Stubbing components:** +**Esboçando componentes filhos:** ```js import { mount } from 'vue-test-utils' @@ -119,7 +121,7 @@ import Bar from './Bar.vue' import Faz from './Faz.vue' describe('Foo', () => { - it('renders a div', () => { + it('verifica componentes filhos de Foo', () => { const wrapper = mount(Foo, { stub: { Bar: '
, + fooBar: FooBar, // Corresponde a , foo: '
' } }) @@ -103,7 +103,7 @@ describe('Foo', () => { }) ``` -**Stubbing global properties:** +**Adicionando propriedades globais:** ```js import { shallow } from 'vue-test-utils' @@ -111,8 +111,8 @@ import { expect } from 'chai' import Foo from './Foo.vue' describe('Foo', () => { - it('renders a div', () => { - const $route = { path: 'http://www.example-path.com' } + it('adicionando mock global do $route', () => { + const $route = { path: 'http://www.meusite.com.br' } const wrapper = shallow(Foo, { mocks: { $route From 0ae800597d61a4a4814fc36500d0be354dedce74 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 14:20:33 +0000 Subject: [PATCH 15/71] feat(docs): [to pt-br] translating options section --- docs/pt-br/api/options.md | 80 +++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/docs/pt-br/api/options.md b/docs/pt-br/api/options.md index 862992dae..8648efe0b 100644 --- a/docs/pt-br/api/options.md +++ b/docs/pt-br/api/options.md @@ -1,10 +1,10 @@ -# Mounting Options +# Opções de mongatem -Options for `mount` and `shallow`. The options object can contain both `vue-test-utils` mounting options and raw Vue options. +As opções são usadas nos métodos `mount` e `shallow`. O objeto de opções pode conter as opções de montagem do `vue-test-utils` e também as opções do Vue. -Vue options are passed to the component when a new instance is created. , e.g. `store`, `propsData`. For a full list, see the [Vue API docs](https://vuejs.org/v2/api/). +As opções do Vue são passadas para o componente quando uma nova instância é criada, por exemplo `store`, `propsData`. Para ver a lista completa de opções veja a [API do Vue](https://vuejs.org/v2/api/). -## `vue-test-utils` Specific Mounting Options +## Opções de montagem específicas do `vue-test-utils` - [context](#context) - [slots](#slots) @@ -18,29 +18,29 @@ Vue options are passed to the component when a new instance is created. , e.g. ` ### `context` -- type: `Object` +- tipo: `Object` -Passes context to functional component. Can only be used with functional components. +Passa o contexto ao componente funcional. Só pode ser usado com componentes funcionais. -Example: +Exemplo: ```js -const wrapper = mount(Component, { +const wrapper = mount(Componente, { context: { props: { show: true } } }) -expect(wrapper.is(Component)).toBe(true) +expect(wrapper.is(Componente)).toBe(true) ``` ### `slots` -- type: `{ [name: string]: Array|Component|string }` +- tipo: `{ [name: string]: Array|Component|string }` -Provide an object of slot contents to the component. The key corresponds to the slot name. The value can be either a component, an array of components, or a template string. +Forneça um objeto do slot para o componente. A chave corresponde ao nome do slot. O valor pode ser um componentem um array de componentes ou uma template string. -Example: +Exemplo: ```js import { expect } from 'chai' @@ -50,7 +50,7 @@ import Bar from './Bar.vue' const wrapper = shallow(Component, { slots: { default: [Foo, Bar], - fooBar: Foo, // Will match , + fooBar: Foo, // Corresponde a , foo: '
' } }) @@ -59,41 +59,41 @@ expect(wrapper.find('div')).toBe(true) ### `stubs` -- type: `{ [name: string]: Component | boolean } | Array` +- tipo: `{ [name: string]: Component | boolean } | Array` -Stubs child components. Can be an Array of component names to stub, or an object. +Esboça os componentes filhos. Pode ser um array com os nomes dos componentes ou um objeto. -Example: +Exemplo: ```js import Foo from './Foo.vue' mount(Component, { - stubs: ['registered-component'] + stubs: ['componente-registrado'] }) shallow(Component, { stubs: { - // stub with a specific implementation - 'registered-component': Foo, - // create default stub - 'another-component': true + // esboço com uma implementação específica + 'componente-registrado': Foo, + // criar um esboço padrão (mockado) + 'outro componente': true } }) ``` ### `mocks` -- type: `Object` +- tipo: `Object` -Add additional properties to the instance. Useful for mocking global injections. +Adiciona uma propriedade adicional à instância. Ótimo para mockar injeções globais. -Example: +Exemplo: ```js import { expect } from 'chai' -const $route = { path: 'http://www.example-path.com' } +const $route = { path: 'http://www.meusite.com.br' } const wrapper = shallow(Component, { mocks: { $route @@ -104,11 +104,11 @@ expect(wrapper.vm.$route.path).toBe($route.path) ### `localVue` -- type: `Vue` +- tipo: `Vue` -A local copy of Vue created by [createLocalVue](./createLocalVue.md) to use when mounting the component. Installing plugins on this copy of Vue prevents polluting the original `Vue` copy. +Uma cópia local do Vue é criada pelo [createLocalVue](./createLocalVue.md) para usar quando for montar um componente. A instalação de plugins e outros nessa cópia previne que seu Vue original seja poluído. -Example: +Exemplo: ```js import { createLocalVue, mount } from 'vue-test-utils' @@ -136,30 +136,30 @@ expect(wrapper.vm.$route).toBeInstanceOf(Object) ### `attachToDocument` -- type: `boolean` -- default: `false` +- tipo: `boolean` +- padrão: `false` -Component will be attach to DOM when rendered if set to `true`. This can be used with [`hasStyle`](wrapper/hasStyle.md) to check multi element CSS selectors. +O componente será anexado ao DOM quando configurado como `true`. Isso pode ser usado com o [`hasStyle`](wrapper/hasStyle.md) para verificar os seletores do CSS de vários elementos. ### `attrs` -- type: `Object` +- tipo: `Object` -Set the component instance's `$attrs` object. +Define o objeto `$attrs` da instância do componente. ### `listeners` -- type: `Object` +- tipo: `Object` -Set the component instance's `$listeners` object. +Define o objeto `$listeners` da instância do componente. ### `clone` -- type: `boolean` -- default: `true` +- tipo: `boolean` +- padrão: `true` -Clones component before mounting if `true`, which avoids mutating the original component definition. +Clona o componente antes de monta-lo se o valor for `true`, evitando qualquer mutação no componente original. -`options.mocks` (`Object`): Add globals to Vue instance. +`options.mocks` (`Object`): Adiciona variáveis global à instância do Vue. -`options.localVue` (`Object`): vue class to use in `mount`. See [createLocalVue](createLocalVue.md) +`options.localVue` (`Object`): classe do Vue usada no método `mount`. Veja [createLocalVue](createLocalVue.md) From 4a2925c6d72483e1b72504903bc9545508e43aad Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 14:28:36 +0000 Subject: [PATCH 16/71] feat(docs): [to pt-br] translating readme wrapper section --- docs/pt-br/README.md | 2 +- docs/pt-br/SUMMARY.md | 2 +- docs/pt-br/api/README.md | 2 +- docs/pt-br/api/wrapper/README.md | 21 +++++++++++---------- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/docs/pt-br/README.md b/docs/pt-br/README.md index b75cdba1e..19c3deeaa 100644 --- a/docs/pt-br/README.md +++ b/docs/pt-br/README.md @@ -26,7 +26,7 @@ - [attrs](api/options.md#attrs) - [listeners](api/options.md#listeners) - [clone](api/options.md#clone) - * [Wrapper](api/wrapper/README.md) + * [Wrapper (embrulho)](api/wrapper/README.md) * [contains](api/wrapper/contains.md) * [emitted](api/wrapper/emitted.md) * [emittedByOrder](api/wrapper/emittedByOrder.md) diff --git a/docs/pt-br/SUMMARY.md b/docs/pt-br/SUMMARY.md index 48116aa5d..fd634df78 100644 --- a/docs/pt-br/SUMMARY.md +++ b/docs/pt-br/SUMMARY.md @@ -22,7 +22,7 @@ - [attrs](api/options.md#attrs) - [listeners](api/options.md#listeners) - [clone](api/options.md#clone) - * [Wrapper](api/wrapper/README.md) + * [Wrapper (embrulho)](api/wrapper/README.md) * [contains](api/wrapper/contains.md) * [emitted](api/wrapper/emitted.md) * [emittedByOrder](api/wrapper/emittedByOrder.md) diff --git a/docs/pt-br/api/README.md b/docs/pt-br/api/README.md index 6941e1a63..df2c2a1de 100644 --- a/docs/pt-br/api/README.md +++ b/docs/pt-br/api/README.md @@ -12,7 +12,7 @@ - [attrs](./options.md#attrs) - [listeners](./options.md#listeners) - [clone](./options.md#clone) -* [Wrapper](./wrapper/README.md) +* [Wrapper (embrulho)](./wrapper/README.md) * [contains](./wrapper/contains.md) * [emitted](./wrapper/emitted.md) * [emittedByOrder](./wrapper/emittedByOrder.md) diff --git a/docs/pt-br/api/wrapper/README.md b/docs/pt-br/api/wrapper/README.md index 6469b8745..f4a2739e6 100644 --- a/docs/pt-br/api/wrapper/README.md +++ b/docs/pt-br/api/wrapper/README.md @@ -1,16 +1,17 @@ -# Wrapper +# Wrapper (embrulho) -vue-test-utils is a wrapper based API. +vue-test-utils é uma API baseada em *wrapper*. -A `Wrapper` is an object that contains a mounted component or vnode and methods to test the component or vnode. +Um `Wrapper` é um objeto que contém um componente montado ou um vnode e alguns métodos para testar esse item envelopado. -- **Properties:** +- **Propriedades:** -`vm` `Component`: this is the vue instance. You can access all the [instance methods and properties of a vm](https://vuejs.org/v2/api/#Instance-Properties) with `wrapper.vm`. This only exists on Vue component wrappers -`element` `HTMLElement`: the root DOM node of the wrapper -`options` `Object`: Object containing vue-test-utils options passed to `mount` or `shallow` -`options.attachedToDom` `Boolean`: True if attachToDom was passed to `mount` or `shallow` +`vm` `Component`: é uma instância Vue. Você pode acessar todos os [métodos de instância e propriedades de um vm](https://vuejs.org/v2/api/#Instance-Properties) com o `wrapper.vm`. Ela só exite em embrulhos de componentes Vue. -- **Methods:** +`element` `HTMLElement`: elemento raiz do DOM do embrulho. -There is a detailed list of methods in the wrapper section of the docs. +`options` `Object`: Objeto que contém as opções do vue-test-utils para ser passado para o `mount` ou `shallow`. + +- **Métodos:** + +Exite uma lista detalhada de métodos na seção Wrapper dessa documentação. From d2318223682c813f0fad081467b9887759053a34 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 14:50:41 +0000 Subject: [PATCH 17/71] feat(docs): [to pt-br] translating wrapper contains section --- docs/pt-br/api/wrapper/contains.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/pt-br/api/wrapper/contains.md b/docs/pt-br/api/wrapper/contains.md index a91b0353b..dce339b87 100644 --- a/docs/pt-br/api/wrapper/contains.md +++ b/docs/pt-br/api/wrapper/contains.md @@ -1,13 +1,13 @@ -# contains(selector) +# contains(seletor) -Assert `Wrapper` contains an element or component matching [selector](../selectors.md). +Verifica se o embrulho contém um elemento ou componente com o [seletor](../selectors.md) informado. -- **Arguments:** - - `{string|Component} selector` +- **Argumentos:** + - `{string|Component} seletor` -- **Returns:** `{boolean}` +- **Retorna:** `{boolean}` -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' @@ -20,4 +20,4 @@ expect(wrapper.contains('p')).toBe(true) expect(wrapper.contains(Bar)).toBe(true) ``` -- **See also:** [selectors](../selectors.md) +- **Veja também:** [seletores](../selectors.md) From 6bb0a390043ef3ace16b24a8a38d85991fc9d49d Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 14:52:33 +0000 Subject: [PATCH 18/71] feat(docs): [to pt-br] translating wrapper emitted section --- docs/pt-br/api/wrapper/emitted.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/pt-br/api/wrapper/emitted.md b/docs/pt-br/api/wrapper/emitted.md index d754eab98..a7026d68a 100644 --- a/docs/pt-br/api/wrapper/emitted.md +++ b/docs/pt-br/api/wrapper/emitted.md @@ -1,33 +1,33 @@ # emitted() -Return an object containing custom events emitted by the `Wrapper` `vm`. +Retorna um objeto contendo os eventos cutomizados emitidos pelo `vm` do embrulho wrapper. -- **Returns:** `{ [name: string]: Array> }` +- **Retorna:** `{ [name: string]: Array> }` -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' import { expect } from 'chai' -const wrapper = mount(Component) +const wrapper = mount(Componente) wrapper.vm.$emit('foo') wrapper.vm.$emit('foo', 123) /* -wrapper.emitted() returns the following object: +wrapper.emitted() retorna o seguinte objeto: { foo: [[], [123]] } */ -// assert event has been emitted +// Verifica se o evento foi emitido expect(wrapper.emitted().foo).toBeTruthy() -// assert event count +// Verifica aquantidade de emissões do evento expect(wrapper.emitted().foo.length).toBe(2) -// assert event payload +// Verifica a carga do segundo evento foo emitido expect(wrapper.emitted().foo[1]).toEqual([123]) ``` From 941e4c331d0583ed2413a1a60a8f3bd1c8a1a715 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 14:54:08 +0000 Subject: [PATCH 19/71] feat(docs): [to pt-br] translating wrapper emittedByOrder section --- docs/pt-br/api/wrapper/emittedByOrder.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/pt-br/api/wrapper/emittedByOrder.md b/docs/pt-br/api/wrapper/emittedByOrder.md index 55ff975b2..47f81d503 100644 --- a/docs/pt-br/api/wrapper/emittedByOrder.md +++ b/docs/pt-br/api/wrapper/emittedByOrder.md @@ -1,10 +1,10 @@ # emittedByOrder() -Return an Array containing custom events emitted by the `Wrapper` `vm`. +Retorna um array contendo os eventos customizados emitidos pelo `vm` do embrulho wrapper. -- **Returns:** `Array<{ name: string, args: Array }>` +- **Retorna:** `Array<{ name: string, args: Array }>` -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' @@ -16,13 +16,13 @@ wrapper.vm.$emit('foo') wrapper.vm.$emit('bar', 123) /* -wrapper.emittedByOrder() returns the following Array: +wrapper.emittedByOrder() retorna o seguinte array: [ { name: 'foo', args: [] }, { name: 'bar', args: [123] } ] */ -// assert event emit order +// Verifica a ordem dos eventos chamados expect(wrapper.emittedByOrder().map(e => e.name)).toEqual(['foo', 'bar']) ``` From f59cb0b7c8ac36df078117663b700b6727a7a93c Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 14:56:08 +0000 Subject: [PATCH 20/71] feat(docs): [to pt-br] translating wrapper find section --- docs/pt-br/api/wrapper/find.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/docs/pt-br/api/wrapper/find.md b/docs/pt-br/api/wrapper/find.md index 1d121c591..f1c4155d2 100644 --- a/docs/pt-br/api/wrapper/find.md +++ b/docs/pt-br/api/wrapper/find.md @@ -1,15 +1,15 @@ -# find(selector) +# find(seletor) -Returns [`Wrapper`](README.md) of first DOM node or Vue component matching selector. +Retorna um embrulho [`Wrapper`](README.md) com o primeiro elmento do DOM ou o componente Vue encontrado a partir do seletor -Use any valid [selector](../selectors.md). +Use any valiUse qualquer [seletor](../selectors.md) válido. -- **Arguments:** - - `{string|Component} selector` +- **Argumentos:** + - `{string|Component} seletor` -- **Returns:** `{Wrapper}` +- **Retorna:** `{Wrapper}` -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' @@ -18,10 +18,12 @@ import Foo from './Foo.vue' import Bar from './Bar.vue' const wrapper = mount(Foo) + const div = wrapper.find('div') expect(div.is('div')).toBe(true) + const bar = wrapper.find(Bar) expect(bar.is(Bar)).toBe(true) ``` -- **See also:** [Wrapper](README.md) +- **Veja também:** [Wrapper](README.md) From d8e49588ec82be0c817d7a7d3c28ba4fe5ac9f8e Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 14:57:23 +0000 Subject: [PATCH 21/71] feat(docs): [to pt-br] translating wrapper findAll section --- docs/pt-br/api/wrapper/findAll.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/docs/pt-br/api/wrapper/findAll.md b/docs/pt-br/api/wrapper/findAll.md index f78ab6201..f8a96571a 100644 --- a/docs/pt-br/api/wrapper/findAll.md +++ b/docs/pt-br/api/wrapper/findAll.md @@ -1,15 +1,15 @@ -# findAll(selector) +# findAll(seletor) -Returns a [`WrapperArray`](../wrapper-array/README.md) of [Wrappers](README.md). +Retorna um [`WrapperArray`](../wrapper-array/README.md) de [Wrappers](README.md). -Use any valid [selector](../selectors.md). +Use qualquer [seletor](../selectors.md) válido. -- **Arguments:** - - `{string|Component} selector` +- **Argumentos:** + - `{string|Component} seletor` -- **Returns:** `{WrapperArray}` +- **Retorna:** `{WrapperArray}` -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' @@ -18,10 +18,12 @@ import Foo from './Foo.vue' import Bar from './Bar.vue' const wrapper = mount(Foo) + const div = wrapper.findAll('div').at(0) expect(div.is('div')).toBe(true) + const bar = wrapper.findAll(Bar).at(0) expect(bar.is(Bar)).toBe(true) ``` -- **See also:** [Wrapper](README.md) +- **Veja também:** [Wrapper](README.md) From 48d02cdc282f17c42bad42b76b3a141ca15c354b Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 15:01:28 +0000 Subject: [PATCH 22/71] feat(docs): [to pt-br] translating wrapper hasAttribute section --- docs/pt-br/api/wrapper/hasAttribute.md | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/docs/pt-br/api/wrapper/hasAttribute.md b/docs/pt-br/api/wrapper/hasAttribute.md index da9a893b5..efc77cda9 100644 --- a/docs/pt-br/api/wrapper/hasAttribute.md +++ b/docs/pt-br/api/wrapper/hasAttribute.md @@ -1,29 +1,30 @@ -# hasAttribute(attribute, value) +# hasAttribute(atributo, valor) -Assert `Wrapper` DOM node has attribute matching value. +Verifica se o embrulho Wrapper contém o atributo mencionado no seu elemento do DOM. -Returns `true` if `Wrapper` DOM node contains attribute with matching value. +Retorna `true` se o embrulho contém o atributo. -- **Arguments:** - - `{string} attribute` - - `{string} value` +- **Argumentos:** + - `{string} atributo` + - `{string} valor` -- **Returns:** `{boolean}` +- **Retorna:** `{boolean}` -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' import { expect } from 'chai' import Foo from './Foo.vue' +// Exemplo
...
const wrapper = mount(Foo) expect(wrapper.hasAttribute('id', 'foo')).toBe(true) ``` -- **Alternative:** +- **Alternativa:** -You could get the attribute from the `Wrapper.element` to have a value based assertion: +Você poderia obter o atributo do `Wrapper.element` para então verificar baseado no valor retornado: ```js import { mount } from 'vue-test-utils' @@ -34,4 +35,4 @@ const wrapper = mount(Foo) expect(wrapper.element.getAttribute('id')).toBe('foo') ``` -This makes for a more informative assertion error. +Isso faz com que o erro da asserção sejá mais informativo. From 7ade7d5755847422d4dd19d2875392bc3f232b41 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 15:04:12 +0000 Subject: [PATCH 23/71] feat(docs): [to pt-br] translating wrapper hasClass section --- docs/pt-br/api/wrapper/hasClass.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/pt-br/api/wrapper/hasClass.md b/docs/pt-br/api/wrapper/hasClass.md index c70b21ef9..ede6d4e4e 100644 --- a/docs/pt-br/api/wrapper/hasClass.md +++ b/docs/pt-br/api/wrapper/hasClass.md @@ -1,15 +1,15 @@ -# hasClass(className) +# hasClass(nomeDaClasse) -Assert `Wrapper` DOM node has class contains `className`. +Verifica se o embrulho do elemento do DOM contém uma classe informada pelo `nomeDaClasse`. -Returns `true` if `Wrapper` DOM node contains class. +Retorna `true` se o wrapper contém a classe. -- **Arguments:** - - `{string} className` +- **Argumentos:** + - `{string} nomeDaClasse` -- **Returns:** `{boolean}` +- **Retorna:** `{boolean}` -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' From 3324044e36ab215c0330ff2dc9289a4f481b9892 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 15:06:42 +0000 Subject: [PATCH 24/71] feat(docs): [to pt-br] translating wrapper hasProp section --- docs/pt-br/api/wrapper/hasProp.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/docs/pt-br/api/wrapper/hasProp.md b/docs/pt-br/api/wrapper/hasProp.md index 66e64b41b..2d617a05d 100644 --- a/docs/pt-br/api/wrapper/hasProp.md +++ b/docs/pt-br/api/wrapper/hasProp.md @@ -1,19 +1,18 @@ -# hasProp(prop, value) +# hasProp(propriedade, valor) -Assert `Wrapper` `vm` has `prop` matching `value`. +Verifica se o `vm` do embrulho possui uma pripriedade com o valor definido. -Returns `true` if `Wrapper` `vm` has `prop` matching `value`. +Retorna `true` se o `vm` do wrapper tem a `propriedade` com o `valor` passado. +**Nota: o wrapper deve conter uma instância do Vue.** -**Note: the Wrapper must contain a Vue instance.** +- **Argumentos:** + - `{string} propriedade` + - `{any} valor` -- **Arguments:** - - `{string} prop` - - `{any} value` +- **Retorna:** `{boolean}` -- **Returns:** `{boolean}` - -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' From 5e60fbf6f4185ecd5e4ed77c8563f2b70db386f8 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 15:08:49 +0000 Subject: [PATCH 25/71] feat(docs): [to pt-br] translating wrapper hasStyle section --- docs/pt-br/api/wrapper/hasStyle.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/pt-br/api/wrapper/hasStyle.md b/docs/pt-br/api/wrapper/hasStyle.md index 0281d8401..127efb7c5 100644 --- a/docs/pt-br/api/wrapper/hasStyle.md +++ b/docs/pt-br/api/wrapper/hasStyle.md @@ -1,18 +1,18 @@ -# hasStyle(style, value) +# hasStyle(estilo, valor) -Assert `Wrapper` DOM node has style matching value +Verifica se o elemento do DOM do embrulho possui uma propriedade de estilo com esse valor. -Returns `true` if `Wrapper` DOM node has `style` matching `value`. +Retorna `true` se o wrapper possui um `estilo` com o `valor`. -**Note will only detect inline styles when running in `jsdom`.** +**Nota: só iremos detectar os estilos quando executado com o `jsdom`.** -- **Arguments:** - - `{string} style` - - `{string} value` +- **Argumentos:** + - `{string} estilo` + - `{string} valor` -- **Returns:** `{boolean}` +- **Retorna:** `{boolean}` -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' From aa8d4d1d715fe77037215bffccda6a00c593bd5c Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 15:09:47 +0000 Subject: [PATCH 26/71] feat(docs): [to pt-br] translating wrapper html section --- docs/pt-br/api/wrapper/html.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/pt-br/api/wrapper/html.md b/docs/pt-br/api/wrapper/html.md index 1243f180f..652f1fcb6 100644 --- a/docs/pt-br/api/wrapper/html.md +++ b/docs/pt-br/api/wrapper/html.md @@ -1,10 +1,10 @@ # html() -Returns HTML of `Wrapper` DOM node as a string. +Retorna o HTML do elemento do embrulho como uma string. -- **Returns:** `{string}` +- **Retorna:** `{string}` -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' From 7d653fe63e3788eee19e06fa57255602aff7ac7a Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 15:10:53 +0000 Subject: [PATCH 27/71] feat(docs): [to pt-br] translating wrapper is section --- docs/pt-br/api/wrapper/is.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/pt-br/api/wrapper/is.md b/docs/pt-br/api/wrapper/is.md index 2987de1a2..e29cd8c8c 100644 --- a/docs/pt-br/api/wrapper/is.md +++ b/docs/pt-br/api/wrapper/is.md @@ -1,13 +1,13 @@ -# is(selector) +# is(seletor) -Assert `Wrapper` DOM node or `vm` matches [selector](../selectors.md). +Verifica se o `vm` do wrapper possui o [seletor](../selectors.md) informado. -- **Arguments:** - - `{string|Component} selector` +- **Argumentos:** + - `{string|Component} seletor` -- **Returns:** `{boolean}` +- **Retorna:** `{boolean}` -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' From abbd97f388c025fae09c3b266b5915208a1f37ac Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 15:11:51 +0000 Subject: [PATCH 28/71] feat(docs): [to pt-br] translating wrapper isEmpty section --- docs/pt-br/api/wrapper/isEmpty.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/pt-br/api/wrapper/isEmpty.md b/docs/pt-br/api/wrapper/isEmpty.md index d70fe7140..6438e5d36 100644 --- a/docs/pt-br/api/wrapper/isEmpty.md +++ b/docs/pt-br/api/wrapper/isEmpty.md @@ -1,10 +1,10 @@ # isEmpty() -Assert `Wrapper` does not contain child node. +Verifica se o embrulho não contem elementos filhos. -- **Returns:** `{boolean}` +- **Retorna:** `{boolean}` -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' From 0e58ba87f72da02402c011825a5758febfab1a06 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 15:12:56 +0000 Subject: [PATCH 29/71] feat(docs): [to pt-br] translating wrapper isVueInstance section --- docs/pt-br/api/wrapper/isVueInstance.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/pt-br/api/wrapper/isVueInstance.md b/docs/pt-br/api/wrapper/isVueInstance.md index 9da12a267..2cb4cdac3 100644 --- a/docs/pt-br/api/wrapper/isVueInstance.md +++ b/docs/pt-br/api/wrapper/isVueInstance.md @@ -1,10 +1,10 @@ # isVueInstance() -Assert `Wrapper` is Vue instance. +Verifica se o embrulho é uma intância do Vue. -- **Returns:** `{boolean}` +- **Retorna:** `{boolean}` -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' From cff9d1cc732167f222f992c870d74de0ce3722f2 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 15:14:50 +0000 Subject: [PATCH 30/71] feat(docs): [to pt-br] translating wrapper name section --- docs/pt-br/api/wrapper/name.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/pt-br/api/wrapper/name.md b/docs/pt-br/api/wrapper/name.md index a1faf1b4f..1f2d95e62 100644 --- a/docs/pt-br/api/wrapper/name.md +++ b/docs/pt-br/api/wrapper/name.md @@ -1,10 +1,10 @@ # name() -Returns component name if `Wrapper` contains a Vue instance, or the tag name of `Wrapper` DOM node if `Wrapper` does not contain a Vue instance. +Retorna o nome do componente se o embrulho for uma instância do Vue, ou então o nome da tag se o embrulho for um elemento do DOM e não for uma instância do Vue. -- **Returns:** `{string}` +- **Retorna:** `{string}` -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' From e8284bd255d83af67750eca8680092586e2adc6a Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 15:18:26 +0000 Subject: [PATCH 31/71] feat(docs): [to pt-br] translating wrapper setComputed section --- docs/pt-br/api/wrapper/setComputed.md | 34 +++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/docs/pt-br/api/wrapper/setComputed.md b/docs/pt-br/api/wrapper/setComputed.md index b5db5549e..6d4a82e37 100644 --- a/docs/pt-br/api/wrapper/setComputed.md +++ b/docs/pt-br/api/wrapper/setComputed.md @@ -1,43 +1,43 @@ -# setComputed(computedProperties) +# setComputed(propriedadesComputadas) -Sets `Wrapper` `vm` computed property and forces update. +Define as propriedades computadas do `vm` do embrulho e força a sua atualização. -**Note the Wrapper must contain a Vue instance.** -**Note every Vue instance must already have the computed properties passed to setComputed.** +**Nota: o wrapper deve ser uma instância do Vue.** +**Nota2: a instância já deve ter as propriedades computadas passadas para o setComputed declaradas.** -- **Arguments:** - - `{Object} computed properties` +- **Argumentos:** + - `{Object} propriedadesComputadas` -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' import { expect } from 'chai' const wrapper = mount({ - template: '
{{ computed1 }} {{ computed2 }}
', + template: '
{{ propriedade1 }} {{ propriedade2 }}
', data () { return { - initial: 'initial' + inicial: 'inicial' } }, computed: { - computed1 () { - return this.initial + propriedade1 () { + return this.inicial }, - computed2 () { - return this.initial + propriedade2 () { + return this.inicial } } }) -expect(wrapper.html()).toBe('
initial initial
') +expect(wrapper.html()).toBe('
inicial inicial
') wrapper.setComputed({ - computed1: 'new-computed1', - computed2: 'new-computed2' + propriedade1: 'nova-propriedade1', + propriedade2: 'nova-propriedade2' }) -expect(wrapper.html()).toBe('
new-computed1 new-computed2
') +expect(wrapper.html()).toBe('
nova-propriedade1 nova-propriedade2
') ``` From 9834851966f03af1d15fc99e0a317a6d57873796 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 15:19:30 +0000 Subject: [PATCH 32/71] feat(docs): [to pt-br] translating wrapper setData section --- docs/pt-br/api/wrapper/setData.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/pt-br/api/wrapper/setData.md b/docs/pt-br/api/wrapper/setData.md index 608f083f4..7b4e15f4d 100644 --- a/docs/pt-br/api/wrapper/setData.md +++ b/docs/pt-br/api/wrapper/setData.md @@ -1,13 +1,13 @@ -# setData(data) +# setData(dados) -Sets `Wrapper` `vm` data and forces update. +Define os dados do `vm` do embrulho e força a sua atualização. -**Note the Wrapper must contain a Vue instance.** +**Nota: o wrapper deve ser uma instância do Vue.** -- **Arguments:** - - `{Object} data` +- **Argumentos:** + - `{Object} dados` -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' From 5f1d01c67b8b7d47472db01bb6b619e9ce9fe5c6 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 15:21:27 +0000 Subject: [PATCH 33/71] feat(docs): [to pt-br] translating wrapper setMethods section --- docs/pt-br/api/wrapper/setMethods.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/pt-br/api/wrapper/setMethods.md b/docs/pt-br/api/wrapper/setMethods.md index 4a40546ee..389c68401 100644 --- a/docs/pt-br/api/wrapper/setMethods.md +++ b/docs/pt-br/api/wrapper/setMethods.md @@ -1,13 +1,13 @@ -# setMethods(methods) +# setMethods(metodos) -Sets `Wrapper` `vm` methods and forces update. +Define os métodos do `vm` do embrulho e força sua atualização. -**Note the Wrapper must contain a Vue instance.** +**Nota: o wrapper deve ser uma instância do Vue.** -- **Arguments:** - - `{Object} methods` +- **Argumentos:** + - `{Object} metodos` -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' @@ -16,9 +16,9 @@ import sinon from 'sinon' import Foo from './Foo.vue' const wrapper = mount(Foo) -const clickMethodStub = sinon.stub() +const mockClique = sinon.stub() -wrapper.setMethods({ clickMethod: clickMethodStub }) +wrapper.setMethods({ metodoClique: mockClique }) wrapper.find('button').trigger('click') -expect(clickMethodStub.called).toBe(true) +expect(mockClique.called).toBe(true) ``` From a18c872c32bc8115057a2ba9d778bcff6080127e Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 15:23:58 +0000 Subject: [PATCH 34/71] feat(docs): [to pt-br] translating wrapper setProps section --- docs/pt-br/api/wrapper/setProps.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/pt-br/api/wrapper/setProps.md b/docs/pt-br/api/wrapper/setProps.md index 7a55124c4..9f84b89af 100644 --- a/docs/pt-br/api/wrapper/setProps.md +++ b/docs/pt-br/api/wrapper/setProps.md @@ -1,13 +1,13 @@ -# setProps(props) +# setProps(propriedades) -- **Arguments:** - - `{Object} props` +Define as propriedades do `vm` do embrulho e força sua atualização. -- **Usage:** +**Nota: o wrapper deve ser uma instância do Vue.** -Sets `Wrapper` `vm` props and forces update. +- **Argumentos:** + - `{Object} propriedades` -**Note the Wrapper must contain a Vue instance.** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' @@ -19,7 +19,7 @@ wrapper.setProps({ foo: 'bar' }) expect(wrapper.vm.foo).to.equal('bar') ``` -You can also pass a `propsData` object, which will initialize the Vue instance with passed values. +Além disso, você pode passar o objeto `propsData`, que irá inicializar a instância do Vue com os valores passados. ``` js // Foo.vue From 3fbea3165276510901d1b278d218031990aa68ec Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 15:25:01 +0000 Subject: [PATCH 35/71] feat(docs): [to pt-br] translating wrapper text section --- docs/pt-br/api/wrapper/text.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/pt-br/api/wrapper/text.md b/docs/pt-br/api/wrapper/text.md index d1ccd4b44..a94c321a0 100644 --- a/docs/pt-br/api/wrapper/text.md +++ b/docs/pt-br/api/wrapper/text.md @@ -1,10 +1,10 @@ # text() -Returns text content of `Wrapper`. +Retorna o texto contido no embrulho. -- **Returns:** `{string}` +- **Retorna:** `{string}` -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' From e3cc69a74cc5f5b069a01f7e2921831031d3c3f0 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 15:30:06 +0000 Subject: [PATCH 36/71] feat(docs): [to pt-br] translating wrapper trigger section --- docs/pt-br/api/wrapper/trigger.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/pt-br/api/wrapper/trigger.md b/docs/pt-br/api/wrapper/trigger.md index 537cda9e6..371767d53 100644 --- a/docs/pt-br/api/wrapper/trigger.md +++ b/docs/pt-br/api/wrapper/trigger.md @@ -1,17 +1,17 @@ -# trigger(eventName) +# trigger(nomeDoEvento {, opcoes}]) -Triggers an event on the `Wrapper` DOM node. +Aciona um evento do elemento do embrulho. -Trigger takes an optional `options` object. The properties in the `options` object are added to the Event. +O método `trigger` usa o objeto opicional `opcoes`, essas opções serão adicionadas ao evento. -You can run preventDefault on the event by passing `preventDefault: true` in `options`. +Você pode rodar o preventDefault em um evento passando `preventDefault: true` no objeto de `opcoes`. -- **Arguments:** - - `{string} eventName` - - `{Object} options` +- **Argumentos:** + - `{string} nomeDoEvento` + - `{Object} opcoes` - `{boolean} preventDefault` -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' @@ -19,15 +19,15 @@ import { expect } from 'chai' import sinon from 'sinon' import Foo from './Foo' -const clickHandler = sinon.stub() +const eventoClique = sinon.stub() const wrapper = mount(Foo, { - propsData: { clickHandler } + propsData: { eventoClique } }) wrapper.trigger('click') wrapper.trigger('click', { - button: 0 + botao: 0 }) wrapper.trigger('click', { From a6d131304b4fa8d33edf7612a18672c55c4809e7 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 15:31:34 +0000 Subject: [PATCH 37/71] feat(docs): [to pt-br] translating wrapper update section --- docs/pt-br/api/wrapper/update.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/pt-br/api/wrapper/update.md b/docs/pt-br/api/wrapper/update.md index 15d13be89..e1f5f9098 100644 --- a/docs/pt-br/api/wrapper/update.md +++ b/docs/pt-br/api/wrapper/update.md @@ -1,10 +1,10 @@ # update() -Force root Vue component to re-render. +Força o componente Vue a ser redesenhado. -If called on a `Wrapper` containing a `vm`, it will force the `Wrapper` `vm` to re-render. +Se você chamar esse método em um embrulho que contém `vm`, ele forçará o `vm` do wrapper a se redesenhar. -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' @@ -13,7 +13,7 @@ import Foo from './Foo.vue' const wrapper = mount(Foo) expect(wrapper.vm.bar).toBe('bar') -wrapper.vm.bar = 'new value' +wrapper.vm.bar = 'novo valor' wrapper.update() -expect(wrapper.vm.bar).toBe('new value') +expect(wrapper.vm.bar).toBe('novo valor') ``` From 5e8574a5526c84a9c5b5b7507cd1a6d94aff502e Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 15:42:44 +0000 Subject: [PATCH 38/71] feat(docs): [to pt-br] translating wrapper destroy section --- docs/pt-br/api/wrapper-array/destroy.md | 2 +- docs/pt-br/api/wrapper/destroy.md | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/pt-br/api/wrapper-array/destroy.md b/docs/pt-br/api/wrapper-array/destroy.md index 875936ecb..82483f5ea 100644 --- a/docs/pt-br/api/wrapper-array/destroy.md +++ b/docs/pt-br/api/wrapper-array/destroy.md @@ -10,9 +10,9 @@ import { expect } from 'chai' import Foo from './Foo.vue' const wrapper = mount(Foo) + const divArray = wrapper.findAll('div') expect(divArray.contains('p')).toBe(true) divArray.destroy() expect(divArray.contains('p')).toBe(false) - ``` diff --git a/docs/pt-br/api/wrapper/destroy.md b/docs/pt-br/api/wrapper/destroy.md index 015d5a5ea..8f943729a 100644 --- a/docs/pt-br/api/wrapper/destroy.md +++ b/docs/pt-br/api/wrapper/destroy.md @@ -1,8 +1,8 @@ # destroy() -Destroys a Vue component instance. +Destroí a instância do componente Vue. -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' @@ -10,11 +10,13 @@ import { expect } from 'chai' import sinon from 'sinon' const spy = sinon.stub() + mount({ render: null, destroyed () { spy() } }).destroy() + expect(spy.calledOnce).to.equal(true) ``` From f9a0991fa973cb9e9b32d726c40fd33da670ced5 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 15:44:11 +0000 Subject: [PATCH 39/71] feat(docs): [to pt-br] translating wrapperarray readme section --- docs/pt-br/api/wrapper-array/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/pt-br/api/wrapper-array/README.md b/docs/pt-br/api/wrapper-array/README.md index 2a6d40ccc..bd177f7f8 100644 --- a/docs/pt-br/api/wrapper-array/README.md +++ b/docs/pt-br/api/wrapper-array/README.md @@ -1,11 +1,11 @@ -# WrapperArray +# WrapperArray (array de embrulhos) -A `WrapperArray` is an object that contains an array of [Wrappers](../wrapper/README.md), and methods to test the `Wrappers`. +Um array de embrulhos é um objeto que contem uma lista com [Wrappers](../wrapper/README.md), e os alguns métodos para testar esses embrulhos. -- **Properties:** +- **Propriedades:** -`length` `number`: the number of `Wrappers` contained in the `WrapperArray` +`length` `number`: O número de embrulhos contidos nesse array. - - **Methods:** +- **Métodos:** -There is a detailed list of methods in the WrapperArray section of the docs. +Nessa documentação você tem uma lista detalhada dos métodos apresentados na seção WrapperArray. From 4cac91366732ee56566dd7746f7eec31fb5df844 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 15:46:03 +0000 Subject: [PATCH 40/71] feat(docs): [to pt-br] translating wrapperarray at section --- docs/pt-br/api/wrapper-array/at.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/docs/pt-br/api/wrapper-array/at.md b/docs/pt-br/api/wrapper-array/at.md index e5864bf1b..ba5f3b8ca 100644 --- a/docs/pt-br/api/wrapper-array/at.md +++ b/docs/pt-br/api/wrapper-array/at.md @@ -1,13 +1,13 @@ -# at(index) +# at(indice) -Returns `Wrapper` at `index` passed. Uses zero based numbering (i.e. first item is at index 0). +Retorna o embrulho correspondente ao `indice` passado. Use números para corresponder ao item do arra, por exemplo o `indice` 0 para o primeiro elemento. -- **Arguments:** - - `{number} index` +- **Argumentos:** + - `{number} indice` -- **Returns:** `{Wrapper}` +- **Retorna:** `{Wrapper}` -- **Example:** +- **Exemplo:** ```js import { shallow } from 'vue-test-utils' @@ -16,6 +16,7 @@ import Foo from './Foo.vue' const wrapper = shallow(Foo) const divArray = wrapper.findAll('div') -const secondDiv = divArray.at(1) -expect(secondDiv.is('p')).toBe(true) + +const segundaDiv = divArray.at(1) +expect(segundaDiv.is('p')).toBe(true) ``` From 918ad1eb9754bb9296b144cef1c40156d7128aad Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 15:47:25 +0000 Subject: [PATCH 41/71] feat(docs): [to pt-br] translating wrapperarray contains section --- docs/pt-br/api/wrapper-array/contains.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/pt-br/api/wrapper-array/contains.md b/docs/pt-br/api/wrapper-array/contains.md index 3b5ee31de..744358508 100644 --- a/docs/pt-br/api/wrapper-array/contains.md +++ b/docs/pt-br/api/wrapper-array/contains.md @@ -1,15 +1,15 @@ -# contains(selector) +# contains(seletor) -Assert every wrapper in `WrapperArray` contains selector. +Verifica se cada embrulho do array contém correspondência do seletor informado. -Use any valid [selector](../selectors.md). +Use qualquer [seletor](../selectors.md) válido. -- **Arguments:** - - `{string|Component} selector` +- **Argumentos:** + - `{string|Component} seletor` -- **Returns:** `{boolean}` +- **Retorna:** `{boolean}` -- **Example:** +- **Exemplo:** ```js import { shallow } from 'vue-test-utils' @@ -19,6 +19,7 @@ import Bar from './Bar.vue' const wrapper = shallow(Foo) const divArray = wrapper.findAll('div') + expect(divArray.contains('p')).toBe(true) expect(divArray.contains(Bar)).toBe(true) ``` From 8d6eb5656e264e31c0037281d019c1b977678e51 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 15:48:40 +0000 Subject: [PATCH 42/71] feat(docs): [to pt-br] translating wrapperarray hasAttribute section --- docs/pt-br/api/wrapper-array/hasAttribute.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/pt-br/api/wrapper-array/hasAttribute.md b/docs/pt-br/api/wrapper-array/hasAttribute.md index b3436edc9..5dd620706 100644 --- a/docs/pt-br/api/wrapper-array/hasAttribute.md +++ b/docs/pt-br/api/wrapper-array/hasAttribute.md @@ -1,14 +1,14 @@ -# hasAttribute(attribute, value) +# hasAttribute(atributo, valor) -Assert every `Wrapper` in `WrapperArray` DOM node has `attribute` matching `value`. +Verifica se algum embrulho do array tem o `atributo` com `valor` correspondente no elemento do DOM. -- **Arguments:** - - `{string} attribute` - - `{string} value` +- **Argumentos:** + - `{string} atributo` + - `{string} valor` -- **Returns:** `{boolean}` +- **Retorna:** `{boolean}` -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' @@ -17,5 +17,6 @@ import Foo from './Foo.vue' const wrapper = mount(Foo) const divArray = wrapper.findAll('div') + expect(divArray.hasAttribute('id', 'foo')).toBe(true) ``` From 49a8064d6f97d0aed4342cf6ae43f0882f610235 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 15:50:04 +0000 Subject: [PATCH 43/71] feat(docs): [to pt-br] translating wrapperarray hasClass section --- docs/pt-br/api/wrapper-array/hasClass.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/pt-br/api/wrapper-array/hasClass.md b/docs/pt-br/api/wrapper-array/hasClass.md index b4c48b397..8a4622e4c 100644 --- a/docs/pt-br/api/wrapper-array/hasClass.md +++ b/docs/pt-br/api/wrapper-array/hasClass.md @@ -1,13 +1,13 @@ -# hasClass(className) +# hasClass(nomeDaClasse) -Assert every `Wrapper` in `WrapperArray` DOM node has class containing `className`. +Verifica se algum embrulho do array contém uma classe com o nome `nomeDaClasse` no elemento do DOM. -- **Arguments:** - - `{string} className` +- **Argumentos:** + - `{string} nomeDaClasse` -- **Returns:** `{boolean}` +- **Retorna:** `{boolean}` -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' @@ -16,5 +16,6 @@ import Foo from './Foo.vue' const wrapper = mount(Foo) const divArray = wrapper.findAll('div') + expect(divArray.hasClass('bar')).toBe(true) ``` From 394c8f580ef2ca17e3c82c3dda6362571198c1aa Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 15:51:36 +0000 Subject: [PATCH 44/71] feat(docs): [to pt-br] translating wrapperarray hasProp section --- docs/pt-br/api/wrapper-array/hasProp.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/docs/pt-br/api/wrapper-array/hasProp.md b/docs/pt-br/api/wrapper-array/hasProp.md index 6ce255fd7..d960788f8 100644 --- a/docs/pt-br/api/wrapper-array/hasProp.md +++ b/docs/pt-br/api/wrapper-array/hasProp.md @@ -1,16 +1,16 @@ -# hasProp(prop, value) +# hasProp(propriedade, valor) -Assert every `Wrapper` in `WrapperArray` `vm` has `prop` matching `value`. +Verifica se algum embrulho do array possui a `propriedade` com o `valor` no `vm`. -**Note the Wrapper must contain a Vue instance.** +**Nota: o wrapper deve ser uma intância do Vue.** -- **Arguments:** - - `{string} prop` - - `{any} value` +- **Argumentos:** + - `{string} propriedade` + - `{any} valor` -- **Returns:** `{boolean}` +- **Retorna:** `{boolean}` -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' @@ -20,5 +20,6 @@ import Bar from './Bar.vue' const wrapper = mount(Foo) const barArray = wrapper.findAll(Bar) + expect(barArray.hasProp('bar', 10)).toBe(true) ``` From 7336700a8ca76497e2dacbeae2a51db1c4df46c9 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 15:53:33 +0000 Subject: [PATCH 45/71] feat(docs): [to pt-br] translating wrapperarray hasStyle section --- docs/pt-br/api/wrapper-array/hasStyle.md | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/docs/pt-br/api/wrapper-array/hasStyle.md b/docs/pt-br/api/wrapper-array/hasStyle.md index 56a8843fa..a3aac4d20 100644 --- a/docs/pt-br/api/wrapper-array/hasStyle.md +++ b/docs/pt-br/api/wrapper-array/hasStyle.md @@ -1,17 +1,18 @@ -# hasStyle(style, value) +# hasStyle(estilo, valor) -Assert every `Wrapper` in `WrapperArray` DOM node has style matching value. +Verifica se algum embrulho do array tem o `estilo` com o `valor` no elemento do DOM. -Returns `true` if `Wrapper` DOM node has `style` matching `value`. +Retorna `true` se o embrulho contém o `estilo` com o `valor`. -**Note will only detect inline styles when running in `jsdom`.** -- **Arguments:** - - `{string} style` - - `{string} value` +**Nota: para detectarmos os estilos deve-se usar o `jsdom`.** -- **Returns:** `{boolean}` +- **Argumentos:** + - `{string} estilo` + - `{string} valor` -- **Example:** +- **Retorna:** `{boolean}` + +- **Exemplo:** ```js import { mount } from 'vue-test-utils' @@ -20,5 +21,6 @@ import Foo from './Foo.vue' const wrapper = mount(Foo) const divArray = wrapper.findAll('div') -expect(divArray.hasStyle('color', 'red')).toBe(true) + +expect(divArray.hasStyle('cor', 'vermelha')).toBe(true) ``` From 5ed7f5757cb03f0b490525a3b40217b2843735d0 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 15:54:45 +0000 Subject: [PATCH 46/71] feat(docs): [to pt-br] translating wrapperarray is section --- docs/pt-br/api/wrapper-array/is.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/pt-br/api/wrapper-array/is.md b/docs/pt-br/api/wrapper-array/is.md index 8a5a7cb7a..0264bd492 100644 --- a/docs/pt-br/api/wrapper-array/is.md +++ b/docs/pt-br/api/wrapper-array/is.md @@ -1,13 +1,13 @@ -# is(selector) +# is(seletor) -Assert every `Wrapper` in `WrapperArray` DOM node or `vm` matches [selector](../selectors.md). +Verifica se algum embrulho do array possui o [seletor](../selectors.md) no seu `vm`. -- **Arguments:** - - `{string|Component} selector` +- **Argumentos:** + - `{string|Component} seletor` -- **Returns:** `{boolean}` +- **Retorna:** `{boolean}` -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' @@ -16,5 +16,6 @@ import Foo from './Foo.vue' const wrapper = mount(Foo) const divArray = wrapper.find('div') + expect(divArray.is('div')).toBe(true) ``` From 260759cef5a4f4211ac85fea802f36a1ce35ef3a Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 15:55:40 +0000 Subject: [PATCH 47/71] feat(docs): [to pt-br] translating wrapperarray isEmpty section --- docs/pt-br/api/wrapper-array/isEmpty.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/pt-br/api/wrapper-array/isEmpty.md b/docs/pt-br/api/wrapper-array/isEmpty.md index 6ef8b4145..491165bf4 100644 --- a/docs/pt-br/api/wrapper-array/isEmpty.md +++ b/docs/pt-br/api/wrapper-array/isEmpty.md @@ -1,10 +1,10 @@ # isEmpty() -Assert every `Wrapper` in `WrapperArray` does not contain child node. +Verifica se algum embrulho do array não tem um elemento filho. -- **Returns:** `{boolean}` +- **Retorna:** `{boolean}` -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' @@ -13,5 +13,6 @@ import Foo from './Foo.vue' const wrapper = mount(Foo) const divArray = wrapper.findAll('div') + expect(divArray.isEmpty()).toBe(true) ``` From 2f3fcc2a7ec5c18820d89f881747f7aef2f68fcd Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 15:56:32 +0000 Subject: [PATCH 48/71] feat(docs): [to pt-br] translating wrapperarray isVueInstance section --- docs/pt-br/api/wrapper-array/isVueInstance.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/pt-br/api/wrapper-array/isVueInstance.md b/docs/pt-br/api/wrapper-array/isVueInstance.md index 66d556b7f..68ff84b48 100644 --- a/docs/pt-br/api/wrapper-array/isVueInstance.md +++ b/docs/pt-br/api/wrapper-array/isVueInstance.md @@ -1,10 +1,10 @@ # isVueInstance() -Assert every `Wrapper` in `WrapperArray` is Vue instance. +Verifica se algum embrulho do array é uma instância do Vue. -- **Returns:** `{boolean}` +- **Retorna:** `{boolean}` -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' @@ -14,5 +14,6 @@ import Bar from './Bar.vue' const wrapper = mount(Foo) const barArray = wrapper.findAll(Bar) + expect(barArray.isVueInstance()).toBe(true) ``` From b7c494b3449ca1d963a1636a3fb25e638caffd90 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 15:58:58 +0000 Subject: [PATCH 49/71] feat(docs): [to pt-br] translating wrapperarray setComputed section --- docs/pt-br/api/wrapper-array/setComputed.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/docs/pt-br/api/wrapper-array/setComputed.md b/docs/pt-br/api/wrapper-array/setComputed.md index 7531132cf..af289a198 100644 --- a/docs/pt-br/api/wrapper-array/setComputed.md +++ b/docs/pt-br/api/wrapper-array/setComputed.md @@ -1,15 +1,14 @@ +# setComputed(propriedadesComputadas) -# setComputed(computedObjects) +Define as propriedades computadas e força a atualização de cada um dos embrulhos no array. -Sets `Wrapper` `vm` computed and forces update on each `Wrapper` in `WrapperArray`. +**Nota: cada embrulho deve ser uma instância do Vue.** +**Nota2: cada instância de cada embrulho deve ter as propriedades computadas já declaradas, pois esse método apenas mocka o seu valor.** -**Note every `Wrapper` must contain a Vue instance.** -**Note every Vue instance must already have the computed properties passed to setComputed.** +- **Argumentos:** + - `{Object} propriedadesComputadass` -- **Arguments:** - - `{Object} computed properties` - -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' @@ -20,7 +19,7 @@ const wrapper = mount(Foo) const barArray = wrapper.findAll(Bar) barArray.setComputed({ - computed1: 'new-computed1', - computed2: 'new-computed2' + propriedade1: 'nova-propriedade1', + propriedade2: 'nova-propriedade2' }) ``` From ae1a267fdefba791276253be10012e7e56fdcfb6 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 16:00:18 +0000 Subject: [PATCH 50/71] feat(docs): [to pt-br] translating wrapperarray setData section --- docs/pt-br/api/wrapper-array/setData.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/pt-br/api/wrapper-array/setData.md b/docs/pt-br/api/wrapper-array/setData.md index f4f69bf61..05a643b16 100644 --- a/docs/pt-br/api/wrapper-array/setData.md +++ b/docs/pt-br/api/wrapper-array/setData.md @@ -1,13 +1,13 @@ -# setData(data) +# setData(dados) -Sets `Wrapper` `vm` data and forces update on each `Wrapper` in `WrapperArray`. +Define os dados e força a atualização de cada embrulho presente no array. -**Note every `Wrapper` must contain a Vue instance.** +**Nota: cada embrulho deve ser uma instância do Vue.** -- **Arguments:** - - `{Object} data` +- **Argumentos:** + - `{Object} dados` -- **Example:** +- **Exemplho:** ```js import { mount } from 'vue-test-utils' @@ -17,6 +17,7 @@ import Bar from './Bar.vue' const wrapper = mount(Foo) const barArray = wrapper.findAll(Bar) + barArray.setData({ foo: 'bar' }) expect(barArray.at(0).vm.foo).toBe('bar') ``` From a72cd4e9376b4c8e9c073d3878ec1a3f851b4cc6 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 16:02:06 +0000 Subject: [PATCH 51/71] feat(docs): [to pt-br] translating wrapperarray setMethods section --- docs/pt-br/api/wrapper-array/setMethods.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/docs/pt-br/api/wrapper-array/setMethods.md b/docs/pt-br/api/wrapper-array/setMethods.md index 5d50927ae..3da8e740d 100644 --- a/docs/pt-br/api/wrapper-array/setMethods.md +++ b/docs/pt-br/api/wrapper-array/setMethods.md @@ -1,14 +1,13 @@ +# setMethods(metodos) -# setMethods(methods) +Define os métodos do componente e força sua atualização para cada embrulho no array. -Sets `Wrapper` `vm` methods and forces update on each `Wrapper` in `WrapperArray`. +**Nota: cada embrulho deve ser uma instância do Vue.** -**Note every `Wrapper` must contain a Vue instance.** +- **Argumentos:** + - `{Object} metodos` -- **Arguments:** - - `{Object} methods` - -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' @@ -19,9 +18,9 @@ import Bar from './Bar.vue' const wrapper = mount(Foo) const barArray = wrapper.findAll(Bar) -const clickMethodStub = sinon.stub() +const mockClique = sinon.stub() -barArray.setMethods({ clickMethod: clickMethodStub }) +barArray.setMethods({ methodoClique: mockClique }) barArray.at(0).trigger('click') -expect(clickMethodStub.called).toBe(true) +expect(mockClique.called).toBe(true) ``` From 4a2449352c91aceb751e0594797e18c48a411208 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 16:03:13 +0000 Subject: [PATCH 52/71] feat(docs): [to pt-br] translating wrapperarray setProps section --- docs/pt-br/api/wrapper-array/setProps.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/pt-br/api/wrapper-array/setProps.md b/docs/pt-br/api/wrapper-array/setProps.md index c68e84f1d..0cd53f01a 100644 --- a/docs/pt-br/api/wrapper-array/setProps.md +++ b/docs/pt-br/api/wrapper-array/setProps.md @@ -1,13 +1,13 @@ -# setProps(props) +# setProps(propriedades) -Sets `Wrapper` `vm` props and forces update on each `Wrapper` in `WrapperArray`. +Define as `propriedades` do componente e força sua atualização para cada embrulho no array. -**Note every `Wrapper` must contain a Vue instance.** +**Nota: cada embrulho deve ser uma instância do Vue.** -- **Arguments:** - - `{Object} props` +- **Argumentos:** + - `{Object} propriedades` -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' @@ -17,6 +17,7 @@ import Bar from './Bar.vue' const wrapper = mount(Foo) const barArray = wrapper.findAll(Bar) + barArray.setProps({ foo: 'bar' }) expect(barArray.at(0).vm.foo).toBe('bar') ``` From 02730905dd76e1443f9da9e0206f0f4eca74c236 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 16:04:49 +0000 Subject: [PATCH 53/71] feat(docs): [to pt-br] translating wrapperarray triggers section --- docs/pt-br/api/wrapper-array/trigger.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/docs/pt-br/api/wrapper-array/trigger.md b/docs/pt-br/api/wrapper-array/trigger.md index 5ffdb7423..90819beca 100644 --- a/docs/pt-br/api/wrapper-array/trigger.md +++ b/docs/pt-br/api/wrapper-array/trigger.md @@ -1,13 +1,13 @@ -# trigger(eventName) +# trigger(nomeDoEvento) -Triggers an event on every `Wrapper` in the `WrapperArray` DOM node. +Aciona um evento no elemeto do DOM de cada embrulho no array. -**Note every `Wrapper` must contain a Vue instance.** +**Nota: cada embrulho deve ser uma instância do Vue.** -- **Arguments:** - - `{string} eventName` +- **Argumentos:** + - `{string} nomeDoEvento` -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' @@ -15,12 +15,13 @@ import { expect } from 'chai' import sinon from 'sinon' import Foo from './Foo.vue' -const clickHandler = sinon.stub() +const mockDoClique = sinon.stub() const wrapper = mount(Foo, { - propsData: { clickHandler } + propsData: { mockDoClique } }) const divArray = wrapper.findAll('div') divArray.trigger('click') -expect(clickHandler.called).toBe(true) + +expect(mockDoClique.called).toBe(true) ``` From 6a9573c2c1607fed03f7822c98260215343304a5 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 16:06:53 +0000 Subject: [PATCH 54/71] feat(docs): [to pt-br] translating wrapperarray update section --- docs/pt-br/api/wrapper-array/update.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/pt-br/api/wrapper-array/update.md b/docs/pt-br/api/wrapper-array/update.md index de0647028..f3d1ea5cf 100644 --- a/docs/pt-br/api/wrapper-array/update.md +++ b/docs/pt-br/api/wrapper-array/update.md @@ -1,10 +1,10 @@ # update() -Force root Vue component of each `Wrapper` in `WrapperArray` to re-render. +Força a atualização e redesenho do componente Vue de cada embrulho do array. -If called on a Vue component wrapper array, it will force each Vue component to re-render. +Se for chamado a partir de um componente Vue, força a atualização de cada componente do array. -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' @@ -13,8 +13,10 @@ import Foo from './Foo.vue' const wrapper = mount(Foo) const divArray = wrapper.findAll('div') + expect(divArray.at(0).vm.bar).toBe('bar') -divArray.at(0).vm.bar = 'new value' +divArray.at(0).vm.bar = 'novo valor' divArray.update() -expect(divArray.at(0).vm.bar).toBe('new value') + +expect(divArray.at(0).vm.bar).toBe('novo valor') ``` From 40d4665dd7ac725575e65e81149a5d06c94f34df Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 16:09:15 +0000 Subject: [PATCH 55/71] feat(docs): [to pt-br] translating wrapperarray destroy section --- docs/pt-br/api/wrapper-array/destroy.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/pt-br/api/wrapper-array/destroy.md b/docs/pt-br/api/wrapper-array/destroy.md index 82483f5ea..495140c44 100644 --- a/docs/pt-br/api/wrapper-array/destroy.md +++ b/docs/pt-br/api/wrapper-array/destroy.md @@ -1,8 +1,8 @@ # destroy() -Destroys each Vue `Wrapper` in `WrapperArray`. +Destroí a instância do Vue da cada um dos embrulhos do array. -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' @@ -14,5 +14,6 @@ const wrapper = mount(Foo) const divArray = wrapper.findAll('div') expect(divArray.contains('p')).toBe(true) divArray.destroy() + expect(divArray.contains('p')).toBe(false) ``` From 01cc393e8896e21532119a05beb4db4407f2e1e0 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 16:12:13 +0000 Subject: [PATCH 56/71] feat(docs): [to pt-br] translating components readme section --- docs/pt-br/api/components/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/pt-br/api/components/README.md b/docs/pt-br/api/components/README.md index b6db0b05b..9fe182248 100644 --- a/docs/pt-br/api/components/README.md +++ b/docs/pt-br/api/components/README.md @@ -1,5 +1,5 @@ -# Components +# Componentes -vue-test-utils includes utility components you can use to stub components. +O vue-test-utils apresenta alguns componentes utilitários para que você possa esboçar componentes. -[TransitionStub](./TransitionStub.md) and [TransitionGroupStub](./TransitionGroupStub.md) are used to stub `transition` and `transition-group` components by default. You can edit the stubs by editing the config. +O [TransitionStub](./TransitionStub.md) e o [TransitionGroupStub](./TransitionGroupStub.md) por padrão são usados para esboçar componentes de transições e grupo de transições. Mas você pode editar esses esboços editando as configurações do mesmo. From ae44b17ab8a9c83290aad1a591a1bc3b3ebe4889 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 16:16:44 +0000 Subject: [PATCH 57/71] feat(docs): [to pt-br] translating components transition stub section --- docs/pt-br/api/components/TransitionStub.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/pt-br/api/components/TransitionStub.md b/docs/pt-br/api/components/TransitionStub.md index 8a11d34eb..fc3b7d337 100644 --- a/docs/pt-br/api/components/TransitionStub.md +++ b/docs/pt-br/api/components/TransitionStub.md @@ -1,8 +1,8 @@ -# TransitionStub +# TransitionStub (esboço de transição) -A component to stub the `transition` wrapper component. Instead of performing transitions asynchronously, it returns the child component synchronously. +É um componente para substtuir o componente `transition`. Em vez de executar as transições de forma assíncrona, ele retorna o componente filho de forma síncrona. -This is set to stub all `transition` components by default in the vue-test-utils config. To use the built-in `transition` wrapper component set `config.stubs.transition` to false: +Por padrão é configurado para trocar todos os componentes `transitions` da sua aplicação. Para desativar o componente `transition`, passe `config.stubs.transition` para false: ```js import VueTestUtils from 'vue-test-utils' @@ -10,14 +10,15 @@ import VueTestUtils from 'vue-test-utils' VueTestUtils.config.stubs.transition = false ``` -To reset it to stub transition components: +Para redefini-lo como componente de transição, use: + ```js import VueTestUtils, { TransitionStub } from 'vue-test-utils' VueTestUtils.config.stubs.transition = TransitionStub ``` -To set it as a stub in mounting options: +Para configura-lo como um stub nas opções de montagem, use: ```js import { mount, TransitionStub } from 'vue-test-utils' From aa3aa12472ace67e615efdfcde3d8f70a788783c Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 16:19:49 +0000 Subject: [PATCH 58/71] feat(docs): [to pt-br] translating components transition group stub section --- docs/pt-br/api/components/TransitionGroupStub.md | 13 +++++++------ docs/pt-br/api/components/TransitionStub.md | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/pt-br/api/components/TransitionGroupStub.md b/docs/pt-br/api/components/TransitionGroupStub.md index f7061f5c3..3103812ef 100644 --- a/docs/pt-br/api/components/TransitionGroupStub.md +++ b/docs/pt-br/api/components/TransitionGroupStub.md @@ -1,23 +1,24 @@ -# TransitionGroupStub +# TransitionGroupStub (Esboço de grupo de transições) -A component to stub the `transition-group` wrapper component. Instead of performing transitions asynchronously, it returns the child components synchronously. +É um componente para substituir o componente `transition-group`. Em vez de executar as transições do grupo de forma assíncrona, ele retorna os componentes filhos de forma síncrona. -This is set to stub all `transition-group` components by default in the vue-test-utils config. To use the built-in `transition-group` wrapper component set `config.stubs[transition-group]` to false: +Por padrão é configurado para trocar todos os componentes `transitions-group` da sua aplicação. Para desativar o componente `transition-group`, passe `config.stubs['transition-group']` para false: ```js import VueTestUtils from 'vue-test-utils' -VueTestUtils.config.stubs.transition = false +VueTestUtils.config.stubs['transition-group'] = false ``` -To reset it to stub transition components: +Para redefinir os grupos de transições no stub, use: + ```js import VueTestUtils, { TransitionGroupStub } from 'vue-test-utils' VueTestUtils.config.stubs['transition-group'] = TransitionGroupStub ``` -To set it as a stub in mounting options: +Para configura-lo na montagem, use: ```js import { mount, TransitionGroupStub } from 'vue-test-utils' diff --git a/docs/pt-br/api/components/TransitionStub.md b/docs/pt-br/api/components/TransitionStub.md index fc3b7d337..9ca07cb9b 100644 --- a/docs/pt-br/api/components/TransitionStub.md +++ b/docs/pt-br/api/components/TransitionStub.md @@ -1,6 +1,6 @@ # TransitionStub (esboço de transição) -É um componente para substtuir o componente `transition`. Em vez de executar as transições de forma assíncrona, ele retorna o componente filho de forma síncrona. +É um componente para substituir o componente `transition`. Em vez de executar as transições de forma assíncrona, ele retorna o componente filho de forma síncrona. Por padrão é configurado para trocar todos os componentes `transitions` da sua aplicação. Para desativar o componente `transition`, passe `config.stubs.transition` para false: From 99859f292c0b0cfce7dbc5e36faf3f809e5283ae Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 16:25:19 +0000 Subject: [PATCH 59/71] feat(docs): [to pt-br] translating components selectors section --- docs/pt-br/api/selectors.md | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/docs/pt-br/api/selectors.md b/docs/pt-br/api/selectors.md index 0c6a47f3b..168581ba5 100644 --- a/docs/pt-br/api/selectors.md +++ b/docs/pt-br/api/selectors.md @@ -1,35 +1,35 @@ -# Selectors +# Seletores -A lot of methods take a selector as an argument. A selector can either be a CSS selector, or a Vue component. +Muitos métodos desse wrapper leval um seletor como argumento. Um seletor pode ser um seletor CSS ou um componente do Vue. -## CSS Selectors +## Seletores CSS -mount handles any valid CSS selector: +O método `mount` controla e suporta qualquer seletor válido: -- tag selectors (div, foo, bar) -- class selectors (.foo, .bar) -- attribute selectors ([foo], [foo="bar"]) -- id selectors (#foo, #bar) -- pseudo selectors (div:first-of-type) +- seletores de tag (div, foo, bar) +- seletores de classes (.foo, .bar) +- seletores de atributos ([foo], [foo="bar"]) +- seletores de ids (#foo, #bar) +- pseudo seletores (div:first-of-type) -You can also use combinators: +Você também pode usar qualquer combinação: -- direct descendant combinator (div > #bar > .foo) -- general descendant combinator (div #bar .foo) -- adjacent sibling selector (div + .foo) -- general sibling selector (div ~ .foo) +- combinador de descendente direto (div > #bar > .foo) +- combinador de descendente geral (div #bar .foo) +- seletor de irmão adjacente (div + .foo) +- seletor geral de irmãos (div ~ .foo) -## Vue Components +## Componentes do Vue -Vue components are also valid selectors. +Os componentes do Vue também são seletores válidos. -vue-test-utils uses the `name` property to search the instance tree for matching Vue components. +O vue-test-utils usa a propriedade `name` para buscar a instância na árvore de componentes do Vue. ```js // Foo.vue export default{ - name: 'FooComponent' + name: 'FooComponente' } ``` From ba9757dc307c743fe1f35a169053729e48bd1826 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 16:27:32 +0000 Subject: [PATCH 60/71] feat(docs): [to pt-br] translating components localVue section --- docs/pt-br/api/createLocalVue.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/docs/pt-br/api/createLocalVue.md b/docs/pt-br/api/createLocalVue.md index a3cbfcee3..e735e3864 100644 --- a/docs/pt-br/api/createLocalVue.md +++ b/docs/pt-br/api/createLocalVue.md @@ -1,13 +1,13 @@ # createLocalVue() -- **Returns:** +- **Retorna:** - `{Component}` -- **Usage:** +- **Uso:** -`createLocalVue` returns a Vue class for you to add components, mixins and install plugins without polluting the global Vue class. +O `createLocalVue` retorna uma classe do Vue para que você possa adicionar componentes, mixins e plugins sem poluir sua classe global do Vue. -Use it with `options.localVue` +Usando com o `options.localVue` ```js import { createLocalVue, shallow } from 'vue-test-utils' @@ -19,10 +19,12 @@ const wrapper = shallow(Foo, { localVue, mocks: { foo: true } }) + expect(wrapper.vm.foo).toBe(true) -const freshWrapper = shallow(Foo) -expect(freshWrapper.vm.foo).toBe(false) +const wrapperSemMock = shallow(Foo) + +expect(wrapperSemMock.vm.foo).toBe(false) ``` -- **See also:** [Common Tips](../guides/common-tips.md#applying-global-plugins-and-mixins) +- **Veja também:** [Dicas comuns](../guides/common-tips.md#applying-global-plugins-and-mixins) From 1c460ce113d05f55ceb1e11a6061b504da0253f6 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 16:31:38 +0000 Subject: [PATCH 61/71] feat(docs): [to pt-br] translating config section --- docs/pt-br/api/config.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/pt-br/api/config.md b/docs/pt-br/api/config.md index 6f44dd639..17ea8fa1e 100644 --- a/docs/pt-br/api/config.md +++ b/docs/pt-br/api/config.md @@ -1,25 +1,25 @@ -# Config +# Configurações -vue-test-utils includes a config object to defined options used by vue-test-utils. +O vue-test-utils apresenta um objeto de configuração para que você possa definir as opções usadas no wrapper. -## `vue-test-utils` Config Options +## Opções de configurações do `vue-test-utils ### `stubs` -- type: `Object` -- default: `{ +- tipo: `Object` +- padrão: `{ transition: TransitionStub, 'transition-group': TransitionGroupStub }` -Stubs to use in components. These are overwritten by `stubs` passed in the mounting options. +Esboços são usados em todos componentes. Eles são substituídos pelos `stubs` passados nas opções da montagem. -When passing `stubs` as an array in the mounting options, `config.stubs` are converted to an array, and will stub components with a basic component that returns a div. +Quando você passa os `stubs` como um array de string nas opções de montagens, o `config.stubs` é convertido em um array e os componentes são esboçados com um componente que retorna uma div. -Example: +Exemplho: ```js import VueTestUtils from 'vue-test-utils' -VueTestUtils.config.stubs['my-compomnent'] = '
' +VueTestUtils.config.stubs['meu-componente'] = '
' ``` From dfd1428bc0033b125d056e6ce5890984b75a1f9f Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 21:40:22 +0000 Subject: [PATCH 62/71] feat(docs): change word 'embrulho' to 'wrapper' --- docs/pt-br/README.md | 2 +- docs/pt-br/SUMMARY.md | 2 +- docs/pt-br/api/README.md | 2 +- docs/pt-br/api/wrapper-array/README.md | 6 +++--- docs/pt-br/api/wrapper-array/at.md | 2 +- docs/pt-br/api/wrapper-array/contains.md | 2 +- docs/pt-br/api/wrapper-array/destroy.md | 2 +- docs/pt-br/api/wrapper-array/hasAttribute.md | 2 +- docs/pt-br/api/wrapper-array/hasClass.md | 2 +- docs/pt-br/api/wrapper-array/hasProp.md | 2 +- docs/pt-br/api/wrapper-array/hasStyle.md | 4 ++-- docs/pt-br/api/wrapper-array/is.md | 2 +- docs/pt-br/api/wrapper-array/isEmpty.md | 2 +- docs/pt-br/api/wrapper-array/isVueInstance.md | 2 +- docs/pt-br/api/wrapper-array/setComputed.md | 6 +++--- docs/pt-br/api/wrapper-array/setData.md | 4 ++-- docs/pt-br/api/wrapper-array/setMethods.md | 4 ++-- docs/pt-br/api/wrapper-array/setProps.md | 4 ++-- docs/pt-br/api/wrapper-array/trigger.md | 4 ++-- docs/pt-br/api/wrapper-array/update.md | 2 +- docs/pt-br/api/wrapper/README.md | 6 +++--- docs/pt-br/api/wrapper/contains.md | 2 +- docs/pt-br/api/wrapper/emitted.md | 2 +- docs/pt-br/api/wrapper/emittedByOrder.md | 2 +- docs/pt-br/api/wrapper/find.md | 2 +- docs/pt-br/api/wrapper/hasAttribute.md | 4 ++-- docs/pt-br/api/wrapper/hasClass.md | 2 +- docs/pt-br/api/wrapper/hasProp.md | 2 +- docs/pt-br/api/wrapper/hasStyle.md | 2 +- docs/pt-br/api/wrapper/html.md | 2 +- docs/pt-br/api/wrapper/isEmpty.md | 2 +- docs/pt-br/api/wrapper/isVueInstance.md | 2 +- docs/pt-br/api/wrapper/name.md | 2 +- docs/pt-br/api/wrapper/setComputed.md | 2 +- docs/pt-br/api/wrapper/setData.md | 2 +- docs/pt-br/api/wrapper/setMethods.md | 2 +- docs/pt-br/api/wrapper/setProps.md | 2 +- docs/pt-br/api/wrapper/text.md | 2 +- docs/pt-br/api/wrapper/trigger.md | 2 +- docs/pt-br/api/wrapper/update.md | 2 +- docs/pt-br/guides/choosing-a-test-runner.md | 2 +- docs/pt-br/guides/common-tips.md | 8 ++++---- docs/pt-br/guides/dom-events.md | 4 ++-- docs/pt-br/guides/getting-started.md | 14 +++++++------- docs/pt-br/guides/using-with-vuex.md | 2 +- 45 files changed, 67 insertions(+), 67 deletions(-) diff --git a/docs/pt-br/README.md b/docs/pt-br/README.md index 19c3deeaa..b75cdba1e 100644 --- a/docs/pt-br/README.md +++ b/docs/pt-br/README.md @@ -26,7 +26,7 @@ - [attrs](api/options.md#attrs) - [listeners](api/options.md#listeners) - [clone](api/options.md#clone) - * [Wrapper (embrulho)](api/wrapper/README.md) + * [Wrapper](api/wrapper/README.md) * [contains](api/wrapper/contains.md) * [emitted](api/wrapper/emitted.md) * [emittedByOrder](api/wrapper/emittedByOrder.md) diff --git a/docs/pt-br/SUMMARY.md b/docs/pt-br/SUMMARY.md index fd634df78..48116aa5d 100644 --- a/docs/pt-br/SUMMARY.md +++ b/docs/pt-br/SUMMARY.md @@ -22,7 +22,7 @@ - [attrs](api/options.md#attrs) - [listeners](api/options.md#listeners) - [clone](api/options.md#clone) - * [Wrapper (embrulho)](api/wrapper/README.md) + * [Wrapper](api/wrapper/README.md) * [contains](api/wrapper/contains.md) * [emitted](api/wrapper/emitted.md) * [emittedByOrder](api/wrapper/emittedByOrder.md) diff --git a/docs/pt-br/api/README.md b/docs/pt-br/api/README.md index df2c2a1de..6941e1a63 100644 --- a/docs/pt-br/api/README.md +++ b/docs/pt-br/api/README.md @@ -12,7 +12,7 @@ - [attrs](./options.md#attrs) - [listeners](./options.md#listeners) - [clone](./options.md#clone) -* [Wrapper (embrulho)](./wrapper/README.md) +* [Wrapper](./wrapper/README.md) * [contains](./wrapper/contains.md) * [emitted](./wrapper/emitted.md) * [emittedByOrder](./wrapper/emittedByOrder.md) diff --git a/docs/pt-br/api/wrapper-array/README.md b/docs/pt-br/api/wrapper-array/README.md index bd177f7f8..d0d452311 100644 --- a/docs/pt-br/api/wrapper-array/README.md +++ b/docs/pt-br/api/wrapper-array/README.md @@ -1,10 +1,10 @@ -# WrapperArray (array de embrulhos) +# WrapperArray (array de wrappers) -Um array de embrulhos é um objeto que contem uma lista com [Wrappers](../wrapper/README.md), e os alguns métodos para testar esses embrulhos. +Um array de wrappers é um objeto que contem uma lista com [Wrappers](../wrapper/README.md), e os alguns métodos para testar esses wrappers. - **Propriedades:** -`length` `number`: O número de embrulhos contidos nesse array. +`length` `number`: O número de wrappers contidos nesse array. - **Métodos:** diff --git a/docs/pt-br/api/wrapper-array/at.md b/docs/pt-br/api/wrapper-array/at.md index ba5f3b8ca..30d331b8a 100644 --- a/docs/pt-br/api/wrapper-array/at.md +++ b/docs/pt-br/api/wrapper-array/at.md @@ -1,6 +1,6 @@ # at(indice) -Retorna o embrulho correspondente ao `indice` passado. Use números para corresponder ao item do arra, por exemplo o `indice` 0 para o primeiro elemento. +Retorna o wrapper correspondente ao `indice` passado. Use números para corresponder ao item do arra, por exemplo o `indice` 0 para o primeiro elemento. - **Argumentos:** - `{number} indice` diff --git a/docs/pt-br/api/wrapper-array/contains.md b/docs/pt-br/api/wrapper-array/contains.md index 744358508..f9eac958d 100644 --- a/docs/pt-br/api/wrapper-array/contains.md +++ b/docs/pt-br/api/wrapper-array/contains.md @@ -1,6 +1,6 @@ # contains(seletor) -Verifica se cada embrulho do array contém correspondência do seletor informado. +Verifica se cada wrapper do array contém correspondência do seletor informado. Use qualquer [seletor](../selectors.md) válido. diff --git a/docs/pt-br/api/wrapper-array/destroy.md b/docs/pt-br/api/wrapper-array/destroy.md index 495140c44..736ba8647 100644 --- a/docs/pt-br/api/wrapper-array/destroy.md +++ b/docs/pt-br/api/wrapper-array/destroy.md @@ -1,6 +1,6 @@ # destroy() -Destroí a instância do Vue da cada um dos embrulhos do array. +Destroí a instância do Vue da cada um dos wrappers do array. - **Exemplo:** diff --git a/docs/pt-br/api/wrapper-array/hasAttribute.md b/docs/pt-br/api/wrapper-array/hasAttribute.md index 5dd620706..8453d2883 100644 --- a/docs/pt-br/api/wrapper-array/hasAttribute.md +++ b/docs/pt-br/api/wrapper-array/hasAttribute.md @@ -1,6 +1,6 @@ # hasAttribute(atributo, valor) -Verifica se algum embrulho do array tem o `atributo` com `valor` correspondente no elemento do DOM. +Verifica se algum wrapper do array tem o `atributo` com `valor` correspondente no elemento do DOM. - **Argumentos:** - `{string} atributo` diff --git a/docs/pt-br/api/wrapper-array/hasClass.md b/docs/pt-br/api/wrapper-array/hasClass.md index 8a4622e4c..2a238d85a 100644 --- a/docs/pt-br/api/wrapper-array/hasClass.md +++ b/docs/pt-br/api/wrapper-array/hasClass.md @@ -1,6 +1,6 @@ # hasClass(nomeDaClasse) -Verifica se algum embrulho do array contém uma classe com o nome `nomeDaClasse` no elemento do DOM. +Verifica se algum wrapper do array contém uma classe com o nome `nomeDaClasse` no elemento do DOM. - **Argumentos:** - `{string} nomeDaClasse` diff --git a/docs/pt-br/api/wrapper-array/hasProp.md b/docs/pt-br/api/wrapper-array/hasProp.md index d960788f8..3427eaf91 100644 --- a/docs/pt-br/api/wrapper-array/hasProp.md +++ b/docs/pt-br/api/wrapper-array/hasProp.md @@ -1,6 +1,6 @@ # hasProp(propriedade, valor) -Verifica se algum embrulho do array possui a `propriedade` com o `valor` no `vm`. +Verifica se algum wrapper do array possui a `propriedade` com o `valor` no `vm`. **Nota: o wrapper deve ser uma intância do Vue.** diff --git a/docs/pt-br/api/wrapper-array/hasStyle.md b/docs/pt-br/api/wrapper-array/hasStyle.md index a3aac4d20..6b74afa38 100644 --- a/docs/pt-br/api/wrapper-array/hasStyle.md +++ b/docs/pt-br/api/wrapper-array/hasStyle.md @@ -1,8 +1,8 @@ # hasStyle(estilo, valor) -Verifica se algum embrulho do array tem o `estilo` com o `valor` no elemento do DOM. +Verifica se algum wrapper do array tem o `estilo` com o `valor` no elemento do DOM. -Retorna `true` se o embrulho contém o `estilo` com o `valor`. +Retorna `true` se o wrapper contém o `estilo` com o `valor`. **Nota: para detectarmos os estilos deve-se usar o `jsdom`.** diff --git a/docs/pt-br/api/wrapper-array/is.md b/docs/pt-br/api/wrapper-array/is.md index 0264bd492..32c8e0f25 100644 --- a/docs/pt-br/api/wrapper-array/is.md +++ b/docs/pt-br/api/wrapper-array/is.md @@ -1,6 +1,6 @@ # is(seletor) -Verifica se algum embrulho do array possui o [seletor](../selectors.md) no seu `vm`. +Verifica se algum wrapper do array possui o [seletor](../selectors.md) no seu `vm`. - **Argumentos:** - `{string|Component} seletor` diff --git a/docs/pt-br/api/wrapper-array/isEmpty.md b/docs/pt-br/api/wrapper-array/isEmpty.md index 491165bf4..b299fac66 100644 --- a/docs/pt-br/api/wrapper-array/isEmpty.md +++ b/docs/pt-br/api/wrapper-array/isEmpty.md @@ -1,6 +1,6 @@ # isEmpty() -Verifica se algum embrulho do array não tem um elemento filho. +Verifica se algum wrapper do array não tem um elemento filho. - **Retorna:** `{boolean}` diff --git a/docs/pt-br/api/wrapper-array/isVueInstance.md b/docs/pt-br/api/wrapper-array/isVueInstance.md index 68ff84b48..116e0ba0d 100644 --- a/docs/pt-br/api/wrapper-array/isVueInstance.md +++ b/docs/pt-br/api/wrapper-array/isVueInstance.md @@ -1,6 +1,6 @@ # isVueInstance() -Verifica se algum embrulho do array é uma instância do Vue. +Verifica se algum wrapper do array é uma instância do Vue. - **Retorna:** `{boolean}` diff --git a/docs/pt-br/api/wrapper-array/setComputed.md b/docs/pt-br/api/wrapper-array/setComputed.md index af289a198..51fd90ead 100644 --- a/docs/pt-br/api/wrapper-array/setComputed.md +++ b/docs/pt-br/api/wrapper-array/setComputed.md @@ -1,9 +1,9 @@ # setComputed(propriedadesComputadas) -Define as propriedades computadas e força a atualização de cada um dos embrulhos no array. +Define as propriedades computadas e força a atualização de cada um dos wrappers no array. -**Nota: cada embrulho deve ser uma instância do Vue.** -**Nota2: cada instância de cada embrulho deve ter as propriedades computadas já declaradas, pois esse método apenas mocka o seu valor.** +**Nota: cada wrapper deve ser uma instância do Vue.** +**Nota2: cada instância de cada wrapper deve ter as propriedades computadas já declaradas, pois esse método apenas mocka o seu valor.** - **Argumentos:** - `{Object} propriedadesComputadass` diff --git a/docs/pt-br/api/wrapper-array/setData.md b/docs/pt-br/api/wrapper-array/setData.md index 05a643b16..e16bbabb6 100644 --- a/docs/pt-br/api/wrapper-array/setData.md +++ b/docs/pt-br/api/wrapper-array/setData.md @@ -1,8 +1,8 @@ # setData(dados) -Define os dados e força a atualização de cada embrulho presente no array. +Define os dados e força a atualização de cada wrapper presente no array. -**Nota: cada embrulho deve ser uma instância do Vue.** +**Nota: cada wrapper deve ser uma instância do Vue.** - **Argumentos:** - `{Object} dados` diff --git a/docs/pt-br/api/wrapper-array/setMethods.md b/docs/pt-br/api/wrapper-array/setMethods.md index 3da8e740d..daad37019 100644 --- a/docs/pt-br/api/wrapper-array/setMethods.md +++ b/docs/pt-br/api/wrapper-array/setMethods.md @@ -1,8 +1,8 @@ # setMethods(metodos) -Define os métodos do componente e força sua atualização para cada embrulho no array. +Define os métodos do componente e força sua atualização para cada wrapper no array. -**Nota: cada embrulho deve ser uma instância do Vue.** +**Nota: cada wrapper deve ser uma instância do Vue.** - **Argumentos:** - `{Object} metodos` diff --git a/docs/pt-br/api/wrapper-array/setProps.md b/docs/pt-br/api/wrapper-array/setProps.md index 0cd53f01a..079649c1a 100644 --- a/docs/pt-br/api/wrapper-array/setProps.md +++ b/docs/pt-br/api/wrapper-array/setProps.md @@ -1,8 +1,8 @@ # setProps(propriedades) -Define as `propriedades` do componente e força sua atualização para cada embrulho no array. +Define as `propriedades` do componente e força sua atualização para cada wrapper no array. -**Nota: cada embrulho deve ser uma instância do Vue.** +**Nota: cada wrapper deve ser uma instância do Vue.** - **Argumentos:** - `{Object} propriedades` diff --git a/docs/pt-br/api/wrapper-array/trigger.md b/docs/pt-br/api/wrapper-array/trigger.md index 90819beca..8ed7a07b0 100644 --- a/docs/pt-br/api/wrapper-array/trigger.md +++ b/docs/pt-br/api/wrapper-array/trigger.md @@ -1,8 +1,8 @@ # trigger(nomeDoEvento) -Aciona um evento no elemeto do DOM de cada embrulho no array. +Aciona um evento no elemeto do DOM de cada wrapper no array. -**Nota: cada embrulho deve ser uma instância do Vue.** +**Nota: cada wrapper deve ser uma instância do Vue.** - **Argumentos:** - `{string} nomeDoEvento` diff --git a/docs/pt-br/api/wrapper-array/update.md b/docs/pt-br/api/wrapper-array/update.md index f3d1ea5cf..0c912a6a0 100644 --- a/docs/pt-br/api/wrapper-array/update.md +++ b/docs/pt-br/api/wrapper-array/update.md @@ -1,6 +1,6 @@ # update() -Força a atualização e redesenho do componente Vue de cada embrulho do array. +Força a atualização e redesenho do componente Vue de cada wrapper do array. Se for chamado a partir de um componente Vue, força a atualização de cada componente do array. diff --git a/docs/pt-br/api/wrapper/README.md b/docs/pt-br/api/wrapper/README.md index f4a2739e6..4305efe92 100644 --- a/docs/pt-br/api/wrapper/README.md +++ b/docs/pt-br/api/wrapper/README.md @@ -1,4 +1,4 @@ -# Wrapper (embrulho) +# Wrapper (wrapper) vue-test-utils é uma API baseada em *wrapper*. @@ -6,9 +6,9 @@ Um `Wrapper` é um objeto que contém um componente montado ou um vnode e alguns - **Propriedades:** -`vm` `Component`: é uma instância Vue. Você pode acessar todos os [métodos de instância e propriedades de um vm](https://vuejs.org/v2/api/#Instance-Properties) com o `wrapper.vm`. Ela só exite em embrulhos de componentes Vue. +`vm` `Component`: é uma instância Vue. Você pode acessar todos os [métodos de instância e propriedades de um vm](https://vuejs.org/v2/api/#Instance-Properties) com o `wrapper.vm`. Ela só exite em wrappers de componentes Vue. -`element` `HTMLElement`: elemento raiz do DOM do embrulho. +`element` `HTMLElement`: elemento raiz do DOM do wrapper. `options` `Object`: Objeto que contém as opções do vue-test-utils para ser passado para o `mount` ou `shallow`. diff --git a/docs/pt-br/api/wrapper/contains.md b/docs/pt-br/api/wrapper/contains.md index dce339b87..6a98a529d 100644 --- a/docs/pt-br/api/wrapper/contains.md +++ b/docs/pt-br/api/wrapper/contains.md @@ -1,6 +1,6 @@ # contains(seletor) -Verifica se o embrulho contém um elemento ou componente com o [seletor](../selectors.md) informado. +Verifica se o wrapper contém um elemento ou componente com o [seletor](../selectors.md) informado. - **Argumentos:** - `{string|Component} seletor` diff --git a/docs/pt-br/api/wrapper/emitted.md b/docs/pt-br/api/wrapper/emitted.md index a7026d68a..7a72367b1 100644 --- a/docs/pt-br/api/wrapper/emitted.md +++ b/docs/pt-br/api/wrapper/emitted.md @@ -1,6 +1,6 @@ # emitted() -Retorna um objeto contendo os eventos cutomizados emitidos pelo `vm` do embrulho wrapper. +Retorna um objeto contendo os eventos cutomizados emitidos pelo `vm` do wrapper. - **Retorna:** `{ [name: string]: Array> }` diff --git a/docs/pt-br/api/wrapper/emittedByOrder.md b/docs/pt-br/api/wrapper/emittedByOrder.md index 47f81d503..f84f62bb7 100644 --- a/docs/pt-br/api/wrapper/emittedByOrder.md +++ b/docs/pt-br/api/wrapper/emittedByOrder.md @@ -1,6 +1,6 @@ # emittedByOrder() -Retorna um array contendo os eventos customizados emitidos pelo `vm` do embrulho wrapper. +Retorna um array contendo os eventos customizados emitidos pelo `vm` do wrapper. - **Retorna:** `Array<{ name: string, args: Array }>` diff --git a/docs/pt-br/api/wrapper/find.md b/docs/pt-br/api/wrapper/find.md index f1c4155d2..1cbcb485a 100644 --- a/docs/pt-br/api/wrapper/find.md +++ b/docs/pt-br/api/wrapper/find.md @@ -1,6 +1,6 @@ # find(seletor) -Retorna um embrulho [`Wrapper`](README.md) com o primeiro elmento do DOM ou o componente Vue encontrado a partir do seletor +Retorna um wrapper [`Wrapper`](README.md) com o primeiro elmento do DOM ou o componente Vue encontrado a partir do seletor Use any valiUse qualquer [seletor](../selectors.md) válido. diff --git a/docs/pt-br/api/wrapper/hasAttribute.md b/docs/pt-br/api/wrapper/hasAttribute.md index efc77cda9..02d7b9eef 100644 --- a/docs/pt-br/api/wrapper/hasAttribute.md +++ b/docs/pt-br/api/wrapper/hasAttribute.md @@ -1,8 +1,8 @@ # hasAttribute(atributo, valor) -Verifica se o embrulho Wrapper contém o atributo mencionado no seu elemento do DOM. +Verifica se o wrapper contém o atributo mencionado no seu elemento do DOM. -Retorna `true` se o embrulho contém o atributo. +Retorna `true` se o wrapper contém o atributo. - **Argumentos:** - `{string} atributo` diff --git a/docs/pt-br/api/wrapper/hasClass.md b/docs/pt-br/api/wrapper/hasClass.md index ede6d4e4e..4d1fbf7f6 100644 --- a/docs/pt-br/api/wrapper/hasClass.md +++ b/docs/pt-br/api/wrapper/hasClass.md @@ -1,6 +1,6 @@ # hasClass(nomeDaClasse) -Verifica se o embrulho do elemento do DOM contém uma classe informada pelo `nomeDaClasse`. +Verifica se o wrapper do elemento do DOM contém uma classe informada pelo `nomeDaClasse`. Retorna `true` se o wrapper contém a classe. diff --git a/docs/pt-br/api/wrapper/hasProp.md b/docs/pt-br/api/wrapper/hasProp.md index 2d617a05d..caba69caa 100644 --- a/docs/pt-br/api/wrapper/hasProp.md +++ b/docs/pt-br/api/wrapper/hasProp.md @@ -1,6 +1,6 @@ # hasProp(propriedade, valor) -Verifica se o `vm` do embrulho possui uma pripriedade com o valor definido. +Verifica se o `vm` do wrapper possui uma pripriedade com o valor definido. Retorna `true` se o `vm` do wrapper tem a `propriedade` com o `valor` passado. diff --git a/docs/pt-br/api/wrapper/hasStyle.md b/docs/pt-br/api/wrapper/hasStyle.md index 127efb7c5..1a49fca43 100644 --- a/docs/pt-br/api/wrapper/hasStyle.md +++ b/docs/pt-br/api/wrapper/hasStyle.md @@ -1,6 +1,6 @@ # hasStyle(estilo, valor) -Verifica se o elemento do DOM do embrulho possui uma propriedade de estilo com esse valor. +Verifica se o elemento do DOM do wrapper possui uma propriedade de estilo com esse valor. Retorna `true` se o wrapper possui um `estilo` com o `valor`. diff --git a/docs/pt-br/api/wrapper/html.md b/docs/pt-br/api/wrapper/html.md index 652f1fcb6..b8282f70a 100644 --- a/docs/pt-br/api/wrapper/html.md +++ b/docs/pt-br/api/wrapper/html.md @@ -1,6 +1,6 @@ # html() -Retorna o HTML do elemento do embrulho como uma string. +Retorna o HTML do elemento do wrapper como uma string. - **Retorna:** `{string}` diff --git a/docs/pt-br/api/wrapper/isEmpty.md b/docs/pt-br/api/wrapper/isEmpty.md index 6438e5d36..29d20be68 100644 --- a/docs/pt-br/api/wrapper/isEmpty.md +++ b/docs/pt-br/api/wrapper/isEmpty.md @@ -1,6 +1,6 @@ # isEmpty() -Verifica se o embrulho não contem elementos filhos. +Verifica se o wrapper não contem elementos filhos. - **Retorna:** `{boolean}` diff --git a/docs/pt-br/api/wrapper/isVueInstance.md b/docs/pt-br/api/wrapper/isVueInstance.md index 2cb4cdac3..421603623 100644 --- a/docs/pt-br/api/wrapper/isVueInstance.md +++ b/docs/pt-br/api/wrapper/isVueInstance.md @@ -1,6 +1,6 @@ # isVueInstance() -Verifica se o embrulho é uma intância do Vue. +Verifica se o wrapper é uma intância do Vue. - **Retorna:** `{boolean}` diff --git a/docs/pt-br/api/wrapper/name.md b/docs/pt-br/api/wrapper/name.md index 1f2d95e62..8babd9c73 100644 --- a/docs/pt-br/api/wrapper/name.md +++ b/docs/pt-br/api/wrapper/name.md @@ -1,6 +1,6 @@ # name() -Retorna o nome do componente se o embrulho for uma instância do Vue, ou então o nome da tag se o embrulho for um elemento do DOM e não for uma instância do Vue. +Retorna o nome do componente se o wrapper for uma instância do Vue, ou então o nome da tag se o wrapper for um elemento do DOM e não for uma instância do Vue. - **Retorna:** `{string}` diff --git a/docs/pt-br/api/wrapper/setComputed.md b/docs/pt-br/api/wrapper/setComputed.md index 6d4a82e37..1239ab3db 100644 --- a/docs/pt-br/api/wrapper/setComputed.md +++ b/docs/pt-br/api/wrapper/setComputed.md @@ -1,6 +1,6 @@ # setComputed(propriedadesComputadas) -Define as propriedades computadas do `vm` do embrulho e força a sua atualização. +Define as propriedades computadas do `vm` do wrapper e força a sua atualização. **Nota: o wrapper deve ser uma instância do Vue.** **Nota2: a instância já deve ter as propriedades computadas passadas para o setComputed declaradas.** diff --git a/docs/pt-br/api/wrapper/setData.md b/docs/pt-br/api/wrapper/setData.md index 7b4e15f4d..9eda395a1 100644 --- a/docs/pt-br/api/wrapper/setData.md +++ b/docs/pt-br/api/wrapper/setData.md @@ -1,6 +1,6 @@ # setData(dados) -Define os dados do `vm` do embrulho e força a sua atualização. +Define os dados do `vm` do wrapper e força a sua atualização. **Nota: o wrapper deve ser uma instância do Vue.** diff --git a/docs/pt-br/api/wrapper/setMethods.md b/docs/pt-br/api/wrapper/setMethods.md index 389c68401..882890925 100644 --- a/docs/pt-br/api/wrapper/setMethods.md +++ b/docs/pt-br/api/wrapper/setMethods.md @@ -1,6 +1,6 @@ # setMethods(metodos) -Define os métodos do `vm` do embrulho e força sua atualização. +Define os métodos do `vm` do wrapper e força sua atualização. **Nota: o wrapper deve ser uma instância do Vue.** diff --git a/docs/pt-br/api/wrapper/setProps.md b/docs/pt-br/api/wrapper/setProps.md index 9f84b89af..c93cdc490 100644 --- a/docs/pt-br/api/wrapper/setProps.md +++ b/docs/pt-br/api/wrapper/setProps.md @@ -1,6 +1,6 @@ # setProps(propriedades) -Define as propriedades do `vm` do embrulho e força sua atualização. +Define as propriedades do `vm` do wrapper e força sua atualização. **Nota: o wrapper deve ser uma instância do Vue.** diff --git a/docs/pt-br/api/wrapper/text.md b/docs/pt-br/api/wrapper/text.md index a94c321a0..351114556 100644 --- a/docs/pt-br/api/wrapper/text.md +++ b/docs/pt-br/api/wrapper/text.md @@ -1,6 +1,6 @@ # text() -Retorna o texto contido no embrulho. +Retorna o texto contido no wrapper. - **Retorna:** `{string}` diff --git a/docs/pt-br/api/wrapper/trigger.md b/docs/pt-br/api/wrapper/trigger.md index 371767d53..c57f9cfbb 100644 --- a/docs/pt-br/api/wrapper/trigger.md +++ b/docs/pt-br/api/wrapper/trigger.md @@ -1,6 +1,6 @@ # trigger(nomeDoEvento {, opcoes}]) -Aciona um evento do elemento do embrulho. +Aciona um evento do elemento do wrapper. O método `trigger` usa o objeto opicional `opcoes`, essas opções serão adicionadas ao evento. diff --git a/docs/pt-br/api/wrapper/update.md b/docs/pt-br/api/wrapper/update.md index e1f5f9098..c138dc589 100644 --- a/docs/pt-br/api/wrapper/update.md +++ b/docs/pt-br/api/wrapper/update.md @@ -2,7 +2,7 @@ Força o componente Vue a ser redesenhado. -Se você chamar esse método em um embrulho que contém `vm`, ele forçará o `vm` do wrapper a se redesenhar. +Se você chamar esse método em um wrapper que contém `vm`, ele forçará o `vm` do wrapper a se redesenhar. - **Exemplo:** diff --git a/docs/pt-br/guides/choosing-a-test-runner.md b/docs/pt-br/guides/choosing-a-test-runner.md index 87714fe09..b15ec57fa 100644 --- a/docs/pt-br/guides/choosing-a-test-runner.md +++ b/docs/pt-br/guides/choosing-a-test-runner.md @@ -9,7 +9,7 @@ Há algumas coisas a considerar ao escolher um *test runner*: conjunto de recurs - [Jest](https://facebook.github.io/jest/docs/en/getting-started.html#content) é o executador de testes mais completo. Ele requer menos configuração, usa JSDOM por padrão, e fornece uma ótima experiência de usuário na linha de comando. Contudo, você vai precisar de um pré-processador para ser possível importar componentes SFC em seus testes. Nos criamos o pré-processador `vue-jest`, para lidar com os recursos SFC mais comuns, mas atualmente não possuímos 100% de compatibilidade com o `vue-loader`. - [mocha-webpack](https://github.com/zinserjan/mocha-webpack) é um -embrulho que envolve o webpack e o Mocha, mas com uma interface simplificada e um modo observador. O benefício dessa configuração é o suporte SFC completo via webpack + `vue-loader`, mas isso requer maiores configurações antecipadas. +wrapper que envolve o webpack e o Mocha, mas com uma interface simplificada e um modo observador. O benefício dessa configuração é o suporte SFC completo via webpack + `vue-loader`, mas isso requer maiores configurações antecipadas. ## Ambiente de navegador diff --git a/docs/pt-br/guides/common-tips.md b/docs/pt-br/guides/common-tips.md index 64023de70..fd89c1a73 100644 --- a/docs/pt-br/guides/common-tips.md +++ b/docs/pt-br/guides/common-tips.md @@ -23,14 +23,14 @@ O `vue-test-utils` permite que você monte um componente sem renderizar seus com ```js import { shallow } from 'vue-test-utils' -// obtém o embrulho contendo a instância montada de Componente +// obtém o wrapper contendo a instância montada de Componente const wrapper = shallow(Componente) wrapper.vm // instância do Vue já montada ``` ## Verificando os eventos emitidos -Cada embrulho montado grava automaticamente todos os eventos emitidos pela instância Vue contida. Você pode recuperar os eventos registrados usando o método `emitted`: +Cada wrapper montado grava automaticamente todos os eventos emitidos pela instância Vue contida. Você pode recuperar os eventos registrados usando o método `emitted`: ``` js wrapper.vm.$emit('foo') @@ -63,7 +63,7 @@ Além disso, você pode pegar um Array dos eventos emitidos em ordem de chamada ## Manupulando o estado do componente -Você pode manipular diretamente o estado do componente usando os métodos `setData` ou `setProps` no embrulho: +Você pode manipular diretamente o estado do componente usando os métodos `setData` ou `setProps` no wrapper: ```js wrapper.setData({ contador: 10 }) @@ -104,7 +104,7 @@ const localVue = createLocalVue() // Instalando normalmente os seus plugins localVue.use(MeuPlugin) -// Passe o localVue para o embrulho do componente +// Passe o localVue para o wrapper do componente mount(Componente, { localVue }) diff --git a/docs/pt-br/guides/dom-events.md b/docs/pt-br/guides/dom-events.md index 1ccfd0ce3..ebc526af8 100644 --- a/docs/pt-br/guides/dom-events.md +++ b/docs/pt-br/guides/dom-events.md @@ -2,7 +2,7 @@ ## Desencadear eventos -O embrulho (wrapper) expõe o método `trigger`. Ele pode ser usado para desencadear eventos do DOM. +O wrapper (wrapper) expõe o método `trigger`. Ele pode ser usado para desencadear eventos do DOM. ```js const wrapper = mount(MeuBotao) @@ -10,7 +10,7 @@ const wrapper = mount(MeuBotao) wrapper.trigger('click') ``` -Você deve estar ciente que esse método também retorna um embrulho. Assumindo que em `MeuComponente` há um botão, o código a seguir simula o clique no botão. +Você deve estar ciente que esse método também retorna um wrapper. Assumindo que em `MeuComponente` há um botão, o código a seguir simula o clique no botão. ```js const wrapper = mount(MeuComponente) diff --git a/docs/pt-br/guides/getting-started.md b/docs/pt-br/guides/getting-started.md index db5b1bf0e..ffedbb572 100644 --- a/docs/pt-br/guides/getting-started.md +++ b/docs/pt-br/guides/getting-started.md @@ -41,9 +41,9 @@ export default { O `vue-test-utils` testa os componentes do Vue montando-os isoladamente, mockando as entradas necessárias (propriedades, slots e eventos de usuário) e verificando as saídas (renderização, eventos personalizados emitidos). -Os componentes montados são retornados em um embrulho (wrapper) que expõe muitos métodos para manipular, percorrer e consultar a instância do componente Vue correspondente. +Os componentes montados são retornados em um wrapper (wrapper) que expõe muitos métodos para manipular, percorrer e consultar a instância do componente Vue correspondente. -Você pode criar essses embrulhos usando o método `mount`. Vamos criar um chamado `test.js`: +Você pode criar essses wrappers usando o método `mount`. Vamos criar um chamado `test.js`: ```js // test.js @@ -53,27 +53,27 @@ Você pode criar essses embrulhos usando o método `mount`. Vamos criar um chama import { mount } from 'vue-test-utils' import Counter from './counter' -// Agora montamos o componente e obtermos o embrulho +// Agora montamos o componente e obtermos o wrapper const wrapper = mount(Counter) // Você pode acessar a instância atual do Vue através de wrapper.vm const vm = wrapper.vm -// Para inspecionar a composição do embrulho exiba-o no console +// Para inspecionar a composição do wrapper exiba-o no console // ...Sua aventura com o vue-test-utils começa agora :) console.log(wrapper) ``` ### Testar a saída HTML do componente -Agora que nós já temos o embrulho, a primeira coisa que podemos fazer é verificar se a saída HTML que componente nos entrega é a esperada. +Agora que nós já temos o wrapper, a primeira coisa que podemos fazer é verificar se a saída HTML que componente nos entrega é a esperada. ```js import { mount } from 'vue-test-utils' import Counter from './counter' describe('Counter', () => { - // Montando o componente e obtendo o embrulho + // Montando o componente e obtendo o wrapper const wrapper = mount(Counter) it('renderiza o HTML correto', () => { @@ -91,7 +91,7 @@ Agora execute os testes com o comando `npm tests`. Você deve ver os testes pass ### Simulando a interação do usuário -Nosso `Counter` deve incrementar o contador quando o usuário clica no botão. Para simular esse comportamento, primeiro precisamos localizar o botão com `wrapper.find()`, que retorna um embrulho (wrapper) para o elemento do botão. Agora nós podemos simular o evento de clique, chamando o método `trigger()` no embrulho do botão: +Nosso `Counter` deve incrementar o contador quando o usuário clica no botão. Para simular esse comportamento, primeiro precisamos localizar o botão com `wrapper.find()`, que retorna um wrapper (wrapper) para o elemento do botão. Agora nós podemos simular o evento de clique, chamando o método `trigger()` no wrapper do botão: ```js it('o clique do botão deve incrementar a contagem', () => { diff --git a/docs/pt-br/guides/using-with-vuex.md b/docs/pt-br/guides/using-with-vuex.md index 6975c9115..01c2d7320 100644 --- a/docs/pt-br/guides/using-with-vuex.md +++ b/docs/pt-br/guides/using-with-vuex.md @@ -92,7 +92,7 @@ describe('Acoes.vue', () => { }) ``` -O que está acontecendo aqui? Primeiro contamos ao localVue que ele usará o Vuex no método `localVue.use`. Este é apenas um embrulho do `Vue.use`. +O que está acontecendo aqui? Primeiro contamos ao localVue que ele usará o Vuex no método `localVue.use`. Este é apenas um wrapper do `Vue.use`. Em seguida, fazemos uma store mockada chamando o método `Vuex.Store` com os valores do mock. Nós apenas passamos as ações, já que é o que nos importa no momento. From 6b4a7699417ee6fbd962519a4573d2286ad42e54 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 21:56:15 +0000 Subject: [PATCH 63/71] =?UTF-8?q?feat(docs):=20change=20word=20'stub'=20to?= =?UTF-8?q?=20'esbo=C3=A7o'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/pt-br/api/components/TransitionGroupStub.md | 2 +- docs/pt-br/api/components/TransitionStub.md | 2 +- docs/pt-br/api/config.md | 6 +++--- docs/pt-br/api/mount.md | 4 ++-- docs/pt-br/api/options.md | 2 +- docs/pt-br/guides/testing-SFCs-with-mocha-webpack.md | 2 +- docs/pt-br/guides/using-with-vue-router.md | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/pt-br/api/components/TransitionGroupStub.md b/docs/pt-br/api/components/TransitionGroupStub.md index 3103812ef..20ce86cb1 100644 --- a/docs/pt-br/api/components/TransitionGroupStub.md +++ b/docs/pt-br/api/components/TransitionGroupStub.md @@ -10,7 +10,7 @@ import VueTestUtils from 'vue-test-utils' VueTestUtils.config.stubs['transition-group'] = false ``` -Para redefinir os grupos de transições no stub, use: +Para redefinir os grupos de transições no esboço, use: ```js import VueTestUtils, { TransitionGroupStub } from 'vue-test-utils' diff --git a/docs/pt-br/api/components/TransitionStub.md b/docs/pt-br/api/components/TransitionStub.md index 9ca07cb9b..ca537fc3c 100644 --- a/docs/pt-br/api/components/TransitionStub.md +++ b/docs/pt-br/api/components/TransitionStub.md @@ -18,7 +18,7 @@ import VueTestUtils, { TransitionStub } from 'vue-test-utils' VueTestUtils.config.stubs.transition = TransitionStub ``` -Para configura-lo como um stub nas opções de montagem, use: +Para configura-lo como um esboço nas opções de montagem, use: ```js import { mount, TransitionStub } from 'vue-test-utils' diff --git a/docs/pt-br/api/config.md b/docs/pt-br/api/config.md index 17ea8fa1e..4bdcb3750 100644 --- a/docs/pt-br/api/config.md +++ b/docs/pt-br/api/config.md @@ -4,7 +4,7 @@ O vue-test-utils apresenta um objeto de configuração para que você possa defi ## Opções de configurações do `vue-test-utils -### `stubs` +### Esboços - tipo: `Object` - padrão: `{ @@ -12,9 +12,9 @@ O vue-test-utils apresenta um objeto de configuração para que você possa defi 'transition-group': TransitionGroupStub }` -Esboços são usados em todos componentes. Eles são substituídos pelos `stubs` passados nas opções da montagem. +Esboços são usados em todos componentes. Eles são substituídos pelos esboços passados nas opções da montagem. -Quando você passa os `stubs` como um array de string nas opções de montagens, o `config.stubs` é convertido em um array e os componentes são esboçados com um componente que retorna uma div. +Quando você passa os esboços como um array de string nas opções de montagens, o `config.stubs` é convertido em um array e os componentes são esboçados com um componente que retorna uma div. Exemplho: diff --git a/docs/pt-br/api/mount.md b/docs/pt-br/api/mount.md index 2f76f2956..247022de4 100644 --- a/docs/pt-br/api/mount.md +++ b/docs/pt-br/api/mount.md @@ -124,12 +124,12 @@ describe('Foo', () => { it('verifica componentes filhos de Foo', () => { const wrapper = mount(Foo, { stub: { - Bar: '
', BarFoo: true, FooBar: Faz } }) - expect(wrapper.contains('.stubbed')).toBe(true) + expect(wrapper.contains('.esbocado')).toBe(true) expect(wrapper.contains(Bar)).toBe(true) }) }) diff --git a/docs/pt-br/api/options.md b/docs/pt-br/api/options.md index 8648efe0b..2ea624674 100644 --- a/docs/pt-br/api/options.md +++ b/docs/pt-br/api/options.md @@ -57,7 +57,7 @@ const wrapper = shallow(Component, { expect(wrapper.find('div')).toBe(true) ``` -### `stubs` +### Esboços - tipo: `{ [name: string]: Component | boolean } | Array` diff --git a/docs/pt-br/guides/testing-SFCs-with-mocha-webpack.md b/docs/pt-br/guides/testing-SFCs-with-mocha-webpack.md index 01630def6..df3bfad0b 100644 --- a/docs/pt-br/guides/testing-SFCs-with-mocha-webpack.md +++ b/docs/pt-br/guides/testing-SFCs-with-mocha-webpack.md @@ -94,7 +94,7 @@ Isso adiciona um ambiente de navegador ao Node, de modo que o `vue-test-utils` p ### Escolhendo uma biblioteca de asserção -[Chai](http://chaijs.com/) é uma biblioteca popular que é comumente usada ao lado do Mocha. Você também pode querer usar o [Sinon](http://sinonjs.org/) para criar spies e stubs. +[Chai](http://chaijs.com/) é uma biblioteca popular que é comumente usada ao lado do Mocha. Você também pode querer usar o [Sinon](http://sinonjs.org/) para criar spies e esboços. Como alternativa, você pode usar o `expect` que agora é uma parte do Jest e expõe [exatamente a mesma API](http://facebook.github.io/jest/docs/en/expect.html#content) na documentação do Jest. diff --git a/docs/pt-br/guides/using-with-vue-router.md b/docs/pt-br/guides/using-with-vue-router.md index ac1be87be..7a91a80c3 100644 --- a/docs/pt-br/guides/using-with-vue-router.md +++ b/docs/pt-br/guides/using-with-vue-router.md @@ -23,7 +23,7 @@ Quando você instala o Vue Router, os componentes `router-link` e `router-view` Quando executamos os testes, nós precisamos disponibilizar os componentes do Vue Router para os componentes que estamos montando. Existem dois métodos para se fazer isso. -### Usando stubs +### Usando esboços ```js shallow(Componente, { From 30b63cab4392431a5ec54c05e5e12d0d115ee9f6 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 21:59:53 +0000 Subject: [PATCH 64/71] feat(docs): change word 'array' to 'Array' --- docs/pt-br/README.md | 34 +++++++++---------- docs/pt-br/SUMMARY.md | 34 +++++++++---------- docs/pt-br/api/README.md | 28 +++++++-------- docs/pt-br/api/config.md | 2 +- docs/pt-br/api/options.md | 4 +-- docs/pt-br/api/wrapper-array/README.md | 6 ++-- docs/pt-br/api/wrapper-array/contains.md | 2 +- docs/pt-br/api/wrapper-array/destroy.md | 2 +- docs/pt-br/api/wrapper-array/hasAttribute.md | 2 +- docs/pt-br/api/wrapper-array/hasClass.md | 2 +- docs/pt-br/api/wrapper-array/hasProp.md | 2 +- docs/pt-br/api/wrapper-array/hasStyle.md | 2 +- docs/pt-br/api/wrapper-array/is.md | 2 +- docs/pt-br/api/wrapper-array/isEmpty.md | 2 +- docs/pt-br/api/wrapper-array/isVueInstance.md | 2 +- docs/pt-br/api/wrapper-array/setComputed.md | 2 +- docs/pt-br/api/wrapper-array/setData.md | 2 +- docs/pt-br/api/wrapper-array/setMethods.md | 2 +- docs/pt-br/api/wrapper-array/setProps.md | 2 +- docs/pt-br/api/wrapper-array/trigger.md | 2 +- docs/pt-br/api/wrapper-array/update.md | 4 +-- docs/pt-br/api/wrapper/emittedByOrder.md | 4 +-- docs/pt-br/api/wrapper/findAll.md | 2 +- 23 files changed, 73 insertions(+), 73 deletions(-) diff --git a/docs/pt-br/README.md b/docs/pt-br/README.md index b75cdba1e..fd3b741ea 100644 --- a/docs/pt-br/README.md +++ b/docs/pt-br/README.md @@ -49,23 +49,23 @@ * [trigger](api/wrapper/trigger.md) * [update](api/wrapper/update.md) * [destroy](api/wrapper/destroy.md) - * [WrapperArray](api/wrapper-array/README.md) - * [at](api/wrapper-array/at.md) - * [contains](api/wrapper-array/contains.md) - * [hasAttribute](api/wrapper-array/hasAttribute.md) - * [hasClass](api/wrapper-array/hasClass.md) - * [hasProp](api/wrapper-array/hasProp.md) - * [hasStyle](api/wrapper-array/hasStyle.md) - * [is](api/wrapper-array/is.md) - * [isEmpty](api/wrapper-array/isEmpty.md) - * [isVueInstance](api/wrapper-array/isVueInstance.md) - * [setComputed](api/wrapper-array/setComputed.md) - * [setData](api/wrapper-array/setData.md) - * [setMethods](api/wrapper-array/setMethods.md) - * [setProps](api/wrapper-array/setProps.md) - * [trigger](api/wrapper-array/trigger.md) - * [update](api/wrapper-array/update.md) - * [destroy](api/wrapper-array/destroy.md) + * [WrapperArray](api/wrapper-Array/README.md) + * [at](api/wrapper-Array/at.md) + * [contains](api/wrapper-Array/contains.md) + * [hasAttribute](api/wrapper-Array/hasAttribute.md) + * [hasClass](api/wrapper-Array/hasClass.md) + * [hasProp](api/wrapper-Array/hasProp.md) + * [hasStyle](api/wrapper-Array/hasStyle.md) + * [is](api/wrapper-Array/is.md) + * [isEmpty](api/wrapper-Array/isEmpty.md) + * [isVueInstance](api/wrapper-Array/isVueInstance.md) + * [setComputed](api/wrapper-Array/setComputed.md) + * [setData](api/wrapper-Array/setData.md) + * [setMethods](api/wrapper-Array/setMethods.md) + * [setProps](api/wrapper-Array/setProps.md) + * [trigger](api/wrapper-Array/trigger.md) + * [update](api/wrapper-Array/update.md) + * [destroy](api/wrapper-Array/destroy.md) * [components](api/components/README.md) * [TransitionStub](api/components/TransitionStub.md) * [TransitionGroupStub](api/components/TransitionGroupStub.md) diff --git a/docs/pt-br/SUMMARY.md b/docs/pt-br/SUMMARY.md index 48116aa5d..350149430 100644 --- a/docs/pt-br/SUMMARY.md +++ b/docs/pt-br/SUMMARY.md @@ -45,23 +45,23 @@ * [trigger](api/wrapper/trigger.md) * [update](api/wrapper/update.md) * [destroy](api/wrapper/destroy.md) - * [WrapperArray](api/wrapper-array/README.md) - * [at](api/wrapper-array/at.md) - * [contains](api/wrapper-array/contains.md) - * [hasAttribute](api/wrapper-array/hasAttribute.md) - * [hasClass](api/wrapper-array/hasClass.md) - * [hasProp](api/wrapper-array/hasProp.md) - * [hasStyle](api/wrapper-array/hasStyle.md) - * [is](api/wrapper-array/is.md) - * [isEmpty](api/wrapper-array/isEmpty.md) - * [isVueInstance](api/wrapper-array/isVueInstance.md) - * [setComputed](api/wrapper-array/setComputed.md) - * [setData](api/wrapper-array/setData.md) - * [setMethods](api/wrapper-array/setMethods.md) - * [setProps](api/wrapper-array/setProps.md) - * [trigger](api/wrapper-array/trigger.md) - * [update](api/wrapper-array/update.md) - * [destroy](api/wrapper-array/destroy.md) + * [WrapperArray](api/wrapper-Array/README.md) + * [at](api/wrapper-Array/at.md) + * [contains](api/wrapper-Array/contains.md) + * [hasAttribute](api/wrapper-Array/hasAttribute.md) + * [hasClass](api/wrapper-Array/hasClass.md) + * [hasProp](api/wrapper-Array/hasProp.md) + * [hasStyle](api/wrapper-Array/hasStyle.md) + * [is](api/wrapper-Array/is.md) + * [isEmpty](api/wrapper-Array/isEmpty.md) + * [isVueInstance](api/wrapper-Array/isVueInstance.md) + * [setComputed](api/wrapper-Array/setComputed.md) + * [setData](api/wrapper-Array/setData.md) + * [setMethods](api/wrapper-Array/setMethods.md) + * [setProps](api/wrapper-Array/setProps.md) + * [trigger](api/wrapper-Array/trigger.md) + * [update](api/wrapper-Array/update.md) + * [destroy](api/wrapper-Array/destroy.md) * [components](api/components/README.md) * [TransitionStub](api/components/TransitionStub.md) * [TransitionGroupStub](api/components/TransitionGroupStub.md) diff --git a/docs/pt-br/api/README.md b/docs/pt-br/api/README.md index 6941e1a63..75a0c8e1e 100644 --- a/docs/pt-br/api/README.md +++ b/docs/pt-br/api/README.md @@ -31,19 +31,19 @@ * [setProps](./wrapper/setProps.md) * [text](./wrapper/text.md) * [trigger](./wrapper/trigger.md) -* [WrapperArray](./wrapper-array/README.md) - * [at](./wrapper-array/at.md) - * [contains](./wrapper-array/contains.md) - * [hasAttribute](./wrapper-array/hasAttribute.md) - * [hasClass](./wrapper-array/hasClass.md) - * [hasProp](./wrapper-array/hasProp.md) - * [hasStyle](./wrapper-array/hasStyle.md) - * [is](./wrapper-array/is.md) - * [isEmpty](./wrapper-array/isEmpty.md) - * [isVueInstance](./wrapper-array/isVueInstance.md) - * [update](./wrapper-array/update.md) - * [setData](./wrapper-array/setData.md) - * [setProps](./wrapper-array/setProps.md) - * [trigger](./wrapper-array/trigger.md) +* [WrapperArray](./wrapper-Array/README.md) + * [at](./wrapper-Array/at.md) + * [contains](./wrapper-Array/contains.md) + * [hasAttribute](./wrapper-Array/hasAttribute.md) + * [hasClass](./wrapper-Array/hasClass.md) + * [hasProp](./wrapper-Array/hasProp.md) + * [hasStyle](./wrapper-Array/hasStyle.md) + * [is](./wrapper-Array/is.md) + * [isEmpty](./wrapper-Array/isEmpty.md) + * [isVueInstance](./wrapper-Array/isVueInstance.md) + * [update](./wrapper-Array/update.md) + * [setData](./wrapper-Array/setData.md) + * [setProps](./wrapper-Array/setProps.md) + * [trigger](./wrapper-Array/trigger.md) * [createLocalVue](./createLocalVue.md) * [Seletores](./selectors.md) diff --git a/docs/pt-br/api/config.md b/docs/pt-br/api/config.md index 4bdcb3750..cc5f24f0a 100644 --- a/docs/pt-br/api/config.md +++ b/docs/pt-br/api/config.md @@ -14,7 +14,7 @@ O vue-test-utils apresenta um objeto de configuração para que você possa defi Esboços são usados em todos componentes. Eles são substituídos pelos esboços passados nas opções da montagem. -Quando você passa os esboços como um array de string nas opções de montagens, o `config.stubs` é convertido em um array e os componentes são esboçados com um componente que retorna uma div. +Quando você passa os esboços como um Array de string nas opções de montagens, o `config.stubs` é convertido em um Array e os componentes são esboçados com um componente que retorna uma div. Exemplho: diff --git a/docs/pt-br/api/options.md b/docs/pt-br/api/options.md index 2ea624674..021c22e97 100644 --- a/docs/pt-br/api/options.md +++ b/docs/pt-br/api/options.md @@ -38,7 +38,7 @@ expect(wrapper.is(Componente)).toBe(true) - tipo: `{ [name: string]: Array|Component|string }` -Forneça um objeto do slot para o componente. A chave corresponde ao nome do slot. O valor pode ser um componentem um array de componentes ou uma template string. +Forneça um objeto do slot para o componente. A chave corresponde ao nome do slot. O valor pode ser um componentem um Array de componentes ou uma template string. Exemplo: @@ -61,7 +61,7 @@ expect(wrapper.find('div')).toBe(true) - tipo: `{ [name: string]: Component | boolean } | Array` -Esboça os componentes filhos. Pode ser um array com os nomes dos componentes ou um objeto. +Esboça os componentes filhos. Pode ser um Array com os nomes dos componentes ou um objeto. Exemplo: diff --git a/docs/pt-br/api/wrapper-array/README.md b/docs/pt-br/api/wrapper-array/README.md index d0d452311..eec9b4d17 100644 --- a/docs/pt-br/api/wrapper-array/README.md +++ b/docs/pt-br/api/wrapper-array/README.md @@ -1,10 +1,10 @@ -# WrapperArray (array de wrappers) +# WrapperArray (Array de wrappers) -Um array de wrappers é um objeto que contem uma lista com [Wrappers](../wrapper/README.md), e os alguns métodos para testar esses wrappers. +Um Array de wrappers é um objeto que contem uma lista com [Wrappers](../wrapper/README.md), e os alguns métodos para testar esses wrappers. - **Propriedades:** -`length` `number`: O número de wrappers contidos nesse array. +`length` `number`: O número de wrappers contidos nesse Array. - **Métodos:** diff --git a/docs/pt-br/api/wrapper-array/contains.md b/docs/pt-br/api/wrapper-array/contains.md index f9eac958d..4f6c033b8 100644 --- a/docs/pt-br/api/wrapper-array/contains.md +++ b/docs/pt-br/api/wrapper-array/contains.md @@ -1,6 +1,6 @@ # contains(seletor) -Verifica se cada wrapper do array contém correspondência do seletor informado. +Verifica se cada wrapper do Array contém correspondência do seletor informado. Use qualquer [seletor](../selectors.md) válido. diff --git a/docs/pt-br/api/wrapper-array/destroy.md b/docs/pt-br/api/wrapper-array/destroy.md index 736ba8647..0cf53a90d 100644 --- a/docs/pt-br/api/wrapper-array/destroy.md +++ b/docs/pt-br/api/wrapper-array/destroy.md @@ -1,6 +1,6 @@ # destroy() -Destroí a instância do Vue da cada um dos wrappers do array. +Destroí a instância do Vue da cada um dos wrappers do Array. - **Exemplo:** diff --git a/docs/pt-br/api/wrapper-array/hasAttribute.md b/docs/pt-br/api/wrapper-array/hasAttribute.md index 8453d2883..f8d687045 100644 --- a/docs/pt-br/api/wrapper-array/hasAttribute.md +++ b/docs/pt-br/api/wrapper-array/hasAttribute.md @@ -1,6 +1,6 @@ # hasAttribute(atributo, valor) -Verifica se algum wrapper do array tem o `atributo` com `valor` correspondente no elemento do DOM. +Verifica se algum wrapper do Array tem o `atributo` com `valor` correspondente no elemento do DOM. - **Argumentos:** - `{string} atributo` diff --git a/docs/pt-br/api/wrapper-array/hasClass.md b/docs/pt-br/api/wrapper-array/hasClass.md index 2a238d85a..c9bdc5079 100644 --- a/docs/pt-br/api/wrapper-array/hasClass.md +++ b/docs/pt-br/api/wrapper-array/hasClass.md @@ -1,6 +1,6 @@ # hasClass(nomeDaClasse) -Verifica se algum wrapper do array contém uma classe com o nome `nomeDaClasse` no elemento do DOM. +Verifica se algum wrapper do Array contém uma classe com o nome `nomeDaClasse` no elemento do DOM. - **Argumentos:** - `{string} nomeDaClasse` diff --git a/docs/pt-br/api/wrapper-array/hasProp.md b/docs/pt-br/api/wrapper-array/hasProp.md index 3427eaf91..990813c71 100644 --- a/docs/pt-br/api/wrapper-array/hasProp.md +++ b/docs/pt-br/api/wrapper-array/hasProp.md @@ -1,6 +1,6 @@ # hasProp(propriedade, valor) -Verifica se algum wrapper do array possui a `propriedade` com o `valor` no `vm`. +Verifica se algum wrapper do Array possui a `propriedade` com o `valor` no `vm`. **Nota: o wrapper deve ser uma intância do Vue.** diff --git a/docs/pt-br/api/wrapper-array/hasStyle.md b/docs/pt-br/api/wrapper-array/hasStyle.md index 6b74afa38..deb9f9191 100644 --- a/docs/pt-br/api/wrapper-array/hasStyle.md +++ b/docs/pt-br/api/wrapper-array/hasStyle.md @@ -1,6 +1,6 @@ # hasStyle(estilo, valor) -Verifica se algum wrapper do array tem o `estilo` com o `valor` no elemento do DOM. +Verifica se algum wrapper do Array tem o `estilo` com o `valor` no elemento do DOM. Retorna `true` se o wrapper contém o `estilo` com o `valor`. diff --git a/docs/pt-br/api/wrapper-array/is.md b/docs/pt-br/api/wrapper-array/is.md index 32c8e0f25..c70b8ff93 100644 --- a/docs/pt-br/api/wrapper-array/is.md +++ b/docs/pt-br/api/wrapper-array/is.md @@ -1,6 +1,6 @@ # is(seletor) -Verifica se algum wrapper do array possui o [seletor](../selectors.md) no seu `vm`. +Verifica se algum wrapper do Array possui o [seletor](../selectors.md) no seu `vm`. - **Argumentos:** - `{string|Component} seletor` diff --git a/docs/pt-br/api/wrapper-array/isEmpty.md b/docs/pt-br/api/wrapper-array/isEmpty.md index b299fac66..4e4bf8bc0 100644 --- a/docs/pt-br/api/wrapper-array/isEmpty.md +++ b/docs/pt-br/api/wrapper-array/isEmpty.md @@ -1,6 +1,6 @@ # isEmpty() -Verifica se algum wrapper do array não tem um elemento filho. +Verifica se algum wrapper do Array não tem um elemento filho. - **Retorna:** `{boolean}` diff --git a/docs/pt-br/api/wrapper-array/isVueInstance.md b/docs/pt-br/api/wrapper-array/isVueInstance.md index 116e0ba0d..d4c1f1746 100644 --- a/docs/pt-br/api/wrapper-array/isVueInstance.md +++ b/docs/pt-br/api/wrapper-array/isVueInstance.md @@ -1,6 +1,6 @@ # isVueInstance() -Verifica se algum wrapper do array é uma instância do Vue. +Verifica se algum wrapper do Array é uma instância do Vue. - **Retorna:** `{boolean}` diff --git a/docs/pt-br/api/wrapper-array/setComputed.md b/docs/pt-br/api/wrapper-array/setComputed.md index 51fd90ead..9648b305e 100644 --- a/docs/pt-br/api/wrapper-array/setComputed.md +++ b/docs/pt-br/api/wrapper-array/setComputed.md @@ -1,6 +1,6 @@ # setComputed(propriedadesComputadas) -Define as propriedades computadas e força a atualização de cada um dos wrappers no array. +Define as propriedades computadas e força a atualização de cada um dos wrappers no Array. **Nota: cada wrapper deve ser uma instância do Vue.** **Nota2: cada instância de cada wrapper deve ter as propriedades computadas já declaradas, pois esse método apenas mocka o seu valor.** diff --git a/docs/pt-br/api/wrapper-array/setData.md b/docs/pt-br/api/wrapper-array/setData.md index e16bbabb6..56f3466f6 100644 --- a/docs/pt-br/api/wrapper-array/setData.md +++ b/docs/pt-br/api/wrapper-array/setData.md @@ -1,6 +1,6 @@ # setData(dados) -Define os dados e força a atualização de cada wrapper presente no array. +Define os dados e força a atualização de cada wrapper presente no Array. **Nota: cada wrapper deve ser uma instância do Vue.** diff --git a/docs/pt-br/api/wrapper-array/setMethods.md b/docs/pt-br/api/wrapper-array/setMethods.md index daad37019..975e02b10 100644 --- a/docs/pt-br/api/wrapper-array/setMethods.md +++ b/docs/pt-br/api/wrapper-array/setMethods.md @@ -1,6 +1,6 @@ # setMethods(metodos) -Define os métodos do componente e força sua atualização para cada wrapper no array. +Define os métodos do componente e força sua atualização para cada wrapper no Array. **Nota: cada wrapper deve ser uma instância do Vue.** diff --git a/docs/pt-br/api/wrapper-array/setProps.md b/docs/pt-br/api/wrapper-array/setProps.md index 079649c1a..87bf8d3b8 100644 --- a/docs/pt-br/api/wrapper-array/setProps.md +++ b/docs/pt-br/api/wrapper-array/setProps.md @@ -1,6 +1,6 @@ # setProps(propriedades) -Define as `propriedades` do componente e força sua atualização para cada wrapper no array. +Define as `propriedades` do componente e força sua atualização para cada wrapper no Array. **Nota: cada wrapper deve ser uma instância do Vue.** diff --git a/docs/pt-br/api/wrapper-array/trigger.md b/docs/pt-br/api/wrapper-array/trigger.md index 8ed7a07b0..68edeec28 100644 --- a/docs/pt-br/api/wrapper-array/trigger.md +++ b/docs/pt-br/api/wrapper-array/trigger.md @@ -1,6 +1,6 @@ # trigger(nomeDoEvento) -Aciona um evento no elemeto do DOM de cada wrapper no array. +Aciona um evento no elemeto do DOM de cada wrapper no Array. **Nota: cada wrapper deve ser uma instância do Vue.** diff --git a/docs/pt-br/api/wrapper-array/update.md b/docs/pt-br/api/wrapper-array/update.md index 0c912a6a0..a67237565 100644 --- a/docs/pt-br/api/wrapper-array/update.md +++ b/docs/pt-br/api/wrapper-array/update.md @@ -1,8 +1,8 @@ # update() -Força a atualização e redesenho do componente Vue de cada wrapper do array. +Força a atualização e redesenho do componente Vue de cada wrapper do Array. -Se for chamado a partir de um componente Vue, força a atualização de cada componente do array. +Se for chamado a partir de um componente Vue, força a atualização de cada componente do Array. - **Exemplo:** diff --git a/docs/pt-br/api/wrapper/emittedByOrder.md b/docs/pt-br/api/wrapper/emittedByOrder.md index f84f62bb7..79061998f 100644 --- a/docs/pt-br/api/wrapper/emittedByOrder.md +++ b/docs/pt-br/api/wrapper/emittedByOrder.md @@ -1,6 +1,6 @@ # emittedByOrder() -Retorna um array contendo os eventos customizados emitidos pelo `vm` do wrapper. +Retorna um Array contendo os eventos customizados emitidos pelo `vm` do wrapper. - **Retorna:** `Array<{ name: string, args: Array }>` @@ -16,7 +16,7 @@ wrapper.vm.$emit('foo') wrapper.vm.$emit('bar', 123) /* -wrapper.emittedByOrder() retorna o seguinte array: +wrapper.emittedByOrder() retorna o seguinte Array: [ { name: 'foo', args: [] }, { name: 'bar', args: [123] } diff --git a/docs/pt-br/api/wrapper/findAll.md b/docs/pt-br/api/wrapper/findAll.md index f8a96571a..1d4c4cce9 100644 --- a/docs/pt-br/api/wrapper/findAll.md +++ b/docs/pt-br/api/wrapper/findAll.md @@ -1,6 +1,6 @@ # findAll(seletor) -Retorna um [`WrapperArray`](../wrapper-array/README.md) de [Wrappers](README.md). +Retorna um [`WrapperArray`](../wrapper-Array/README.md) de [Wrappers](README.md). Use qualquer [seletor](../selectors.md) válido. From 6ccc0b2db3293ce3b6a4be242fe92982ccb213e2 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 22:02:42 +0000 Subject: [PATCH 65/71] feat(docs): change word 'string' to 'String' --- docs/pt-br/api/config.md | 2 +- docs/pt-br/api/options.md | 6 +++--- docs/pt-br/api/shallow.md | 2 +- docs/pt-br/api/wrapper-array/contains.md | 2 +- docs/pt-br/api/wrapper-array/hasAttribute.md | 4 ++-- docs/pt-br/api/wrapper-array/hasClass.md | 2 +- docs/pt-br/api/wrapper-array/hasProp.md | 2 +- docs/pt-br/api/wrapper-array/hasStyle.md | 4 ++-- docs/pt-br/api/wrapper-array/is.md | 2 +- docs/pt-br/api/wrapper-array/trigger.md | 2 +- docs/pt-br/api/wrapper/contains.md | 2 +- docs/pt-br/api/wrapper/emitted.md | 2 +- docs/pt-br/api/wrapper/emittedByOrder.md | 2 +- docs/pt-br/api/wrapper/find.md | 2 +- docs/pt-br/api/wrapper/findAll.md | 2 +- docs/pt-br/api/wrapper/hasAttribute.md | 4 ++-- docs/pt-br/api/wrapper/hasClass.md | 2 +- docs/pt-br/api/wrapper/hasProp.md | 2 +- docs/pt-br/api/wrapper/hasStyle.md | 4 ++-- docs/pt-br/api/wrapper/html.md | 4 ++-- docs/pt-br/api/wrapper/is.md | 2 +- docs/pt-br/api/wrapper/name.md | 2 +- docs/pt-br/api/wrapper/text.md | 2 +- docs/pt-br/api/wrapper/trigger.md | 2 +- docs/pt-br/guides/testing-SFCs-with-jest.md | 4 ++-- 25 files changed, 33 insertions(+), 33 deletions(-) diff --git a/docs/pt-br/api/config.md b/docs/pt-br/api/config.md index cc5f24f0a..963a5b76e 100644 --- a/docs/pt-br/api/config.md +++ b/docs/pt-br/api/config.md @@ -14,7 +14,7 @@ O vue-test-utils apresenta um objeto de configuração para que você possa defi Esboços são usados em todos componentes. Eles são substituídos pelos esboços passados nas opções da montagem. -Quando você passa os esboços como um Array de string nas opções de montagens, o `config.stubs` é convertido em um Array e os componentes são esboçados com um componente que retorna uma div. +Quando você passa os esboços como um Array de String nas opções de montagens, o `config.stubs` é convertido em um Array e os componentes são esboçados com um componente que retorna uma div. Exemplho: diff --git a/docs/pt-br/api/options.md b/docs/pt-br/api/options.md index 021c22e97..cf037b814 100644 --- a/docs/pt-br/api/options.md +++ b/docs/pt-br/api/options.md @@ -36,9 +36,9 @@ expect(wrapper.is(Componente)).toBe(true) ### `slots` -- tipo: `{ [name: string]: Array|Component|string }` +- tipo: `{ [name: String]: Array|Component|String }` -Forneça um objeto do slot para o componente. A chave corresponde ao nome do slot. O valor pode ser um componentem um Array de componentes ou uma template string. +Forneça um objeto do slot para o componente. A chave corresponde ao nome do slot. O valor pode ser um componentem um Array de componentes ou uma template String. Exemplo: @@ -59,7 +59,7 @@ expect(wrapper.find('div')).toBe(true) ### Esboços -- tipo: `{ [name: string]: Component | boolean } | Array` +- tipo: `{ [name: String]: Component | boolean } | Array` Esboça os componentes filhos. Pode ser um Array com os nomes dos componentes ou um objeto. diff --git a/docs/pt-br/api/shallow.md b/docs/pt-br/api/shallow.md index 54b418e87..4c6c6f78d 100644 --- a/docs/pt-br/api/shallow.md +++ b/docs/pt-br/api/shallow.md @@ -10,7 +10,7 @@ - `{Array|Component|String} default` - `{Array|Component|String} named` - `{Object} mocks` - - `{Object|Array} stubs` + - `{Object|Array} stubs` - `{boolean} clone` - `{Object} children` - `{Vue} localVue` diff --git a/docs/pt-br/api/wrapper-array/contains.md b/docs/pt-br/api/wrapper-array/contains.md index 4f6c033b8..6e4a5ff95 100644 --- a/docs/pt-br/api/wrapper-array/contains.md +++ b/docs/pt-br/api/wrapper-array/contains.md @@ -5,7 +5,7 @@ Verifica se cada wrapper do Array contém correspondência do seletor informado. Use qualquer [seletor](../selectors.md) válido. - **Argumentos:** - - `{string|Component} seletor` + - `{String|Component} seletor` - **Retorna:** `{boolean}` diff --git a/docs/pt-br/api/wrapper-array/hasAttribute.md b/docs/pt-br/api/wrapper-array/hasAttribute.md index f8d687045..b9a171b39 100644 --- a/docs/pt-br/api/wrapper-array/hasAttribute.md +++ b/docs/pt-br/api/wrapper-array/hasAttribute.md @@ -3,8 +3,8 @@ Verifica se algum wrapper do Array tem o `atributo` com `valor` correspondente no elemento do DOM. - **Argumentos:** - - `{string} atributo` - - `{string} valor` + - `{String} atributo` + - `{String} valor` - **Retorna:** `{boolean}` diff --git a/docs/pt-br/api/wrapper-array/hasClass.md b/docs/pt-br/api/wrapper-array/hasClass.md index c9bdc5079..99bf0dd5d 100644 --- a/docs/pt-br/api/wrapper-array/hasClass.md +++ b/docs/pt-br/api/wrapper-array/hasClass.md @@ -3,7 +3,7 @@ Verifica se algum wrapper do Array contém uma classe com o nome `nomeDaClasse` no elemento do DOM. - **Argumentos:** - - `{string} nomeDaClasse` + - `{String} nomeDaClasse` - **Retorna:** `{boolean}` diff --git a/docs/pt-br/api/wrapper-array/hasProp.md b/docs/pt-br/api/wrapper-array/hasProp.md index 990813c71..c3c9a3387 100644 --- a/docs/pt-br/api/wrapper-array/hasProp.md +++ b/docs/pt-br/api/wrapper-array/hasProp.md @@ -5,7 +5,7 @@ Verifica se algum wrapper do Array possui a `propriedade` com o `valor` no `vm`. **Nota: o wrapper deve ser uma intância do Vue.** - **Argumentos:** - - `{string} propriedade` + - `{String} propriedade` - `{any} valor` - **Retorna:** `{boolean}` diff --git a/docs/pt-br/api/wrapper-array/hasStyle.md b/docs/pt-br/api/wrapper-array/hasStyle.md index deb9f9191..e85ea29bb 100644 --- a/docs/pt-br/api/wrapper-array/hasStyle.md +++ b/docs/pt-br/api/wrapper-array/hasStyle.md @@ -7,8 +7,8 @@ Retorna `true` se o wrapper contém o `estilo` com o `valor`. **Nota: para detectarmos os estilos deve-se usar o `jsdom`.** - **Argumentos:** - - `{string} estilo` - - `{string} valor` + - `{String} estilo` + - `{String} valor` - **Retorna:** `{boolean}` diff --git a/docs/pt-br/api/wrapper-array/is.md b/docs/pt-br/api/wrapper-array/is.md index c70b8ff93..786352e3b 100644 --- a/docs/pt-br/api/wrapper-array/is.md +++ b/docs/pt-br/api/wrapper-array/is.md @@ -3,7 +3,7 @@ Verifica se algum wrapper do Array possui o [seletor](../selectors.md) no seu `vm`. - **Argumentos:** - - `{string|Component} seletor` + - `{String|Component} seletor` - **Retorna:** `{boolean}` diff --git a/docs/pt-br/api/wrapper-array/trigger.md b/docs/pt-br/api/wrapper-array/trigger.md index 68edeec28..cc848ca6d 100644 --- a/docs/pt-br/api/wrapper-array/trigger.md +++ b/docs/pt-br/api/wrapper-array/trigger.md @@ -5,7 +5,7 @@ Aciona um evento no elemeto do DOM de cada wrapper no Array. **Nota: cada wrapper deve ser uma instância do Vue.** - **Argumentos:** - - `{string} nomeDoEvento` + - `{String} nomeDoEvento` - **Exemplo:** diff --git a/docs/pt-br/api/wrapper/contains.md b/docs/pt-br/api/wrapper/contains.md index 6a98a529d..f2f6b7ef3 100644 --- a/docs/pt-br/api/wrapper/contains.md +++ b/docs/pt-br/api/wrapper/contains.md @@ -3,7 +3,7 @@ Verifica se o wrapper contém um elemento ou componente com o [seletor](../selectors.md) informado. - **Argumentos:** - - `{string|Component} seletor` + - `{String|Component} seletor` - **Retorna:** `{boolean}` diff --git a/docs/pt-br/api/wrapper/emitted.md b/docs/pt-br/api/wrapper/emitted.md index 7a72367b1..e62207bd9 100644 --- a/docs/pt-br/api/wrapper/emitted.md +++ b/docs/pt-br/api/wrapper/emitted.md @@ -2,7 +2,7 @@ Retorna um objeto contendo os eventos cutomizados emitidos pelo `vm` do wrapper. -- **Retorna:** `{ [name: string]: Array> }` +- **Retorna:** `{ [name: String]: Array> }` - **Exemplo:** diff --git a/docs/pt-br/api/wrapper/emittedByOrder.md b/docs/pt-br/api/wrapper/emittedByOrder.md index 79061998f..5421e8c91 100644 --- a/docs/pt-br/api/wrapper/emittedByOrder.md +++ b/docs/pt-br/api/wrapper/emittedByOrder.md @@ -2,7 +2,7 @@ Retorna um Array contendo os eventos customizados emitidos pelo `vm` do wrapper. -- **Retorna:** `Array<{ name: string, args: Array }>` +- **Retorna:** `Array<{ name: String, args: Array }>` - **Exemplo:** diff --git a/docs/pt-br/api/wrapper/find.md b/docs/pt-br/api/wrapper/find.md index 1cbcb485a..651c87fd9 100644 --- a/docs/pt-br/api/wrapper/find.md +++ b/docs/pt-br/api/wrapper/find.md @@ -5,7 +5,7 @@ Retorna um wrapper [`Wrapper`](README.md) com o primeiro elmento do DOM ou o com Use any valiUse qualquer [seletor](../selectors.md) válido. - **Argumentos:** - - `{string|Component} seletor` + - `{String|Component} seletor` - **Retorna:** `{Wrapper}` diff --git a/docs/pt-br/api/wrapper/findAll.md b/docs/pt-br/api/wrapper/findAll.md index 1d4c4cce9..b51619017 100644 --- a/docs/pt-br/api/wrapper/findAll.md +++ b/docs/pt-br/api/wrapper/findAll.md @@ -5,7 +5,7 @@ Retorna um [`WrapperArray`](../wrapper-Array/README.md) de [Wrappers](README.md) Use qualquer [seletor](../selectors.md) válido. - **Argumentos:** - - `{string|Component} seletor` + - `{String|Component} seletor` - **Retorna:** `{WrapperArray}` diff --git a/docs/pt-br/api/wrapper/hasAttribute.md b/docs/pt-br/api/wrapper/hasAttribute.md index 02d7b9eef..436c62df5 100644 --- a/docs/pt-br/api/wrapper/hasAttribute.md +++ b/docs/pt-br/api/wrapper/hasAttribute.md @@ -5,8 +5,8 @@ Verifica se o wrapper contém o atributo mencionado no seu elemento do DOM. Retorna `true` se o wrapper contém o atributo. - **Argumentos:** - - `{string} atributo` - - `{string} valor` + - `{String} atributo` + - `{String} valor` - **Retorna:** `{boolean}` diff --git a/docs/pt-br/api/wrapper/hasClass.md b/docs/pt-br/api/wrapper/hasClass.md index 4d1fbf7f6..8d608caa2 100644 --- a/docs/pt-br/api/wrapper/hasClass.md +++ b/docs/pt-br/api/wrapper/hasClass.md @@ -5,7 +5,7 @@ Verifica se o wrapper do elemento do DOM contém uma classe informada pelo `nome Retorna `true` se o wrapper contém a classe. - **Argumentos:** - - `{string} nomeDaClasse` + - `{String} nomeDaClasse` - **Retorna:** `{boolean}` diff --git a/docs/pt-br/api/wrapper/hasProp.md b/docs/pt-br/api/wrapper/hasProp.md index caba69caa..da00f8e79 100644 --- a/docs/pt-br/api/wrapper/hasProp.md +++ b/docs/pt-br/api/wrapper/hasProp.md @@ -7,7 +7,7 @@ Retorna `true` se o `vm` do wrapper tem a `propriedade` com o `valor` passado. **Nota: o wrapper deve conter uma instância do Vue.** - **Argumentos:** - - `{string} propriedade` + - `{String} propriedade` - `{any} valor` - **Retorna:** `{boolean}` diff --git a/docs/pt-br/api/wrapper/hasStyle.md b/docs/pt-br/api/wrapper/hasStyle.md index 1a49fca43..f52231317 100644 --- a/docs/pt-br/api/wrapper/hasStyle.md +++ b/docs/pt-br/api/wrapper/hasStyle.md @@ -7,8 +7,8 @@ Retorna `true` se o wrapper possui um `estilo` com o `valor`. **Nota: só iremos detectar os estilos quando executado com o `jsdom`.** - **Argumentos:** - - `{string} estilo` - - `{string} valor` + - `{String} estilo` + - `{String} valor` - **Retorna:** `{boolean}` diff --git a/docs/pt-br/api/wrapper/html.md b/docs/pt-br/api/wrapper/html.md index b8282f70a..8f504fda3 100644 --- a/docs/pt-br/api/wrapper/html.md +++ b/docs/pt-br/api/wrapper/html.md @@ -1,8 +1,8 @@ # html() -Retorna o HTML do elemento do wrapper como uma string. +Retorna o HTML do elemento do wrapper como uma String. -- **Retorna:** `{string}` +- **Retorna:** `{String}` - **Exemplo:** diff --git a/docs/pt-br/api/wrapper/is.md b/docs/pt-br/api/wrapper/is.md index e29cd8c8c..94b0ca437 100644 --- a/docs/pt-br/api/wrapper/is.md +++ b/docs/pt-br/api/wrapper/is.md @@ -3,7 +3,7 @@ Verifica se o `vm` do wrapper possui o [seletor](../selectors.md) informado. - **Argumentos:** - - `{string|Component} seletor` + - `{String|Component} seletor` - **Retorna:** `{boolean}` diff --git a/docs/pt-br/api/wrapper/name.md b/docs/pt-br/api/wrapper/name.md index 8babd9c73..787a2ae83 100644 --- a/docs/pt-br/api/wrapper/name.md +++ b/docs/pt-br/api/wrapper/name.md @@ -2,7 +2,7 @@ Retorna o nome do componente se o wrapper for uma instância do Vue, ou então o nome da tag se o wrapper for um elemento do DOM e não for uma instância do Vue. -- **Retorna:** `{string}` +- **Retorna:** `{String}` - **Exemplo:** diff --git a/docs/pt-br/api/wrapper/text.md b/docs/pt-br/api/wrapper/text.md index 351114556..e1a4e52b3 100644 --- a/docs/pt-br/api/wrapper/text.md +++ b/docs/pt-br/api/wrapper/text.md @@ -2,7 +2,7 @@ Retorna o texto contido no wrapper. -- **Retorna:** `{string}` +- **Retorna:** `{String}` - **Exemplo:** diff --git a/docs/pt-br/api/wrapper/trigger.md b/docs/pt-br/api/wrapper/trigger.md index c57f9cfbb..455e3e214 100644 --- a/docs/pt-br/api/wrapper/trigger.md +++ b/docs/pt-br/api/wrapper/trigger.md @@ -7,7 +7,7 @@ O método `trigger` usa o objeto opicional `opcoes`, essas opções serão adici Você pode rodar o preventDefault em um evento passando `preventDefault: true` no objeto de `opcoes`. - **Argumentos:** - - `{string} nomeDoEvento` + - `{String} nomeDoEvento` - `{Object} opcoes` - `{boolean} preventDefault` diff --git a/docs/pt-br/guides/testing-SFCs-with-jest.md b/docs/pt-br/guides/testing-SFCs-with-jest.md index e28ac0dbb..6eb88cb6c 100644 --- a/docs/pt-br/guides/testing-SFCs-with-jest.md +++ b/docs/pt-br/guides/testing-SFCs-with-jest.md @@ -125,7 +125,7 @@ Exemplo do novo `.babelrc`: ### Teste instantâneo -Você pode usar o [`vue-server-renderer`](https://github.com/vuejs/vue/tree/dev/packages/vue-server-renderer) para transformar um componente em uma string para que ele possa ser salvo como instântaneo para o [teste instântaneo com Jest](https://facebook.github.io/jest/docs/en/snapshot-testing.html). +Você pode usar o [`vue-server-renderer`](https://github.com/vuejs/vue/tree/dev/packages/vue-server-renderer) para transformar um componente em uma String para que ele possa ser salvo como instântaneo para o [teste instântaneo com Jest](https://facebook.github.io/jest/docs/en/snapshot-testing.html). O resultado do `vue-server-renderer` inclui alguns atributos específicos de SSR e ignora espaços em branco, dificultando a detecção de um diff. Podemos melhorar o instantâneo salvo com um serializador personalizado: @@ -150,7 +150,7 @@ Em seguida, configure-o no `package.json`: ### Colocando arquivos de teste -Por padrão, o Jest irá recursivamente pegar todos os arquivosque tenham uma extensão `.spec.js` ou `.test.js` em todo o seu projeto. Se isso não for de acordo com o seu esperado, é possível [alterar o testRegex](https://facebook.github.io/jest/docs/en/configuration.html#testregex-string) na seção `config` no arquivo `package.json`. +Por padrão, o Jest irá recursivamente pegar todos os arquivosque tenham uma extensão `.spec.js` ou `.test.js` em todo o seu projeto. Se isso não for de acordo com o seu esperado, é possível [alterar o testRegex](https://facebook.github.io/jest/docs/en/configuration.html#testregex-String) na seção `config` no arquivo `package.json`. O Jest recomenda a criação de um diretório `__tests__` logo ao lado do código que está sendo testado, mas sinta-se livre para estruturar seus testes conforme entender. Apenas tenha cuidado com o fato de o Jest criar um diretório `__snapshots__` ao lado dos arquivos de teste que executam testes instantâneos. From e411fc358b5f3f8d1102159fe398bb30f7610eda Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 22:04:57 +0000 Subject: [PATCH 66/71] feat(docs): change word 'boolean' to 'Boolean' --- docs/pt-br/api/options.md | 6 +++--- docs/pt-br/api/shallow.md | 4 ++-- docs/pt-br/api/wrapper-array/contains.md | 2 +- docs/pt-br/api/wrapper-array/hasAttribute.md | 2 +- docs/pt-br/api/wrapper-array/hasClass.md | 2 +- docs/pt-br/api/wrapper-array/hasProp.md | 2 +- docs/pt-br/api/wrapper-array/hasStyle.md | 2 +- docs/pt-br/api/wrapper-array/is.md | 2 +- docs/pt-br/api/wrapper-array/isEmpty.md | 2 +- docs/pt-br/api/wrapper-array/isVueInstance.md | 2 +- docs/pt-br/api/wrapper/contains.md | 2 +- docs/pt-br/api/wrapper/exists.md | 2 +- docs/pt-br/api/wrapper/hasAttribute.md | 2 +- docs/pt-br/api/wrapper/hasClass.md | 2 +- docs/pt-br/api/wrapper/hasProp.md | 2 +- docs/pt-br/api/wrapper/hasStyle.md | 2 +- docs/pt-br/api/wrapper/is.md | 2 +- docs/pt-br/api/wrapper/isEmpty.md | 2 +- docs/pt-br/api/wrapper/isVueInstance.md | 2 +- docs/pt-br/api/wrapper/trigger.md | 2 +- 20 files changed, 23 insertions(+), 23 deletions(-) diff --git a/docs/pt-br/api/options.md b/docs/pt-br/api/options.md index cf037b814..fbfc5f240 100644 --- a/docs/pt-br/api/options.md +++ b/docs/pt-br/api/options.md @@ -59,7 +59,7 @@ expect(wrapper.find('div')).toBe(true) ### Esboços -- tipo: `{ [name: String]: Component | boolean } | Array` +- tipo: `{ [name: String]: Component | Boolean } | Array` Esboça os componentes filhos. Pode ser um Array com os nomes dos componentes ou um objeto. @@ -136,7 +136,7 @@ expect(wrapper.vm.$route).toBeInstanceOf(Object) ### `attachToDocument` -- tipo: `boolean` +- tipo: `Boolean` - padrão: `false` O componente será anexado ao DOM quando configurado como `true`. Isso pode ser usado com o [`hasStyle`](wrapper/hasStyle.md) para verificar os seletores do CSS de vários elementos. @@ -155,7 +155,7 @@ Define o objeto `$listeners` da instância do componente. ### `clone` -- tipo: `boolean` +- tipo: `Boolean` - padrão: `true` Clona o componente antes de monta-lo se o valor for `true`, evitando qualquer mutação no componente original. diff --git a/docs/pt-br/api/shallow.md b/docs/pt-br/api/shallow.md index 4c6c6f78d..48448c8d3 100644 --- a/docs/pt-br/api/shallow.md +++ b/docs/pt-br/api/shallow.md @@ -4,14 +4,14 @@ - `{Component} componente` - `{Object} opcoes` - - `{boolean} attachToDocument` + - `{Boolean} attachToDocument` - `{Object} context` - `{Object} slots` - `{Array|Component|String} default` - `{Array|Component|String} named` - `{Object} mocks` - `{Object|Array} stubs` - - `{boolean} clone` + - `{Boolean} clone` - `{Object} children` - `{Vue} localVue` diff --git a/docs/pt-br/api/wrapper-array/contains.md b/docs/pt-br/api/wrapper-array/contains.md index 6e4a5ff95..e7a1e5878 100644 --- a/docs/pt-br/api/wrapper-array/contains.md +++ b/docs/pt-br/api/wrapper-array/contains.md @@ -7,7 +7,7 @@ Use qualquer [seletor](../selectors.md) válido. - **Argumentos:** - `{String|Component} seletor` -- **Retorna:** `{boolean}` +- **Retorna:** `{Boolean}` - **Exemplo:** diff --git a/docs/pt-br/api/wrapper-array/hasAttribute.md b/docs/pt-br/api/wrapper-array/hasAttribute.md index b9a171b39..eb641120e 100644 --- a/docs/pt-br/api/wrapper-array/hasAttribute.md +++ b/docs/pt-br/api/wrapper-array/hasAttribute.md @@ -6,7 +6,7 @@ Verifica se algum wrapper do Array tem o `atributo` com `valor` correspondente n - `{String} atributo` - `{String} valor` -- **Retorna:** `{boolean}` +- **Retorna:** `{Boolean}` - **Exemplo:** diff --git a/docs/pt-br/api/wrapper-array/hasClass.md b/docs/pt-br/api/wrapper-array/hasClass.md index 99bf0dd5d..a87b4fd7d 100644 --- a/docs/pt-br/api/wrapper-array/hasClass.md +++ b/docs/pt-br/api/wrapper-array/hasClass.md @@ -5,7 +5,7 @@ Verifica se algum wrapper do Array contém uma classe com o nome `nomeDaClasse` - **Argumentos:** - `{String} nomeDaClasse` -- **Retorna:** `{boolean}` +- **Retorna:** `{Boolean}` - **Exemplo:** diff --git a/docs/pt-br/api/wrapper-array/hasProp.md b/docs/pt-br/api/wrapper-array/hasProp.md index c3c9a3387..50056257b 100644 --- a/docs/pt-br/api/wrapper-array/hasProp.md +++ b/docs/pt-br/api/wrapper-array/hasProp.md @@ -8,7 +8,7 @@ Verifica se algum wrapper do Array possui a `propriedade` com o `valor` no `vm`. - `{String} propriedade` - `{any} valor` -- **Retorna:** `{boolean}` +- **Retorna:** `{Boolean}` - **Exemplo:** diff --git a/docs/pt-br/api/wrapper-array/hasStyle.md b/docs/pt-br/api/wrapper-array/hasStyle.md index e85ea29bb..2fc61c73f 100644 --- a/docs/pt-br/api/wrapper-array/hasStyle.md +++ b/docs/pt-br/api/wrapper-array/hasStyle.md @@ -10,7 +10,7 @@ Retorna `true` se o wrapper contém o `estilo` com o `valor`. - `{String} estilo` - `{String} valor` -- **Retorna:** `{boolean}` +- **Retorna:** `{Boolean}` - **Exemplo:** diff --git a/docs/pt-br/api/wrapper-array/is.md b/docs/pt-br/api/wrapper-array/is.md index 786352e3b..5815c780c 100644 --- a/docs/pt-br/api/wrapper-array/is.md +++ b/docs/pt-br/api/wrapper-array/is.md @@ -5,7 +5,7 @@ Verifica se algum wrapper do Array possui o [seletor](../selectors.md) no seu `v - **Argumentos:** - `{String|Component} seletor` -- **Retorna:** `{boolean}` +- **Retorna:** `{Boolean}` - **Exemplo:** diff --git a/docs/pt-br/api/wrapper-array/isEmpty.md b/docs/pt-br/api/wrapper-array/isEmpty.md index 4e4bf8bc0..83fc9b324 100644 --- a/docs/pt-br/api/wrapper-array/isEmpty.md +++ b/docs/pt-br/api/wrapper-array/isEmpty.md @@ -2,7 +2,7 @@ Verifica se algum wrapper do Array não tem um elemento filho. -- **Retorna:** `{boolean}` +- **Retorna:** `{Boolean}` - **Exemplo:** diff --git a/docs/pt-br/api/wrapper-array/isVueInstance.md b/docs/pt-br/api/wrapper-array/isVueInstance.md index d4c1f1746..e6a58ac8c 100644 --- a/docs/pt-br/api/wrapper-array/isVueInstance.md +++ b/docs/pt-br/api/wrapper-array/isVueInstance.md @@ -2,7 +2,7 @@ Verifica se algum wrapper do Array é uma instância do Vue. -- **Retorna:** `{boolean}` +- **Retorna:** `{Boolean}` - **Exemplo:** diff --git a/docs/pt-br/api/wrapper/contains.md b/docs/pt-br/api/wrapper/contains.md index f2f6b7ef3..f7d552ec8 100644 --- a/docs/pt-br/api/wrapper/contains.md +++ b/docs/pt-br/api/wrapper/contains.md @@ -5,7 +5,7 @@ Verifica se o wrapper contém um elemento ou componente com o [seletor](../selec - **Argumentos:** - `{String|Component} seletor` -- **Retorna:** `{boolean}` +- **Retorna:** `{Boolean}` - **Exemplo:** diff --git a/docs/pt-br/api/wrapper/exists.md b/docs/pt-br/api/wrapper/exists.md index 4fac1351f..a008ddec0 100644 --- a/docs/pt-br/api/wrapper/exists.md +++ b/docs/pt-br/api/wrapper/exists.md @@ -4,7 +4,7 @@ Assert `Wrapper` or `WrapperArray` exists. Returns false if called on an empty `Wrapper` or `WrapperArray`. -- **Returns:** `{boolean}` +- **Returns:** `{Boolean}` - **Example:** diff --git a/docs/pt-br/api/wrapper/hasAttribute.md b/docs/pt-br/api/wrapper/hasAttribute.md index 436c62df5..9cbae20c0 100644 --- a/docs/pt-br/api/wrapper/hasAttribute.md +++ b/docs/pt-br/api/wrapper/hasAttribute.md @@ -8,7 +8,7 @@ Retorna `true` se o wrapper contém o atributo. - `{String} atributo` - `{String} valor` -- **Retorna:** `{boolean}` +- **Retorna:** `{Boolean}` - **Exemplo:** diff --git a/docs/pt-br/api/wrapper/hasClass.md b/docs/pt-br/api/wrapper/hasClass.md index 8d608caa2..e526f3a96 100644 --- a/docs/pt-br/api/wrapper/hasClass.md +++ b/docs/pt-br/api/wrapper/hasClass.md @@ -7,7 +7,7 @@ Retorna `true` se o wrapper contém a classe. - **Argumentos:** - `{String} nomeDaClasse` -- **Retorna:** `{boolean}` +- **Retorna:** `{Boolean}` - **Exemplo:** diff --git a/docs/pt-br/api/wrapper/hasProp.md b/docs/pt-br/api/wrapper/hasProp.md index da00f8e79..42b8c0a22 100644 --- a/docs/pt-br/api/wrapper/hasProp.md +++ b/docs/pt-br/api/wrapper/hasProp.md @@ -10,7 +10,7 @@ Retorna `true` se o `vm` do wrapper tem a `propriedade` com o `valor` passado. - `{String} propriedade` - `{any} valor` -- **Retorna:** `{boolean}` +- **Retorna:** `{Boolean}` - **Exemplo:** diff --git a/docs/pt-br/api/wrapper/hasStyle.md b/docs/pt-br/api/wrapper/hasStyle.md index f52231317..d4f4a807b 100644 --- a/docs/pt-br/api/wrapper/hasStyle.md +++ b/docs/pt-br/api/wrapper/hasStyle.md @@ -10,7 +10,7 @@ Retorna `true` se o wrapper possui um `estilo` com o `valor`. - `{String} estilo` - `{String} valor` -- **Retorna:** `{boolean}` +- **Retorna:** `{Boolean}` - **Exemplo:** diff --git a/docs/pt-br/api/wrapper/is.md b/docs/pt-br/api/wrapper/is.md index 94b0ca437..dcec2d398 100644 --- a/docs/pt-br/api/wrapper/is.md +++ b/docs/pt-br/api/wrapper/is.md @@ -5,7 +5,7 @@ Verifica se o `vm` do wrapper possui o [seletor](../selectors.md) informado. - **Argumentos:** - `{String|Component} seletor` -- **Retorna:** `{boolean}` +- **Retorna:** `{Boolean}` - **Exemplo:** diff --git a/docs/pt-br/api/wrapper/isEmpty.md b/docs/pt-br/api/wrapper/isEmpty.md index 29d20be68..c27344a0e 100644 --- a/docs/pt-br/api/wrapper/isEmpty.md +++ b/docs/pt-br/api/wrapper/isEmpty.md @@ -2,7 +2,7 @@ Verifica se o wrapper não contem elementos filhos. -- **Retorna:** `{boolean}` +- **Retorna:** `{Boolean}` - **Exemplo:** diff --git a/docs/pt-br/api/wrapper/isVueInstance.md b/docs/pt-br/api/wrapper/isVueInstance.md index 421603623..f73fa8685 100644 --- a/docs/pt-br/api/wrapper/isVueInstance.md +++ b/docs/pt-br/api/wrapper/isVueInstance.md @@ -2,7 +2,7 @@ Verifica se o wrapper é uma intância do Vue. -- **Retorna:** `{boolean}` +- **Retorna:** `{Boolean}` - **Exemplo:** diff --git a/docs/pt-br/api/wrapper/trigger.md b/docs/pt-br/api/wrapper/trigger.md index 455e3e214..1ed3b6c9d 100644 --- a/docs/pt-br/api/wrapper/trigger.md +++ b/docs/pt-br/api/wrapper/trigger.md @@ -9,7 +9,7 @@ Você pode rodar o preventDefault em um evento passando `preventDefault: true` n - **Argumentos:** - `{String} nomeDoEvento` - `{Object} opcoes` - - `{boolean} preventDefault` + - `{Boolean} preventDefault` - **Exemplo:** From 03c850da276d45abefe47c8d9639a55310b2de8f Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 22:15:06 +0000 Subject: [PATCH 67/71] fix(docs): fix write errors --- docs/pt-br/api/config.md | 2 +- docs/pt-br/api/selectors.md | 2 +- docs/pt-br/api/wrapper/destroy.md | 2 +- docs/pt-br/api/wrapper/find.md | 2 +- docs/pt-br/guides/common-tips.md | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/pt-br/api/config.md b/docs/pt-br/api/config.md index 963a5b76e..dce461a84 100644 --- a/docs/pt-br/api/config.md +++ b/docs/pt-br/api/config.md @@ -16,7 +16,7 @@ Esboços são usados em todos componentes. Eles são substituídos pelos esboço Quando você passa os esboços como um Array de String nas opções de montagens, o `config.stubs` é convertido em um Array e os componentes são esboçados com um componente que retorna uma div. -Exemplho: +Exemplo: ```js import VueTestUtils from 'vue-test-utils' diff --git a/docs/pt-br/api/selectors.md b/docs/pt-br/api/selectors.md index 168581ba5..ce97f2483 100644 --- a/docs/pt-br/api/selectors.md +++ b/docs/pt-br/api/selectors.md @@ -1,6 +1,6 @@ # Seletores -Muitos métodos desse wrapper leval um seletor como argumento. Um seletor pode ser um seletor CSS ou um componente do Vue. +Muitos métodos desse wrapper leva um seletor como argumento. Um seletor pode ser um seletor CSS ou um componente do Vue. ## Seletores CSS diff --git a/docs/pt-br/api/wrapper/destroy.md b/docs/pt-br/api/wrapper/destroy.md index 8f943729a..fc04358b9 100644 --- a/docs/pt-br/api/wrapper/destroy.md +++ b/docs/pt-br/api/wrapper/destroy.md @@ -1,6 +1,6 @@ # destroy() -Destroí a instância do componente Vue. +Destrói a instância do componente Vue. - **Exemplo:** diff --git a/docs/pt-br/api/wrapper/find.md b/docs/pt-br/api/wrapper/find.md index 651c87fd9..ea7fa8285 100644 --- a/docs/pt-br/api/wrapper/find.md +++ b/docs/pt-br/api/wrapper/find.md @@ -2,7 +2,7 @@ Retorna um wrapper [`Wrapper`](README.md) com o primeiro elmento do DOM ou o componente Vue encontrado a partir do seletor -Use any valiUse qualquer [seletor](../selectors.md) válido. +Use qualquer [seletor](../selectors.md) válido. - **Argumentos:** - `{String|Component} seletor` diff --git a/docs/pt-br/guides/common-tips.md b/docs/pt-br/guides/common-tips.md index fd89c1a73..8b51ff877 100644 --- a/docs/pt-br/guides/common-tips.md +++ b/docs/pt-br/guides/common-tips.md @@ -61,7 +61,7 @@ expect(wrapper.emitted().foo[1]).toEqual([123]) Além disso, você pode pegar um Array dos eventos emitidos em ordem de chamada com o método [wrapper.emittedByOrder()](../api/wrapper/emittedByOrder.md). -## Manupulando o estado do componente +## Manipulando o estado do componente Você pode manipular diretamente o estado do componente usando os métodos `setData` ou `setProps` no wrapper: From 55b978f1f32a75d622eedc70984ef0f446efbb93 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 22:28:10 +0000 Subject: [PATCH 68/71] fix(docs): untranslate code api part --- docs/pt-br/api/mount.md | 4 ++-- docs/pt-br/api/shallow.md | 4 ++-- docs/pt-br/api/wrapper-array/hasAttribute.md | 8 ++++---- docs/pt-br/api/wrapper-array/hasClass.md | 6 +++--- docs/pt-br/api/wrapper-array/hasProp.md | 6 +++--- docs/pt-br/api/wrapper-array/hasStyle.md | 12 ++++++------ docs/pt-br/api/wrapper-array/setComputed.md | 4 ++-- docs/pt-br/api/wrapper-array/setData.md | 4 ++-- docs/pt-br/api/wrapper-array/setMethods.md | 4 ++-- docs/pt-br/api/wrapper-array/setProps.md | 2 +- docs/pt-br/api/wrapper-array/trigger.md | 4 ++-- docs/pt-br/api/wrapper/exists.md | 13 +++++++------ docs/pt-br/api/wrapper/hasAttribute.md | 6 +++--- docs/pt-br/api/wrapper/hasClass.md | 6 +++--- docs/pt-br/api/wrapper/hasProp.md | 6 +++--- docs/pt-br/api/wrapper/hasStyle.md | 8 ++++---- docs/pt-br/api/wrapper/setComputed.md | 4 ++-- docs/pt-br/api/wrapper/setData.md | 4 ++-- docs/pt-br/api/wrapper/setMethods.md | 4 ++-- docs/pt-br/api/wrapper/setProps.md | 2 +- docs/pt-br/api/wrapper/trigger.md | 10 +++++----- 21 files changed, 61 insertions(+), 60 deletions(-) diff --git a/docs/pt-br/api/mount.md b/docs/pt-br/api/mount.md index 247022de4..524dcea83 100644 --- a/docs/pt-br/api/mount.md +++ b/docs/pt-br/api/mount.md @@ -1,9 +1,9 @@ -# mount(componente {, opcoes}]) +# mount(component {, options}]) - **Argumentos:** - `{Component} componente` - - `{Object} opcoes` + - `{Object} options` - **Retorna:** `{Wrapper}` diff --git a/docs/pt-br/api/shallow.md b/docs/pt-br/api/shallow.md index 48448c8d3..a873c5023 100644 --- a/docs/pt-br/api/shallow.md +++ b/docs/pt-br/api/shallow.md @@ -1,9 +1,9 @@ -# shallow(componente {, opcoes}]) +# shallow(component {, options}]) - **Argumentos:** - `{Component} componente` - - `{Object} opcoes` + - `{Object} options` - `{Boolean} attachToDocument` - `{Object} context` - `{Object} slots` diff --git a/docs/pt-br/api/wrapper-array/hasAttribute.md b/docs/pt-br/api/wrapper-array/hasAttribute.md index eb641120e..faaa0cc54 100644 --- a/docs/pt-br/api/wrapper-array/hasAttribute.md +++ b/docs/pt-br/api/wrapper-array/hasAttribute.md @@ -1,10 +1,10 @@ -# hasAttribute(atributo, valor) +# hasAttribute(attribute, value) -Verifica se algum wrapper do Array tem o `atributo` com `valor` correspondente no elemento do DOM. +Verifica se algum wrapper do Array tem o `atributo` com `value` correspondente no elemento do DOM. - **Argumentos:** - - `{String} atributo` - - `{String} valor` + - `{String} attribute` + - `{String} value` - **Retorna:** `{Boolean}` diff --git a/docs/pt-br/api/wrapper-array/hasClass.md b/docs/pt-br/api/wrapper-array/hasClass.md index a87b4fd7d..4dc2ad891 100644 --- a/docs/pt-br/api/wrapper-array/hasClass.md +++ b/docs/pt-br/api/wrapper-array/hasClass.md @@ -1,9 +1,9 @@ -# hasClass(nomeDaClasse) +# hasClass(className) -Verifica se algum wrapper do Array contém uma classe com o nome `nomeDaClasse` no elemento do DOM. +Verifica se algum wrapper do Array contém uma classe com o nome `className` no elemento do DOM. - **Argumentos:** - - `{String} nomeDaClasse` + - `{String} className` - **Retorna:** `{Boolean}` diff --git a/docs/pt-br/api/wrapper-array/hasProp.md b/docs/pt-br/api/wrapper-array/hasProp.md index 50056257b..d2649b55a 100644 --- a/docs/pt-br/api/wrapper-array/hasProp.md +++ b/docs/pt-br/api/wrapper-array/hasProp.md @@ -1,12 +1,12 @@ -# hasProp(propriedade, valor) +# hasProp(propriedade, value) -Verifica se algum wrapper do Array possui a `propriedade` com o `valor` no `vm`. +Verifica se algum wrapper do Array possui a `propriedade` com o `value` no `vm`. **Nota: o wrapper deve ser uma intância do Vue.** - **Argumentos:** - `{String} propriedade` - - `{any} valor` + - `{any} value` - **Retorna:** `{Boolean}` diff --git a/docs/pt-br/api/wrapper-array/hasStyle.md b/docs/pt-br/api/wrapper-array/hasStyle.md index 2fc61c73f..24e5e45bc 100644 --- a/docs/pt-br/api/wrapper-array/hasStyle.md +++ b/docs/pt-br/api/wrapper-array/hasStyle.md @@ -1,14 +1,14 @@ -# hasStyle(estilo, valor) +# hasStyle(style, value) -Verifica se algum wrapper do Array tem o `estilo` com o `valor` no elemento do DOM. +Verifica se algum wrapper do Array tem o `style` com o `value` no elemento do DOM. -Retorna `true` se o wrapper contém o `estilo` com o `valor`. +Retorna `true` se o wrapper contém o `style` com o `value`. -**Nota: para detectarmos os estilos deve-se usar o `jsdom`.** +**Nota: para detectarmos os styles deve-se usar o `jsdom`.** - **Argumentos:** - - `{String} estilo` - - `{String} valor` + - `{String} style` + - `{String} value` - **Retorna:** `{Boolean}` diff --git a/docs/pt-br/api/wrapper-array/setComputed.md b/docs/pt-br/api/wrapper-array/setComputed.md index 9648b305e..beed90fbd 100644 --- a/docs/pt-br/api/wrapper-array/setComputed.md +++ b/docs/pt-br/api/wrapper-array/setComputed.md @@ -1,4 +1,4 @@ -# setComputed(propriedadesComputadas) +# setComputed(computedProperties) Define as propriedades computadas e força a atualização de cada um dos wrappers no Array. @@ -6,7 +6,7 @@ Define as propriedades computadas e força a atualização de cada um dos wrappe **Nota2: cada instância de cada wrapper deve ter as propriedades computadas já declaradas, pois esse método apenas mocka o seu valor.** - **Argumentos:** - - `{Object} propriedadesComputadass` + - `{Object} computedPropertiess` - **Exemplo:** diff --git a/docs/pt-br/api/wrapper-array/setData.md b/docs/pt-br/api/wrapper-array/setData.md index 56f3466f6..0dd0d2940 100644 --- a/docs/pt-br/api/wrapper-array/setData.md +++ b/docs/pt-br/api/wrapper-array/setData.md @@ -1,11 +1,11 @@ -# setData(dados) +# setData(data) Define os dados e força a atualização de cada wrapper presente no Array. **Nota: cada wrapper deve ser uma instância do Vue.** - **Argumentos:** - - `{Object} dados` + - `{Object} data` - **Exemplho:** diff --git a/docs/pt-br/api/wrapper-array/setMethods.md b/docs/pt-br/api/wrapper-array/setMethods.md index 975e02b10..bb877a95d 100644 --- a/docs/pt-br/api/wrapper-array/setMethods.md +++ b/docs/pt-br/api/wrapper-array/setMethods.md @@ -1,11 +1,11 @@ -# setMethods(metodos) +# setMethods(methods) Define os métodos do componente e força sua atualização para cada wrapper no Array. **Nota: cada wrapper deve ser uma instância do Vue.** - **Argumentos:** - - `{Object} metodos` + - `{Object} methods` - **Exemplo:** diff --git a/docs/pt-br/api/wrapper-array/setProps.md b/docs/pt-br/api/wrapper-array/setProps.md index 87bf8d3b8..b6e19d410 100644 --- a/docs/pt-br/api/wrapper-array/setProps.md +++ b/docs/pt-br/api/wrapper-array/setProps.md @@ -1,4 +1,4 @@ -# setProps(propriedades) +# setProps(props) Define as `propriedades` do componente e força sua atualização para cada wrapper no Array. diff --git a/docs/pt-br/api/wrapper-array/trigger.md b/docs/pt-br/api/wrapper-array/trigger.md index cc848ca6d..b73fb1ad5 100644 --- a/docs/pt-br/api/wrapper-array/trigger.md +++ b/docs/pt-br/api/wrapper-array/trigger.md @@ -1,11 +1,11 @@ -# trigger(nomeDoEvento) +# trigger(eventName) Aciona um evento no elemeto do DOM de cada wrapper no Array. **Nota: cada wrapper deve ser uma instância do Vue.** - **Argumentos:** - - `{String} nomeDoEvento` + - `{String} eventName` - **Exemplo:** diff --git a/docs/pt-br/api/wrapper/exists.md b/docs/pt-br/api/wrapper/exists.md index a008ddec0..3a79864e0 100644 --- a/docs/pt-br/api/wrapper/exists.md +++ b/docs/pt-br/api/wrapper/exists.md @@ -1,12 +1,12 @@ # exists() -Assert `Wrapper` or `WrapperArray` exists. +Verifica se o `Wrapper` ou o `WrapperArray` existe. -Returns false if called on an empty `Wrapper` or `WrapperArray`. +Retorna `false` se chamado com um `Wrapper` ou `WrapperArray` vazio. -- **Returns:** `{Boolean}` +- **Retorna:** `{Boolean}` -- **Example:** +- **Exemplo:** ```js import { mount } from 'vue-test-utils' @@ -14,8 +14,9 @@ import { expect } from 'chai' import Foo from './Foo.vue' const wrapper = mount(Foo) + expect(wrapper.exists()).toBe(true) -expect(wrapper.find('does-not-exist').exists()).toBe(false) +expect(wrapper.find('nao-existe').exists()).toBe(false) expect(wrapper.findAll('div').exists()).toBe(true) -expect(wrapper.findAll('does-not-exist').exists()).toBe(false) +expect(wrapper.findAll('nao-existe').exists()).toBe(false) ``` diff --git a/docs/pt-br/api/wrapper/hasAttribute.md b/docs/pt-br/api/wrapper/hasAttribute.md index 9cbae20c0..e41123238 100644 --- a/docs/pt-br/api/wrapper/hasAttribute.md +++ b/docs/pt-br/api/wrapper/hasAttribute.md @@ -1,12 +1,12 @@ -# hasAttribute(atributo, valor) +# hasAttribute(attribute, value) Verifica se o wrapper contém o atributo mencionado no seu elemento do DOM. Retorna `true` se o wrapper contém o atributo. - **Argumentos:** - - `{String} atributo` - - `{String} valor` + - `{String} attribute` + - `{String} value` - **Retorna:** `{Boolean}` diff --git a/docs/pt-br/api/wrapper/hasClass.md b/docs/pt-br/api/wrapper/hasClass.md index e526f3a96..32e69fae9 100644 --- a/docs/pt-br/api/wrapper/hasClass.md +++ b/docs/pt-br/api/wrapper/hasClass.md @@ -1,11 +1,11 @@ -# hasClass(nomeDaClasse) +# hasClass(className) -Verifica se o wrapper do elemento do DOM contém uma classe informada pelo `nomeDaClasse`. +Verifica se o wrapper do elemento do DOM contém uma classe informada pelo `className`. Retorna `true` se o wrapper contém a classe. - **Argumentos:** - - `{String} nomeDaClasse` + - `{String} className` - **Retorna:** `{Boolean}` diff --git a/docs/pt-br/api/wrapper/hasProp.md b/docs/pt-br/api/wrapper/hasProp.md index 42b8c0a22..7b9dd2f7e 100644 --- a/docs/pt-br/api/wrapper/hasProp.md +++ b/docs/pt-br/api/wrapper/hasProp.md @@ -1,14 +1,14 @@ -# hasProp(propriedade, valor) +# hasProp(propriedade, value) Verifica se o `vm` do wrapper possui uma pripriedade com o valor definido. -Retorna `true` se o `vm` do wrapper tem a `propriedade` com o `valor` passado. +Retorna `true` se o `vm` do wrapper tem a `propriedade` com o `value` passado. **Nota: o wrapper deve conter uma instância do Vue.** - **Argumentos:** - `{String} propriedade` - - `{any} valor` + - `{any} value` - **Retorna:** `{Boolean}` diff --git a/docs/pt-br/api/wrapper/hasStyle.md b/docs/pt-br/api/wrapper/hasStyle.md index d4f4a807b..2a1b29265 100644 --- a/docs/pt-br/api/wrapper/hasStyle.md +++ b/docs/pt-br/api/wrapper/hasStyle.md @@ -1,14 +1,14 @@ -# hasStyle(estilo, valor) +# hasStyle(style, value) Verifica se o elemento do DOM do wrapper possui uma propriedade de estilo com esse valor. -Retorna `true` se o wrapper possui um `estilo` com o `valor`. +Retorna `true` se o wrapper possui um `style` com o `value`. **Nota: só iremos detectar os estilos quando executado com o `jsdom`.** - **Argumentos:** - - `{String} estilo` - - `{String} valor` + - `{String} style` + - `{String} value` - **Retorna:** `{Boolean}` diff --git a/docs/pt-br/api/wrapper/setComputed.md b/docs/pt-br/api/wrapper/setComputed.md index 1239ab3db..925fc96e5 100644 --- a/docs/pt-br/api/wrapper/setComputed.md +++ b/docs/pt-br/api/wrapper/setComputed.md @@ -1,4 +1,4 @@ -# setComputed(propriedadesComputadas) +# setComputed(computedProperties) Define as propriedades computadas do `vm` do wrapper e força a sua atualização. @@ -7,7 +7,7 @@ Define as propriedades computadas do `vm` do wrapper e força a sua atualizaçã - **Argumentos:** - - `{Object} propriedadesComputadas` + - `{Object} computedProperties` - **Exemplo:** diff --git a/docs/pt-br/api/wrapper/setData.md b/docs/pt-br/api/wrapper/setData.md index 9eda395a1..ac7e70acf 100644 --- a/docs/pt-br/api/wrapper/setData.md +++ b/docs/pt-br/api/wrapper/setData.md @@ -1,11 +1,11 @@ -# setData(dados) +# setData(data) Define os dados do `vm` do wrapper e força a sua atualização. **Nota: o wrapper deve ser uma instância do Vue.** - **Argumentos:** - - `{Object} dados` + - `{Object} data` - **Exemplo:** diff --git a/docs/pt-br/api/wrapper/setMethods.md b/docs/pt-br/api/wrapper/setMethods.md index 882890925..a73fabc64 100644 --- a/docs/pt-br/api/wrapper/setMethods.md +++ b/docs/pt-br/api/wrapper/setMethods.md @@ -1,11 +1,11 @@ -# setMethods(metodos) +# setMethods(methods) Define os métodos do `vm` do wrapper e força sua atualização. **Nota: o wrapper deve ser uma instância do Vue.** - **Argumentos:** - - `{Object} metodos` + - `{Object} methods` - **Exemplo:** diff --git a/docs/pt-br/api/wrapper/setProps.md b/docs/pt-br/api/wrapper/setProps.md index c93cdc490..c18efe20e 100644 --- a/docs/pt-br/api/wrapper/setProps.md +++ b/docs/pt-br/api/wrapper/setProps.md @@ -1,4 +1,4 @@ -# setProps(propriedades) +# setProps(props) Define as propriedades do `vm` do wrapper e força sua atualização. diff --git a/docs/pt-br/api/wrapper/trigger.md b/docs/pt-br/api/wrapper/trigger.md index 1ed3b6c9d..f2882e941 100644 --- a/docs/pt-br/api/wrapper/trigger.md +++ b/docs/pt-br/api/wrapper/trigger.md @@ -1,14 +1,14 @@ -# trigger(nomeDoEvento {, opcoes}]) +# trigger(eventName {, options}]) Aciona um evento do elemento do wrapper. -O método `trigger` usa o objeto opicional `opcoes`, essas opções serão adicionadas ao evento. +O método `trigger` usa o objeto opicional `options`, essas opções serão adicionadas ao evento. -Você pode rodar o preventDefault em um evento passando `preventDefault: true` no objeto de `opcoes`. +Você pode rodar o preventDefault em um evento passando `preventDefault: true` no objeto de `options`. - **Argumentos:** - - `{String} nomeDoEvento` - - `{Object} opcoes` + - `{String} eventName` + - `{Object} options` - `{Boolean} preventDefault` - **Exemplo:** From 701d795c58030b74f7ef369e80ee035e5864bdb3 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 23:14:09 +0000 Subject: [PATCH 69/71] fix(docs): translate mock and debug --- docs/pt-br/api/options.md | 4 ++-- docs/pt-br/api/wrapper-array/setComputed.md | 2 +- docs/pt-br/guides/choosing-a-test-runner.md | 2 +- docs/pt-br/guides/common-tips.md | 6 +++--- docs/pt-br/guides/getting-started.md | 2 +- docs/pt-br/guides/using-with-vue-router.md | 2 +- docs/pt-br/guides/using-with-vuex.md | 6 +++--- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/pt-br/api/options.md b/docs/pt-br/api/options.md index fbfc5f240..38a8a7c29 100644 --- a/docs/pt-br/api/options.md +++ b/docs/pt-br/api/options.md @@ -76,7 +76,7 @@ shallow(Component, { stubs: { // esboço com uma implementação específica 'componente-registrado': Foo, - // criar um esboço padrão (mockado) + // criar um esboço padrão (simulado com mock) 'outro componente': true } }) @@ -86,7 +86,7 @@ shallow(Component, { - tipo: `Object` -Adiciona uma propriedade adicional à instância. Ótimo para mockar injeções globais. +Adiciona uma propriedade adicional à instância. Ótimo para simular injeções globais. Exemplo: diff --git a/docs/pt-br/api/wrapper-array/setComputed.md b/docs/pt-br/api/wrapper-array/setComputed.md index beed90fbd..70abc1df0 100644 --- a/docs/pt-br/api/wrapper-array/setComputed.md +++ b/docs/pt-br/api/wrapper-array/setComputed.md @@ -3,7 +3,7 @@ Define as propriedades computadas e força a atualização de cada um dos wrappers no Array. **Nota: cada wrapper deve ser uma instância do Vue.** -**Nota2: cada instância de cada wrapper deve ter as propriedades computadas já declaradas, pois esse método apenas mocka o seu valor.** +**Nota2: cada instância de cada wrapper deve ter as propriedades computadas já declaradas, pois esse método apenas simular o seu valor.** - **Argumentos:** - `{Object} computedPropertiess` diff --git a/docs/pt-br/guides/choosing-a-test-runner.md b/docs/pt-br/guides/choosing-a-test-runner.md index b15ec57fa..9e2280489 100644 --- a/docs/pt-br/guides/choosing-a-test-runner.md +++ b/docs/pt-br/guides/choosing-a-test-runner.md @@ -4,7 +4,7 @@ Um *test runner* é um programa com objetivo de executar seus testes. Existem muitos executadores de testes populares no Javascript, o `vue-test-utils` funciona com todos eles. -Há algumas coisas a considerar ao escolher um *test runner*: conjunto de recursos, desempenho e suporte a pré-compilação de componentes arquivos de únicos (SFC). Depois de comparar cuidadosamente as bibliotecas existentes, aqui estão dois *test runner* que recomendamos: +Há algumas coisas a considerar ao escolher um *test runner*: conjunto de recursos, desempenho e suporte a pré-compilação de componentes de arquivo único (SFC). Depois de comparar cuidadosamente as bibliotecas existentes, aqui estão dois *test runner* que recomendamos: - [Jest](https://facebook.github.io/jest/docs/en/getting-started.html#content) é o executador de testes mais completo. Ele requer menos configuração, usa JSDOM por padrão, e fornece uma ótima experiência de usuário na linha de comando. Contudo, você vai precisar de um pré-processador para ser possível importar componentes SFC em seus testes. Nos criamos o pré-processador `vue-jest`, para lidar com os recursos SFC mais comuns, mas atualmente não possuímos 100% de compatibilidade com o `vue-loader`. diff --git a/docs/pt-br/guides/common-tips.md b/docs/pt-br/guides/common-tips.md index 8b51ff877..0e891dea8 100644 --- a/docs/pt-br/guides/common-tips.md +++ b/docs/pt-br/guides/common-tips.md @@ -112,7 +112,7 @@ mount(Componente, { ## Mockando injeções -Outra estratégia para injetar propriedades é simplismente mockar ela. Você pode fazer isso com a opção `mocks`: +Outra estratégia para injetar propriedades é simplesmente simular ela. Você pode fazer isso com a opção `mocks`: ```js import { mount } from 'vue-test-utils' @@ -126,7 +126,7 @@ const $route = { mount(Component, { mocks: { - // adiciona o objeto $route mockado na instância Vue + // adiciona o objeto $route simulado na instância Vue // antes da montagem do componente $route } @@ -135,4 +135,4 @@ mount(Component, { ## Lidando com o roteamento -Uma vez que o roteamento, por definição, tem a ver com a estrutura geral da aplicação e envolve muitos componentes, é melhor testado atráves de testes de integração ou de ponta a ponta. Para componentes individuais que dependem dos recursos do `vue-router`, você pode mocka-lo usando as técnicas mencionadas acima. +Uma vez que o roteamento, por definição, tem a ver com a estrutura geral da aplicação e envolve muitos componentes, é melhor testado atráves de testes de integração ou de ponta a ponta. Para componentes individuais que dependem dos recursos do `vue-router`, você pode simula-lo usando as técnicas mencionadas acima. diff --git a/docs/pt-br/guides/getting-started.md b/docs/pt-br/guides/getting-started.md index ffedbb572..f311e289e 100644 --- a/docs/pt-br/guides/getting-started.md +++ b/docs/pt-br/guides/getting-started.md @@ -39,7 +39,7 @@ export default { ### Montando seus componentes -O `vue-test-utils` testa os componentes do Vue montando-os isoladamente, mockando as entradas necessárias (propriedades, slots e eventos de usuário) e verificando as saídas (renderização, eventos personalizados emitidos). +O `vue-test-utils` testa os componentes do Vue montando-os isoladamente, simulando as entradas necessárias (propriedades, slots e eventos de usuário) e verificando as saídas (renderização, eventos personalizados emitidos). Os componentes montados são retornados em um wrapper (wrapper) que expõe muitos métodos para manipular, percorrer e consultar a instância do componente Vue correspondente. diff --git a/docs/pt-br/guides/using-with-vue-router.md b/docs/pt-br/guides/using-with-vue-router.md index 7a91a80c3..3fda5b46d 100644 --- a/docs/pt-br/guides/using-with-vue-router.md +++ b/docs/pt-br/guides/using-with-vue-router.md @@ -66,6 +66,6 @@ wrapper.vm.$router // /rota/qualquer A instalação do Vue Router adiciona `$route` e `$router` como propriedades de somente leitura do protótipo Vue. -Isso significa que todos os testes futuros que tentam mockar o `$route` ou o `$router` irão falhar. +Isso significa que todos os testes futuros que tentam simular o `$route` ou o `$router` irão falhar. Para evitar isso, nunca instale o Vue Router quando estiver executando seus testes. diff --git a/docs/pt-br/guides/using-with-vuex.md b/docs/pt-br/guides/using-with-vuex.md index 01c2d7320..2f9dbeae0 100644 --- a/docs/pt-br/guides/using-with-vuex.md +++ b/docs/pt-br/guides/using-with-vuex.md @@ -94,7 +94,7 @@ describe('Acoes.vue', () => { O que está acontecendo aqui? Primeiro contamos ao localVue que ele usará o Vuex no método `localVue.use`. Este é apenas um wrapper do `Vue.use`. -Em seguida, fazemos uma store mockada chamando o método `Vuex.Store` com os valores do mock. Nós apenas passamos as ações, já que é o que nos importa no momento. +Em seguida, fazemos uma store simulada chamando o método `Vuex.Store` com os valores do mock. Nós apenas passamos as ações, já que é o que nos importa no momento. As ações são [funções de mock do Jest](https://facebook.github.io/jest/docs/en/mock-functions.html). Essas funções simuladas nos dão alguns métodos para verificar se as determinadas ações foram ou não chamadas. @@ -102,11 +102,11 @@ Então, podemos fazer a asserção nos nossos testes esperando que essas ações A forma como definimos a store pode parecer um pouco estranha para você. -Nós usamos o `beforeEach` para garantir que teremos uma store limpa antes de cada teste. O `beforeEach` é um método gancho do Mocha que é chamado antes de cada teste. Em nosso teste, reatribuímos os valores da store. Se nós não fizessemos isso, as funções mockadas deveriam ser reiniciadas automaticamente. Esse método também permite que alteremos o estado nos testes sem que afete os testes posteriores, pois ele será redefinido entre esses testes. +Nós usamos o `beforeEach` para garantir que teremos uma store limpa antes de cada teste. O `beforeEach` é um método gancho do Mocha que é chamado antes de cada teste. Em nosso teste, reatribuímos os valores da store. Se nós não fizessemos isso, as funções simuladas deveriam ser reiniciadas automaticamente. Esse método também permite que alteremos o estado nos testes sem que afete os testes posteriores, pois ele será redefinido entre esses testes. A coisa mais impotante a ser notada neste teste é que **criamos um mock da store e depois passamos ela para o vue-test-utils**. -Ótimo, agora que nós já conseguimos mockar as actions, vamos ver como mockars o getters. +Ótimo, agora que nós já conseguimos simular as actions, vamos ver como simular o getters. ## Mockando os getters From d2fb5b78423c1ef1d1d2631ec9573c39f1acb045 Mon Sep 17 00:00:00 2001 From: Leonardo Vilarinho Date: Fri, 17 Nov 2017 23:43:33 +0000 Subject: [PATCH 70/71] fix(docs): fix link wrapper array menu --- docs/pt-br/README.md | 36 +++++++++---------- docs/pt-br/SUMMARY.md | 36 +++++++++---------- docs/pt-br/api/README.md | 28 +++++++-------- docs/pt-br/api/mount.md | 2 +- docs/pt-br/api/shallow.md | 2 +- docs/pt-br/api/wrapper/README.md | 2 +- docs/pt-br/api/wrapper/findAll.md | 2 +- docs/pt-br/guides/choosing-a-test-runner.md | 2 +- docs/pt-br/guides/common-tips.md | 4 +-- .../guides/testing-SFCs-with-mocha-webpack.md | 2 +- docs/pt-br/guides/using-with-vue-router.md | 2 +- docs/pt-br/guides/using-with-vuex.md | 4 +-- 12 files changed, 61 insertions(+), 61 deletions(-) diff --git a/docs/pt-br/README.md b/docs/pt-br/README.md index fd3b741ea..f092ea048 100644 --- a/docs/pt-br/README.md +++ b/docs/pt-br/README.md @@ -49,24 +49,24 @@ * [trigger](api/wrapper/trigger.md) * [update](api/wrapper/update.md) * [destroy](api/wrapper/destroy.md) - * [WrapperArray](api/wrapper-Array/README.md) - * [at](api/wrapper-Array/at.md) - * [contains](api/wrapper-Array/contains.md) - * [hasAttribute](api/wrapper-Array/hasAttribute.md) - * [hasClass](api/wrapper-Array/hasClass.md) - * [hasProp](api/wrapper-Array/hasProp.md) - * [hasStyle](api/wrapper-Array/hasStyle.md) - * [is](api/wrapper-Array/is.md) - * [isEmpty](api/wrapper-Array/isEmpty.md) - * [isVueInstance](api/wrapper-Array/isVueInstance.md) - * [setComputed](api/wrapper-Array/setComputed.md) - * [setData](api/wrapper-Array/setData.md) - * [setMethods](api/wrapper-Array/setMethods.md) - * [setProps](api/wrapper-Array/setProps.md) - * [trigger](api/wrapper-Array/trigger.md) - * [update](api/wrapper-Array/update.md) - * [destroy](api/wrapper-Array/destroy.md) - * [components](api/components/README.md) + * [WrapperArray](api/wrapper-array/README.md) + * [at](api/wrapper-array/at.md) + * [contains](api/wrapper-array/contains.md) + * [hasAttribute](api/wrapper-array/hasAttribute.md) + * [hasClass](api/wrapper-array/hasClass.md) + * [hasProp](api/wrapper-array/hasProp.md) + * [hasStyle](api/wrapper-array/hasStyle.md) + * [is](api/wrapper-array/is.md) + * [isEmpty](api/wrapper-array/isEmpty.md) + * [isVueInstance](api/wrapper-array/isVueInstance.md) + * [setComputed](api/wrapper-array/setComputed.md) + * [setData](api/wrapper-array/setData.md) + * [setMethods](api/wrapper-array/setMethods.md) + * [setProps](api/wrapper-array/setProps.md) + * [trigger](api/wrapper-array/trigger.md) + * [update](api/wrapper-array/update.md) + * [destroy](api/wrapper-array/destroy.md) + * [Componentes](api/components/README.md) * [TransitionStub](api/components/TransitionStub.md) * [TransitionGroupStub](api/components/TransitionGroupStub.md) * [Seletores](api/selectors.md) diff --git a/docs/pt-br/SUMMARY.md b/docs/pt-br/SUMMARY.md index 350149430..0c5cdceb7 100644 --- a/docs/pt-br/SUMMARY.md +++ b/docs/pt-br/SUMMARY.md @@ -45,24 +45,24 @@ * [trigger](api/wrapper/trigger.md) * [update](api/wrapper/update.md) * [destroy](api/wrapper/destroy.md) - * [WrapperArray](api/wrapper-Array/README.md) - * [at](api/wrapper-Array/at.md) - * [contains](api/wrapper-Array/contains.md) - * [hasAttribute](api/wrapper-Array/hasAttribute.md) - * [hasClass](api/wrapper-Array/hasClass.md) - * [hasProp](api/wrapper-Array/hasProp.md) - * [hasStyle](api/wrapper-Array/hasStyle.md) - * [is](api/wrapper-Array/is.md) - * [isEmpty](api/wrapper-Array/isEmpty.md) - * [isVueInstance](api/wrapper-Array/isVueInstance.md) - * [setComputed](api/wrapper-Array/setComputed.md) - * [setData](api/wrapper-Array/setData.md) - * [setMethods](api/wrapper-Array/setMethods.md) - * [setProps](api/wrapper-Array/setProps.md) - * [trigger](api/wrapper-Array/trigger.md) - * [update](api/wrapper-Array/update.md) - * [destroy](api/wrapper-Array/destroy.md) - * [components](api/components/README.md) + * [WrapperArray](api/wrapper-array/README.md) + * [at](api/wrapper-array/at.md) + * [contains](api/wrapper-array/contains.md) + * [hasAttribute](api/wrapper-array/hasAttribute.md) + * [hasClass](api/wrapper-array/hasClass.md) + * [hasProp](api/wrapper-array/hasProp.md) + * [hasStyle](api/wrapper-array/hasStyle.md) + * [is](api/wrapper-array/is.md) + * [isEmpty](api/wrapper-array/isEmpty.md) + * [isVueInstance](api/wrapper-array/isVueInstance.md) + * [setComputed](api/wrapper-array/setComputed.md) + * [setData](api/wrapper-array/setData.md) + * [setMethods](api/wrapper-array/setMethods.md) + * [setProps](api/wrapper-array/setProps.md) + * [trigger](api/wrapper-array/trigger.md) + * [update](api/wrapper-array/update.md) + * [destroy](api/wrapper-array/destroy.md) + * [Componentes](api/components/README.md) * [TransitionStub](api/components/TransitionStub.md) * [TransitionGroupStub](api/components/TransitionGroupStub.md) * [Seletores](api/selectors.md) diff --git a/docs/pt-br/api/README.md b/docs/pt-br/api/README.md index 75a0c8e1e..6941e1a63 100644 --- a/docs/pt-br/api/README.md +++ b/docs/pt-br/api/README.md @@ -31,19 +31,19 @@ * [setProps](./wrapper/setProps.md) * [text](./wrapper/text.md) * [trigger](./wrapper/trigger.md) -* [WrapperArray](./wrapper-Array/README.md) - * [at](./wrapper-Array/at.md) - * [contains](./wrapper-Array/contains.md) - * [hasAttribute](./wrapper-Array/hasAttribute.md) - * [hasClass](./wrapper-Array/hasClass.md) - * [hasProp](./wrapper-Array/hasProp.md) - * [hasStyle](./wrapper-Array/hasStyle.md) - * [is](./wrapper-Array/is.md) - * [isEmpty](./wrapper-Array/isEmpty.md) - * [isVueInstance](./wrapper-Array/isVueInstance.md) - * [update](./wrapper-Array/update.md) - * [setData](./wrapper-Array/setData.md) - * [setProps](./wrapper-Array/setProps.md) - * [trigger](./wrapper-Array/trigger.md) +* [WrapperArray](./wrapper-array/README.md) + * [at](./wrapper-array/at.md) + * [contains](./wrapper-array/contains.md) + * [hasAttribute](./wrapper-array/hasAttribute.md) + * [hasClass](./wrapper-array/hasClass.md) + * [hasProp](./wrapper-array/hasProp.md) + * [hasStyle](./wrapper-array/hasStyle.md) + * [is](./wrapper-array/is.md) + * [isEmpty](./wrapper-array/isEmpty.md) + * [isVueInstance](./wrapper-array/isVueInstance.md) + * [update](./wrapper-array/update.md) + * [setData](./wrapper-array/setData.md) + * [setProps](./wrapper-array/setProps.md) + * [trigger](./wrapper-array/trigger.md) * [createLocalVue](./createLocalVue.md) * [Seletores](./selectors.md) diff --git a/docs/pt-br/api/mount.md b/docs/pt-br/api/mount.md index 524dcea83..b219581f6 100644 --- a/docs/pt-br/api/mount.md +++ b/docs/pt-br/api/mount.md @@ -2,7 +2,7 @@ - **Argumentos:** - - `{Component} componente` + - `{Component} component` - `{Object} options` - **Retorna:** `{Wrapper}` diff --git a/docs/pt-br/api/shallow.md b/docs/pt-br/api/shallow.md index a873c5023..e3189be2a 100644 --- a/docs/pt-br/api/shallow.md +++ b/docs/pt-br/api/shallow.md @@ -2,7 +2,7 @@ - **Argumentos:** - - `{Component} componente` + - `{Component} component` - `{Object} options` - `{Boolean} attachToDocument` - `{Object} context` diff --git a/docs/pt-br/api/wrapper/README.md b/docs/pt-br/api/wrapper/README.md index 4305efe92..b7eccd817 100644 --- a/docs/pt-br/api/wrapper/README.md +++ b/docs/pt-br/api/wrapper/README.md @@ -1,4 +1,4 @@ -# Wrapper (wrapper) +# Wrapper vue-test-utils é uma API baseada em *wrapper*. diff --git a/docs/pt-br/api/wrapper/findAll.md b/docs/pt-br/api/wrapper/findAll.md index b51619017..869c7d8be 100644 --- a/docs/pt-br/api/wrapper/findAll.md +++ b/docs/pt-br/api/wrapper/findAll.md @@ -1,6 +1,6 @@ # findAll(seletor) -Retorna um [`WrapperArray`](../wrapper-Array/README.md) de [Wrappers](README.md). +Retorna um [`WrapperArray`](../wrapper-array/README.md) de [Wrappers](README.md). Use qualquer [seletor](../selectors.md) válido. diff --git a/docs/pt-br/guides/choosing-a-test-runner.md b/docs/pt-br/guides/choosing-a-test-runner.md index 9e2280489..94a6ec1a0 100644 --- a/docs/pt-br/guides/choosing-a-test-runner.md +++ b/docs/pt-br/guides/choosing-a-test-runner.md @@ -1,4 +1,4 @@ -# Escolhendo um executadror de testes +# Escolhendo um executador de testes Um *test runner* é um programa com objetivo de executar seus testes. diff --git a/docs/pt-br/guides/common-tips.md b/docs/pt-br/guides/common-tips.md index 0e891dea8..798245c80 100644 --- a/docs/pt-br/guides/common-tips.md +++ b/docs/pt-br/guides/common-tips.md @@ -71,7 +71,7 @@ wrapper.setData({ contador: 10 }) wrapper.setProps({ foo: 'bar' }) ``` -## Mockando propriedades +## Simulando propriedades Você pode passar propriedades para o componente usando a opção `propsData` integrada no Vue: @@ -110,7 +110,7 @@ mount(Componente, { }) ``` -## Mockando injeções +## Simulando injeções Outra estratégia para injetar propriedades é simplesmente simular ela. Você pode fazer isso com a opção `mocks`: diff --git a/docs/pt-br/guides/testing-SFCs-with-mocha-webpack.md b/docs/pt-br/guides/testing-SFCs-with-mocha-webpack.md index df3bfad0b..5d51059a0 100644 --- a/docs/pt-br/guides/testing-SFCs-with-mocha-webpack.md +++ b/docs/pt-br/guides/testing-SFCs-with-mocha-webpack.md @@ -62,7 +62,7 @@ module.exports = { } ``` -Se for debugar pela IDE, também recomendamos adicionar o seguinte: +Se for depurar pela IDE, também recomendamos adicionar o seguinte: ``` js module.exports = { diff --git a/docs/pt-br/guides/using-with-vue-router.md b/docs/pt-br/guides/using-with-vue-router.md index 3fda5b46d..395792fda 100644 --- a/docs/pt-br/guides/using-with-vue-router.md +++ b/docs/pt-br/guides/using-with-vue-router.md @@ -44,7 +44,7 @@ shallow(Componente, { }) ``` -## Mockando o `$route` e o `$router` +## Simulando o `$route` e o `$router` Às vezes você quer testar que um componente faz algo com os parâmetros dos objetos `$route` e `$router`. Para fazer isso você pode passar mocks personalizados para a instância do Vue. diff --git a/docs/pt-br/guides/using-with-vuex.md b/docs/pt-br/guides/using-with-vuex.md index 2f9dbeae0..7fd355a75 100644 --- a/docs/pt-br/guides/using-with-vuex.md +++ b/docs/pt-br/guides/using-with-vuex.md @@ -2,7 +2,7 @@ Nesse guia verems como testar o Vuex nos componentes com o `vue-test-utils`. -## Mockando ações +## Simulando ações Vejamos algum código... @@ -108,7 +108,7 @@ A coisa mais impotante a ser notada neste teste é que **criamos um mock da stor Ótimo, agora que nós já conseguimos simular as actions, vamos ver como simular o getters. -## Mockando os getters +## Simulando os getters ``` html