removeAttribute(attribute)

Removes an attribute of the element.

Arguments

attribute (String): The name of the attribute.

Example

Example Component

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

describe('Example.vue', () => {
    it('removes the attribute "style" (tested with mount())', () => {
        const wrapper = mount(Example);
        const fullNameElement = wrapper.find('h1')[0];
        expect(fullNameElement.getAttributeValue('style')).to.equal('color: red;');
        fullNameElement.removeAttribute('style');
        expect(fullNameElement.getAttributeValue('style')).to.be.null;
    });

    it('removes the attribute "style" (tested with mountAsChild())', () => {
        const wrapper = mountAsChild(Example);
        const fullNameElement = wrapper.find('h1')[0];
        expect(fullNameElement.getAttributeValue('style')).to.equal('color: red;');
        fullNameElement.removeAttribute('style');
        expect(fullNameElement.getAttributeValue('style')).to.be.null;
    });
});

results matching ""

    No results matching ""