|
Server : LiteSpeed System : Linux server354.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64 User : getfsxkz ( 1681) PHP Version : 8.1.33 Disable Function : NONE Directory : /home/getfsxkz/theaztech.org/wp-content/plugins/extendify/src/Launch/lib/__tests__/ |
Upload File : |
import { addIdAttributeToBlock } from '@launch/lib/blocks';
describe('addIdAttributeToBlock', () => {
const blockCode = '<div class="wp-block-group something">Content</div>';
it('adds id attribute to block with wp-block-group class', () => {
const result = addIdAttributeToBlock(blockCode, 'test-id');
expect(result).toContain('id="test-id"');
});
it('does not break other parts of the HTML', () => {
const result = addIdAttributeToBlock(blockCode, 'unique-id');
expect(result).toContain(
'<div class="wp-block-group something" id="unique-id">',
);
});
it('does nothing if blockCode doesn’t match the expected pattern', () => {
const input = '<div class="something-else">Hello</div>';
const result = addIdAttributeToBlock(input, 'abc');
expect(result).toBe(input);
});
});