mirror of
https://github.com/tabler/tabler-icons.git
synced 2025-08-11 08:34:10 +02:00
Add title to icon's <svg> as child tag in React, Vue.js and React Native (#1147)
* Add title as child tag of <svg> in icons-react * Add title as child tag of <svg> in icons-vue package * Add title as child tag of <svg> in icons-react-native package * Test <title> element in React * Prevent adding <!----> to <svg> if no title prop passed + Test <title> child element. * Fix tests for Vue Stroke attribute added to expected SVG code. --------- Co-authored-by: Bartłomiej Gawęda <bgaweda@abis.krakow.pl>
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import { describe, it, expect, afterEach, assertType, expectTypeOf } from 'vitest';
|
||||
import { describe, it, expect, afterEach, expectTypeOf } from 'vitest';
|
||||
import { render, cleanup } from '@testing-library/react'
|
||||
import { IconAccessible, IconAccessibleFilled, createReactComponent } from "./src/tabler-icons-react"
|
||||
import type { IconNode } from './src/tabler-icons-react';
|
||||
import { ReactNode } from 'react';
|
||||
|
||||
describe("React Icon component", () => {
|
||||
afterEach(() => {
|
||||
@@ -58,6 +56,14 @@ describe("React Icon component", () => {
|
||||
expectTypeOf(IconAccessible).toEqualTypeOf(createReactComponent('outline', 'accessible', 'Accessible', []));
|
||||
});
|
||||
|
||||
it('should add title child element to svg when title prop is passed', () => {
|
||||
const { container } = render(<IconAccessible title="Accessible Icon"/>);
|
||||
const svg = container.getElementsByTagName("svg")[0];
|
||||
const title = svg.getElementsByTagName("title")[0];
|
||||
|
||||
expect(title).toHaveTextContent("Accessible Icon");
|
||||
})
|
||||
|
||||
it("should match snapshot", () => {
|
||||
const { container } = render(<IconAccessible/>)
|
||||
expect(container.innerHTML).toMatchInlineSnapshot(`
|
||||
|
Reference in New Issue
Block a user