diff --git a/packages/utils/tests/get-icon-test.ts b/packages/utils/tests/get-icon-test.ts index 7951b6d..0cfea02 100644 --- a/packages/utils/tests/get-icon-test.ts +++ b/packages/utils/tests/get-icon-test.ts @@ -23,16 +23,16 @@ describe('Testing getting icon data', () => { test('Minified icon set', () => { const result = getIconData( { - prefix: 'foo', + prefix: 'test_set', icons: { - bar: { + test_icon: { body: '', }, }, width: 24, height: 24, }, - 'bar' + 'test_icon' ); expect(result).toEqual({ body: '', @@ -40,4 +40,32 @@ describe('Testing getting icon data', () => { height: 24, }); }); + + test('Alias', () => { + const result = getIconData( + { + prefix: 'test_set', + icons: { + test_icon: { + body: '', + }, + }, + aliases: { + test_alias: { + parent: 'test_icon', + rotate: 2, + }, + }, + width: 24, + height: 24, + }, + 'test_alias' + ); + expect(result).toEqual({ + body: '', + width: 24, + height: 24, + rotate: 2, + }); + }); }); diff --git a/packages/utils/tests/get-icons-test.ts b/packages/utils/tests/get-icons-test.ts index 6898d1b..f6b2150 100644 --- a/packages/utils/tests/get-icons-test.ts +++ b/packages/utils/tests/get-icons-test.ts @@ -70,7 +70,7 @@ describe('Testing retrieving icons from icon set', () => { bar: { body: '', }, - bar2: { + bar_2: { body: '', }, }, @@ -79,7 +79,7 @@ describe('Testing retrieving icons from icon set', () => { parent: 'bar', hFlip: true, }, - 'foo2': { + 'foo_2': { parent: 'foo', }, 'missing-alias': { @@ -87,10 +87,10 @@ describe('Testing retrieving icons from icon set', () => { }, }, chars: { - f00: 'bar2', + f00: 'bar_2', f01: 'bar', f02: 'foo', - f03: 'foo2', + f03: 'foo_2', f04: 'missing-icon', }, }; @@ -113,7 +113,7 @@ describe('Testing retrieving icons from icon set', () => { }); // Alias of alias - expect(getIcons(data, ['foo2'])).toEqual({ + expect(getIcons(data, ['foo_2'])).toEqual({ prefix: 'foo', lastModified, icons: { @@ -126,7 +126,7 @@ describe('Testing retrieving icons from icon set', () => { parent: 'bar', hFlip: true, }, - foo2: { + foo_2: { parent: 'foo', }, }, diff --git a/packages/utils/tests/icons-to-css-test.ts b/packages/utils/tests/icons-to-css-test.ts index 73298ef..332814b 100644 --- a/packages/utils/tests/icons-to-css-test.ts +++ b/packages/utils/tests/icons-to-css-test.ts @@ -16,7 +16,7 @@ describe('Testing CSS for multiple icons', () => { 'airplane': { body: '', }, - 'airplane-engines': { + 'airplane_engines': { body: '', }, 'empty': { @@ -33,12 +33,16 @@ describe('Testing CSS for multiple icons', () => { // Detect mode: mask expect( - getIconsCSS(iconSet, ['activity', '123', 'airplane', 'missing'], { - format: 'expanded', - rules: { - visibility: 'visible', - }, - }) + getIconsCSS( + iconSet, + ['activity', '123', 'airplane_engines', 'missing'], + { + format: 'expanded', + rules: { + visibility: 'visible', + }, + } + ) ).toBe(`.icon--test-prefix { visibility: visible; display: inline-block; @@ -61,8 +65,8 @@ describe('Testing CSS for multiple icons', () => { --svg: ${expectedURL('123')}; } -.icon--test-prefix--airplane { - --svg: ${expectedURL('airplane')}; +.icon--test-prefix--airplane_engines { + --svg: ${expectedURL('airplane_engines')}; } /* Could not find icon: missing */ diff --git a/packages/utils/tests/parse-icons-test.ts b/packages/utils/tests/parse-icons-test.ts index 3a58c8a..354367f 100644 --- a/packages/utils/tests/parse-icons-test.ts +++ b/packages/utils/tests/parse-icons-test.ts @@ -4,16 +4,16 @@ import { parseIconSet, parseIconSetAsync } from '../lib/icon-set/parse'; describe('Testing parsing icon set', () => { test('Simple icon set', () => { // Names list - const names: string[] = ['missing', 'icon1', 'icon2']; + const names: string[] = ['missing', 'icon_1', 'icon_2']; // Resolved data const expected: Record = { - icon1: { + icon_1: { body: '', width: 20, height: 24, }, - icon2: { + icon_2: { body: '', width: 24, height: 24, @@ -28,11 +28,11 @@ describe('Testing parsing icon set', () => { prefix: 'foo', not_found: ['missing'], icons: { - icon1: { + icon_1: { body: '', width: 20, }, - icon2: { + icon_2: { body: '', width: 24, }, @@ -48,7 +48,7 @@ describe('Testing parsing icon set', () => { expect(data).toEqual(expected[name]); } ) - ).toEqual(['missing', 'icon1', 'icon2']); + ).toEqual(['missing', 'icon_1', 'icon_2']); // All names should have been parsed expect(names).toEqual([]); diff --git a/packages/utils/tests/validate-alias-test.ts b/packages/utils/tests/validate-alias-test.ts index ce68133..be113bf 100644 --- a/packages/utils/tests/validate-alias-test.ts +++ b/packages/utils/tests/validate-alias-test.ts @@ -58,7 +58,9 @@ describe('Testing validating alias', () => { }, aliases: null, }); - reject('Expected to throw error when aliases is null'); + reject( + new Error('Expected to throw error when aliases is null') + ); return; } catch { // @@ -108,8 +110,10 @@ describe('Testing validating alias', () => { }, }); reject( - 'Expected to throw error when alias has missing parent, got ' + - JSON.stringify(result) + new Error( + 'Expected to throw error when alias has missing parent, got ' + + JSON.stringify(result) + ) ); return; } catch { @@ -167,8 +171,10 @@ describe('Testing validating alias', () => { }, }); reject( - 'Expected to throw error when alias has missing parent, got ' + - JSON.stringify(result) + new Error( + 'Expected to throw error when alias has missing parent, got ' + + JSON.stringify(result) + ) ); return; } catch { @@ -229,8 +235,10 @@ describe('Testing validating alias', () => { }, }); reject( - 'Expected to throw error when alias has missing parent, got ' + - JSON.stringify(result) + new Error( + 'Expected to throw error when alias has missing parent, got ' + + JSON.stringify(result) + ) ); return; } catch { @@ -294,8 +302,10 @@ describe('Testing validating alias', () => { }, }); reject( - 'Expected to throw error when alias has missing parent, got ' + - JSON.stringify(result) + new Error( + 'Expected to throw error when alias has missing parent, got ' + + JSON.stringify(result) + ) ); return; } catch {