demarches-normaliennes/app/javascript/shared/utils.test.ts

42 lines
1.2 KiB
TypeScript
Raw Normal View History

2022-07-05 13:38:00 +02:00
import { suite, test, expect } from 'vitest';
2023-10-26 16:01:15 +02:00
import { show, hide, toggle, toggleExpandIcon } from './utils';
2022-07-05 13:38:00 +02:00
suite('@utils', () => {
test('show', () => {
const input = document.createElement('input');
input.classList.add('hidden');
show(input);
expect(input.classList.contains('hidden')).toBeFalsy();
});
test('hide', () => {
const input = document.createElement('input');
hide(input);
expect(input.classList.contains('hidden')).toBeTruthy();
});
test('toggle', () => {
const input = document.createElement('input');
toggle(input);
expect(input.classList.contains('hidden')).toBeTruthy();
toggle(input);
expect(input.classList.contains('hidden')).toBeFalsy();
});
2022-10-24 16:43:18 +02:00
test('toggleExpandIcon', () => {
const icon = document.createElement('icon');
icon.classList.add('fr-icon-arrow-down-s-line');
2022-10-24 16:43:18 +02:00
toggleExpandIcon(icon);
expect(icon.classList.contains('fr-icon-arrow-up-s-line')).toBeTruthy();
expect(icon.classList.contains('fr-icon-arrow-down-s-line')).toBeFalsy();
2022-10-24 16:43:18 +02:00
toggleExpandIcon(icon);
expect(icon.classList.contains('fr-icon-arrow-down-s-line')).toBeTruthy();
expect(icon.classList.contains('fr-icon-arrow-up-s-line')).toBeFalsy();
2022-10-24 16:43:18 +02:00
});
2022-07-05 13:38:00 +02:00
});