import { testIconObject } from '../src/attributes/icon/object';
import { iconDefaults } from '@iconify/utils/lib/icon';
describe('Testing testIconObject', () => {
it('Objects', () => {
expect(
testIconObject({
body: '',
})
).toEqual({
...iconDefaults,
body: '',
});
expect(
testIconObject({
body: '',
width: 24,
height: '32',
})
).toEqual({
...iconDefaults,
body: '',
width: 24,
// Validation is simple, this will fail during render
height: '32',
});
// Invalid objects
expect(testIconObject({})).toBeUndefined();
expect(
testIconObject([
{
body: '',
},
])
).toBeUndefined();
expect(
testIconObject({
body: true,
})
).toBeUndefined();
});
it('String', () => {
expect(
testIconObject(
JSON.stringify({
body: '',
})
)
).toEqual({
...iconDefaults,
body: '',
});
// Strings that are not objects
expect(testIconObject('foo')).toBeUndefined();
expect(testIconObject('{"body": ""')).toBeUndefined();
});
});