xref: /openbmc/webui-vue/tests/unit/Global/InputPasswordToggle.spec.js (revision 7d6b44cb263da09e575c7cb28cab88c1eb339c7b)
1*7d6b44cbSEd Tanousimport { mount } from '@vue/test-utils';
2e881499eSSukanya Pandeyimport InputPasswordToggle from '@/components/Global/InputPasswordToggle';
3e881499eSSukanya Pandey
4e881499eSSukanya Pandeydescribe('InputPasswordToggle.vue', () => {
5e881499eSSukanya Pandey  const wrapper = mount(InputPasswordToggle, {
6e881499eSSukanya Pandey    data() {
7e881499eSSukanya Pandey      return {
8e881499eSSukanya Pandey        isVisible: false,
9e881499eSSukanya Pandey      };
10e881499eSSukanya Pandey    },
11e881499eSSukanya Pandey    mocks: {
12e881499eSSukanya Pandey      $t: (key) => key,
13e881499eSSukanya Pandey    },
14e881499eSSukanya Pandey  });
15e881499eSSukanya Pandey  it('should exist', () => {
16e881499eSSukanya Pandey    expect(wrapper.exists()).toBe(true);
17e881499eSSukanya Pandey  });
18e881499eSSukanya Pandey  it('should not render isVisible class', () => {
19e881499eSSukanya Pandey    expect(wrapper.find('.isVisible').exists()).toBe(false);
20e881499eSSukanya Pandey  });
21e881499eSSukanya Pandey  it('should render isVisible class when button is clicked', async () => {
22e881499eSSukanya Pandey    await wrapper.find('button').trigger('click');
23e881499eSSukanya Pandey    expect(wrapper.find('.isVisible').exists()).toBe(true);
24e881499eSSukanya Pandey  });
25e881499eSSukanya Pandey  it('should render correctly', () => {
26e881499eSSukanya Pandey    expect(wrapper.element).toMatchSnapshot();
27e881499eSSukanya Pandey  });
28e881499eSSukanya Pandey});
29