|
1 | | -/** |
2 | | - * @jest-environment node |
3 | | - */ |
4 | 1 | import React from 'react'; |
5 | 2 | import { render } from '@testing-library/react'; |
6 | 3 | import { |
7 | 4 | Icon, |
8 | 5 | SpriteContextProvider, |
9 | 6 | IconsCache, |
10 | 7 | initOnClient, |
11 | | - renderSpriteSheetToString, |
12 | 8 | } from '../src/index'; |
13 | 9 | import { act } from 'react-dom/test-utils'; |
14 | | -import { renderToString } from 'react-dom/server'; |
15 | 10 |
|
16 | 11 | const svg1 = `<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"> |
17 | 12 | <path d="M0 0h24v24H0z" fill="none"/> |
@@ -63,24 +58,6 @@ test('should fill the cache when an icon is rendered', async () => { |
63 | 58 | }); |
64 | 59 | }); |
65 | 60 |
|
66 | | -test('render loaded svgs to a svg sprite sheet string', async () => { |
67 | | - const cache: IconsCache = new Map(); |
68 | | - const renderedString = renderToString( |
69 | | - <SpriteContextProvider knownIcons={cache} loadSVG={loadSVG}> |
70 | | - <Icon url={'1'}></Icon> |
71 | | - </SpriteContextProvider>, |
72 | | - ); |
73 | | - |
74 | | - const renderedSpriteSheet = await renderSpriteSheetToString( |
75 | | - renderedString, |
76 | | - cache, |
77 | | - ); |
78 | | - |
79 | | - expect(renderedSpriteSheet).toMatchInlineSnapshot( |
80 | | - `"<svg><use xlink:href=\\"#1\\"></use></svg><svg id=\\"__SVG_SPRITE_SHEET__\\" style=\\"display:none\\"><symbol id=\\"1\\" xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 24 24\\"><path d=\\"M0 0h24v24H0z\\" fill=\\"none\\"/></symbol></svg>"`, |
81 | | - ); |
82 | | -}); |
83 | | - |
84 | 61 | test('client should be able to initiate the cache from a rendered dom', async () => { |
85 | 62 | const cache: IconsCache = new Map(); |
86 | 63 | document.body.innerHTML = `<svg id="__SVG_SPRITE_SHEET__" style="display:none"> |
|
0 commit comments