Emoji favicons for the web
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: test settings migration

+119 -2
+2 -1
source/background.ts
··· 41 41 async function syncSettings() { 42 42 const storedSettings: Settings | SettingsV1 = await browserAPI.storage.sync 43 43 .get(STORAGE_KEYS) as Settings | SettingsV1; 44 - 45 44 if (!storedSettings) return; 46 45 47 46 if (isV1Settings(storedSettings)) { 47 + console.info('Version < 2 versions found', storedSettings); 48 48 settings = migrateFromV1(storedSettings); 49 + console.info('Migrating to', settings); 49 50 await browserAPI.storage.sync.remove(LEGACY_STORAGE_KEYS); 50 51 await browserAPI.storage.sync.set(settings); 51 52 } else {
+102
source/utilities/__tests__/fixtures/settings_data.ts
··· 1 + import type { Settings, SettingsV1 } from '../../settings.ts'; 2 + 3 + import * as emoji from 'emoji'; 4 + import FaviconData from '../../favicon_data.ts'; 5 + 6 + export const v0: SettingsV1 = { 7 + 'flagReplaced': true, 8 + 'overrideAll': false, 9 + 'overrides': [ 10 + { 11 + 'emoji': '😍', 12 + 'filter': 'hello', 13 + }, 14 + { 15 + 'emoji': '😃', 16 + 'filter': 'goodbye', 17 + }, 18 + { 19 + 'emoji': '🤩', 20 + 'filter': 'sweet lahd', 21 + }, 22 + ], 23 + 'skips': [ 24 + 'hahahahh', 25 + ], 26 + }; 27 + 28 + export const v1: SettingsV1 = { 29 + 'flagReplaced': true, 30 + 'overrideAll': false, 31 + 'overrides': [ 32 + { 33 + 'emoji': { 34 + 'colons': ':heart_eyes:', 35 + 'emoticons': [], 36 + 'id': 'heart_eyes', 37 + 'name': 'Smiling Face with Heart-Shaped Eyes', 38 + 'native': '😍', 39 + 'short_names': [ 40 + 'heart_eyes', 41 + ], 42 + 'skin': null, 43 + 'unified': '1f60d', 44 + }, 45 + 'filter': 'hello', 46 + }, 47 + { 48 + 'emoji': { 49 + 'colons': ':smiley:', 50 + 'emoticons': [ 51 + '=)', 52 + '=-)', 53 + ], 54 + 'id': 'smiley', 55 + 'name': 'Smiling Face with Open Mouth', 56 + 'native': '😃', 57 + 'short_names': [ 58 + 'smiley', 59 + ], 60 + 'skin': null, 61 + 'unified': '1f603', 62 + }, 63 + 'filter': 'goodbye', 64 + }, 65 + { 66 + 'emoji': { 67 + 'colons': ':star-struck:', 68 + 'emoticons': [], 69 + 'id': 'star-struck', 70 + 'name': 'Grinning Face with Star Eyes', 71 + 'native': '🤩', 72 + 'short_names': [ 73 + 'star-struck', 74 + 'grinning_face_with_star_eyes', 75 + ], 76 + 'skin': null, 77 + 'unified': '1f929', 78 + }, 79 + 'filter': 'sweet lahd', 80 + }, 81 + ], 82 + 'skips': [ 83 + 'hahahahh', 84 + ], 85 + }; 86 + 87 + export const v2: Settings = { 88 + 'features': { 89 + 'enableFaviconAutofill': true, 90 + 'enableOverrideAll': false, 91 + 'enableSiteIgnore': true, 92 + }, 93 + 'ignoreList': [ 94 + new FaviconData(undefined, 'hahahahh'), 95 + ], 96 + 'siteList': [ 97 + new FaviconData(emoji.infoByCode('😍'), 'hello'), 98 + new FaviconData(emoji.infoByCode('😃'), 'goodbye'), 99 + new FaviconData(emoji.infoByCode('🤩'), 'sweet lahd'), 100 + ], 101 + 'version': '2.0.0', 102 + };
+14 -1
source/utilities/__tests__/settings.test.ts
··· 1 1 import { assertEquals } from 'asserts'; 2 2 import { describe, it } from 'bdd'; 3 3 4 - import { parseVersion } from '../settings.ts'; 4 + import { isV1Settings, migrateFromV1, parseVersion } from '../settings.ts'; 5 + import { v0, v1, v2 } from './fixtures/settings_data.ts'; 5 6 6 7 describe('parseVersion', () => { 7 8 it('should parse version with descriptor', () => { ··· 38 39 } 39 40 }); 40 41 }); 42 + 43 + describe('migrateFromV1', () => { 44 + it('should migrate from v0 to v2', () => { 45 + assertEquals(isV1Settings(v0), true); 46 + assertEquals(migrateFromV1(v0), v2); 47 + }); 48 + 49 + it('should migrate from v1 to v2', () => { 50 + assertEquals(isV1Settings(v1), true); 51 + assertEquals(migrateFromV1(v1), v2); 52 + }); 53 + });
+1
source/utilities/settings.ts
··· 33 33 id: string; 34 34 name: string; 35 35 native: string; 36 + short_names: string[]; 36 37 skin: null; 37 38 unified: string; 38 39 };