/
githubmirror
/
nativefier
Обзор
Документация
Войти
/
githubmirror
/
nativefier
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/utils/sanitizeFilename.test.ts
34 строки
1 KB
Adam Weeden
Allow non-ascii app names like 微信读书 (fix #1056) (#1207)
01 июн 2021, 06:27
Не верифицирован
01 июн 2021, 06:27
86a27d4
Код
Авторство
О чём код?
import { sanitizeFilename } from './sanitizeFilename'; import { DEFAULT_APP_NAME } from '../constants'; describe('replacing reserved characters', () => { const reserved = '\\/?*<>:|'; test('it should return a result without reserved characters', () => { const expectedResult = 'abc'; const param = `${reserved}${expectedResult}`; const result = sanitizeFilename('', param); expect(result).toBe(expectedResult); }); test('it should allow non-ascii characters', () => { const expectedResult = '微信读书'; const param = `${reserved}${expectedResult}`; const result = sanitizeFilename('', param); expect(result).toBe(expectedResult); }); test('when the result of replacing these characters is empty, use default', () => { const result = sanitizeFilename('', reserved); expect(result).toBe(DEFAULT_APP_NAME); }); }); describe('when the platform is linux', () => { test('it should return a name without spaces', () => { const param = 'some name'; const expectedResult = 'somename'; const result = sanitizeFilename('linux', param); expect(result).toBe(expectedResult); }); });