Fix bug where color palette could not be empty

This commit is contained in:
Adam Wathan 2020-11-13 19:51:05 -05:00
parent 869d68d03b
commit 278c2031fb
2 changed files with 5 additions and 0 deletions

View file

@ -75,3 +75,7 @@ test('it flattens deeply nested color objects', () => {
'button-primary-focus-variant': 'orange',
})
})
test('it handles empty objects', () => {
expect(flattenColorPalette({})).toEqual({})
})

View file

@ -1,5 +1,6 @@
const flattenColorPalette = (colors) =>
Object.assign(
{},
...Object.entries(colors).flatMap(([color, values]) =>
typeof values == 'object'
? Object.entries(flattenColorPalette(values)).map(([number, hex]) => ({