hasClass(className)

Checks if wrapper has the class.

Arguments

className (String): The name of the expected class.

Returns

(Boolean): Whether the Wrapper element has the class or not.

Example

Example Component

import { mount } from '@jasoeight/vue-testing';
import { expect } from 'chai';
import Example from './path/to/Example.vue';

describe('Example.vue', () => {
    it('has ul with an attribute "class" with value "list" (tested with mount())', () => {
        const wrapper = mount(Example);
        expect(wrapper.find('ul')[0].hasClass('list')).to.be.true;
    });

    it('has ul with an attribute "class" with value "list" (tested with mountAsChild())', () => {
        const wrapper = mountAsChild(Example);
        expect(wrapper.find('ul')[0].hasClass('list')).to.be.true;
    });
});

results matching ""

    No results matching ""