lundi 2 septembre 2019

Testing Vuejs Filters

I am trying to write a test for my Vuejs filter but I have no idea where to begin with filters in particular đŸ€”

This is my filter:

Vue.filter('pluralize', (word: string, amount: number) => amount > 1 ? `${word}s` : word);

The use case in a Vue component:

recharge

So if the count is is greater than 1, Recharge becomes Recharges

This is as far as I got so far concerning the test mark up:

import {createLocalVue} from '@vue/test-utils';

describe('pluralize', () => {
  let localVue = createLocalVue();
  localVue.filter('pluralize', (word: string, amount: number) => amount > 1 ? `${word}s` : word);

  it('returns plural suffix value', () => {
    // Test comes here...
  });
});

Any and all help will be appreciated đŸ‘đŸŒ

Aucun commentaire:

Enregistrer un commentaire