Skip typecheck for emoji-datasource
This commit is contained in:
parent
2c0ccb2e36
commit
3914216f5c
3 changed files with 30 additions and 11 deletions
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
// Camelcase disabled due to emoji-datasource using snake_case
|
// Camelcase disabled due to emoji-datasource using snake_case
|
||||||
/* eslint-disable camelcase */
|
/* eslint-disable camelcase */
|
||||||
import untypedData from 'emoji-datasource';
|
|
||||||
import emojiRegex from 'emoji-regex';
|
import emojiRegex from 'emoji-regex';
|
||||||
import {
|
import {
|
||||||
compact,
|
compact,
|
||||||
|
@ -25,6 +24,10 @@ import { MINUTE } from '../../util/durations';
|
||||||
import { drop } from '../../util/drop';
|
import { drop } from '../../util/drop';
|
||||||
import type { LocaleEmojiType } from '../../types/emoji';
|
import type { LocaleEmojiType } from '../../types/emoji';
|
||||||
|
|
||||||
|
// Import emoji-datasource dynamically to avoid costly typechecking.
|
||||||
|
// eslint-disable-next-line import/no-dynamic-require, @typescript-eslint/no-var-requires
|
||||||
|
const untypedData = require('emoji-datasource' as string);
|
||||||
|
|
||||||
export const skinTones = ['1F3FB', '1F3FC', '1F3FD', '1F3FE', '1F3FF'];
|
export const skinTones = ['1F3FB', '1F3FC', '1F3FD', '1F3FE', '1F3FF'];
|
||||||
|
|
||||||
export type SkinToneKey = '1F3FB' | '1F3FC' | '1F3FD' | '1F3FE' | '1F3FF';
|
export type SkinToneKey = '1F3FB' | '1F3FC' | '1F3FD' | '1F3FE' | '1F3FF';
|
||||||
|
@ -78,7 +81,7 @@ export type EmojiData = {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const data = (untypedData as Array<EmojiData>)
|
export const data = (untypedData as Array<EmojiData>)
|
||||||
.filter(emoji => emoji.has_img_apple)
|
.filter(emoji => emoji.has_img_apple)
|
||||||
.map(emoji =>
|
.map(emoji =>
|
||||||
// Why this weird map?
|
// Why this weird map?
|
||||||
|
|
|
@ -2,9 +2,8 @@
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
import { useEffect, useCallback, useRef } from 'react';
|
import { useEffect, useCallback, useRef } from 'react';
|
||||||
import data from 'emoji-datasource';
|
|
||||||
|
|
||||||
import { createSearch } from '../components/emoji/lib';
|
import { data, createSearch } from '../components/emoji/lib';
|
||||||
import type { SearchEmojiListType } from '../components/emoji/lib';
|
import type { SearchEmojiListType } from '../components/emoji/lib';
|
||||||
import { drop } from '../util/drop';
|
import { drop } from '../util/drop';
|
||||||
import * as log from '../logging/log';
|
import * as log from '../logging/log';
|
||||||
|
|
|
@ -1,20 +1,32 @@
|
||||||
// Copyright 2021 Signal Messenger, LLC
|
// Copyright 2021 Signal Messenger, LLC
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
import { readFileSync } from 'node:fs';
|
||||||
|
import { join } from 'node:path';
|
||||||
import { assert } from 'chai';
|
import { assert } from 'chai';
|
||||||
import * as moment from 'moment';
|
import * as moment from 'moment';
|
||||||
import { setupI18n } from '../../util/setupI18n';
|
import { setupI18n } from '../../util/setupI18n';
|
||||||
import { DurationInSeconds } from '../../util/durations';
|
import { DurationInSeconds } from '../../util/durations';
|
||||||
import enMessages from '../../../_locales/en/messages.json';
|
import type { LocaleMessagesType } from '../../types/I18N';
|
||||||
import esMessages from '../../../_locales/es/messages.json';
|
|
||||||
import nbMessages from '../../../_locales/nb/messages.json';
|
|
||||||
import nlMessages from '../../../_locales/nl/messages.json';
|
|
||||||
import ptBrMessages from '../../../_locales/pt-BR/messages.json';
|
|
||||||
import zhCnMessages from '../../../_locales/zh-CN/messages.json';
|
|
||||||
|
|
||||||
import * as expirationTimer from '../../util/expirationTimer';
|
import * as expirationTimer from '../../util/expirationTimer';
|
||||||
|
|
||||||
describe('expiration timer utilities', () => {
|
function loadMessages(locale: string): LocaleMessagesType {
|
||||||
|
const localePath = join(
|
||||||
|
__dirname,
|
||||||
|
'..',
|
||||||
|
'..',
|
||||||
|
'..',
|
||||||
|
'_locales',
|
||||||
|
locale,
|
||||||
|
'messages.json'
|
||||||
|
);
|
||||||
|
const json = readFileSync(localePath, 'utf8');
|
||||||
|
return JSON.parse(json) as LocaleMessagesType;
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('expiration timer utilities', async () => {
|
||||||
|
const enMessages = loadMessages('en');
|
||||||
const i18n = setupI18n('en', enMessages);
|
const i18n = setupI18n('en', enMessages);
|
||||||
|
|
||||||
describe('DEFAULT_DURATIONS_IN_SECONDS', () => {
|
describe('DEFAULT_DURATIONS_IN_SECONDS', () => {
|
||||||
|
@ -68,12 +80,14 @@ describe('expiration timer utilities', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('formats other languages successfully', () => {
|
it('formats other languages successfully', () => {
|
||||||
|
const esMessages = loadMessages('es');
|
||||||
const esI18n = setupI18n('es', esMessages);
|
const esI18n = setupI18n('es', esMessages);
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
format(esI18n, DurationInSeconds.fromSeconds(120)),
|
format(esI18n, DurationInSeconds.fromSeconds(120)),
|
||||||
'2 minutos'
|
'2 minutos'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const zhCnMessages = loadMessages('zh-CN');
|
||||||
const zhCnI18n = setupI18n('zh-CN', zhCnMessages);
|
const zhCnI18n = setupI18n('zh-CN', zhCnMessages);
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
format(zhCnI18n, DurationInSeconds.fromSeconds(60)),
|
format(zhCnI18n, DurationInSeconds.fromSeconds(60)),
|
||||||
|
@ -82,6 +96,7 @@ describe('expiration timer utilities', () => {
|
||||||
|
|
||||||
// The underlying library supports the "pt" locale, not the "pt_BR" locale. That's
|
// The underlying library supports the "pt" locale, not the "pt_BR" locale. That's
|
||||||
// what we're testing here.
|
// what we're testing here.
|
||||||
|
const ptBrMessages = loadMessages('pt-BR');
|
||||||
const ptBrI18n = setupI18n('pt_BR', ptBrMessages);
|
const ptBrI18n = setupI18n('pt_BR', ptBrMessages);
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
format(ptBrI18n, DurationInSeconds.fromDays(5)),
|
format(ptBrI18n, DurationInSeconds.fromDays(5)),
|
||||||
|
@ -90,6 +105,8 @@ describe('expiration timer utilities', () => {
|
||||||
|
|
||||||
// The underlying library supports the Norwegian language, which is a macrolanguage
|
// The underlying library supports the Norwegian language, which is a macrolanguage
|
||||||
// for Bokmål and Nynorsk.
|
// for Bokmål and Nynorsk.
|
||||||
|
const nbMessages = loadMessages('nb');
|
||||||
|
const nlMessages = loadMessages('nl');
|
||||||
[setupI18n('nb', nbMessages), setupI18n('nn', nlMessages)].forEach(
|
[setupI18n('nb', nbMessages), setupI18n('nn', nlMessages)].forEach(
|
||||||
norwegianI18n => {
|
norwegianI18n => {
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue