mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-03-17 17:10:03 +01:00
Add tests for hideIf
This commit is contained in:
parent
c9f3677bd4
commit
007a3e629a
1 changed files with 15 additions and 0 deletions
|
@ -14,6 +14,7 @@ import {
|
||||||
findFirstTextNode,
|
findFirstTextNode,
|
||||||
disableEl,
|
disableEl,
|
||||||
enableEl,
|
enableEl,
|
||||||
|
hideIf,
|
||||||
} from '../dom';
|
} from '../dom';
|
||||||
import { getRandomArrayItem, getRandomIntBetween } from '../../../test/randomness';
|
import { getRandomArrayItem, getRandomIntBetween } from '../../../test/randomness';
|
||||||
import { fireEvent } from '@testing-library/dom';
|
import { fireEvent } from '@testing-library/dom';
|
||||||
|
@ -444,4 +445,18 @@ describe('DOM Utilities', () => {
|
||||||
expect(result).toBe(undefined);
|
expect(result).toBe(undefined);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('hideIf', () => {
|
||||||
|
it('should add "hidden" class if condition is true', () => {
|
||||||
|
const element = document.createElement('div');
|
||||||
|
hideIf(true, element);
|
||||||
|
expect(element).toHaveClass('hidden');
|
||||||
|
});
|
||||||
|
it('should remove "hidden" class if condition is false', () => {
|
||||||
|
const element = document.createElement('div');
|
||||||
|
element.classList.add('hidden');
|
||||||
|
hideIf(false, element);
|
||||||
|
expect(element).not.toHaveClass('hidden');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue