2
0
mirror of https://github.com/iconify/iconify.git synced 2024-09-20 09:19:02 +00:00
iconify/iconify-icon/icon/tests/icon-object-test.ts

58 lines
973 B
TypeScript
Raw Normal View History

2022-04-29 20:19:22 +00:00
import { testIconObject } from '../src/attributes/icon/object';
describe('Testing testIconObject', () => {
it('Objects', () => {
expect(
testIconObject({
body: '<g />',
})
).toEqual({
body: '<g />',
});
expect(
testIconObject({
body: '<g />',
width: 24,
height: '32',
})
).toEqual({
body: '<g />',
width: 24,
// Validation is simple, this will fail during render
height: '32',
});
// Invalid objects
expect(testIconObject({})).toBeUndefined();
expect(
testIconObject([
{
body: '<g />',
},
])
).toBeUndefined();
expect(
testIconObject({
body: true,
})
).toBeUndefined();
});
it('String', () => {
expect(
testIconObject(
JSON.stringify({
body: '<g />',
})
)
).toEqual({
body: '<g />',
});
// Strings that are not objects
expect(testIconObject('foo')).toBeUndefined();
expect(testIconObject('{"body": "<g />"')).toBeUndefined();
});
});