2021-09-20 20:53:49 +00:00
|
|
|
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
|
|
|
|
|
|
|
describe('Testing replaceIDs', () => {
|
|
|
|
it('Simple code', () => {
|
2021-10-01 20:13:37 +00:00
|
|
|
const body =
|
|
|
|
'<defs><path id="test1"></defs><use fill="#FFA000" xlink:href="#test1"/>';
|
|
|
|
const expected =
|
2022-01-09 09:01:59 +00:00
|
|
|
'<defs><path id="callback0"></defs><use fill="#FFA000" xlink:href="#callback0"/>';
|
2021-10-01 20:13:37 +00:00
|
|
|
|
|
|
|
// Using callback
|
|
|
|
let counter = 0;
|
2022-01-09 09:01:59 +00:00
|
|
|
expect(replaceIDs(body, () => 'callback' + counter++)).toBe(expected);
|
2021-10-01 20:13:37 +00:00
|
|
|
});
|
2021-09-20 20:53:49 +00:00
|
|
|
});
|