@paliari/vue-test-utils
TypeScript icon, indicating that this package has built-in type declarations

0.0.13 • Public • Published

vue-test-utils

#Install

  • Use npm

    $ npm install -D @paliari/vue-test-utils --save

  • Use yarn

    $ yarn add -D @paliari/vue-test-utils

Mocks

StoreHelpers

With this it is possible to mock the paliari vue store helper methods (base, paginator, crud)

Usage sample:

import '@paliari/vue-test-utils/__mocks__/StoreHelpers'
import paliariVue from 'paliari-vue'
import 'store/modules/anyStore'
import api from './__mocks__/api'

const { StoreHelpers } = paliariVue

it('should to call the auxiliary store with the correct parameters', () => {
    expect(StoreHelper.base).toBeCalledTimes(1)
    expect(StoreHelper.base).toBeCalledWith({ namespaced: true }, api)
})

Filters

Mocks of the main filters used in the projects

Usage sample:

import { shallowMount } from '@vue/test-utils'
import { filters } from '@paliari/vue-test-utils'
import Component from '@/views/Zubumafu.vue'

describe('renderer', () => {
    it('should matched snapshot', () => {
        const wrapper = shallowMount(Component, { filters })
        expect(wrapper.element).toMatchSnapshot()
    })
    it('should to call filter cpfCnpj', () => {
        expect(filters.cpfCnpj).toBeCalledTimes(1)
        expect(filters.cpfCnpj).toBeCalledWith('00000000000')
    })
})

Single imports sample:

import { cpfCnpj, truncate, date } from '@paliari/vue-test-utils/__mocks__/filters'

Available filters

name params returns
cpfCnpj (value) v
currency (number, prefix = '', sufix = '') ${prefix}${number}${sufix}
date (value, format) value
truncate (text, length = 30) text.substr(0, length - 3) + '...'

Readme

Keywords

none

Package Sidebar

Install

npm i @paliari/vue-test-utils

Weekly Downloads

1

Version

0.0.13

License

MIT

Unpacked Size

5.61 kB

Total Files

12

Last publish

Collaborators

  • dflourusso
  • felipebohnertpaetzold
  • m.paliari
  • paliari_ci