mtcute/packages/file-id/tests/serialize-unique.spec.ts

34 lines
1.3 KiB
TypeScript
Raw Normal View History

import { expect } from 'chai'
import { describe } from 'mocha'
import { parseFileId, toUniqueFileId } from '../src/index.js'
// test file IDs are partially taken from https://github.com/luckydonald/telegram_file_id
describe('serializing unique file ids', () => {
const test = (id: string, expected: string) => {
expect(toUniqueFileId(parseFileId(id))).eql(expected)
}
it('serializes unique ids for old file ids', () => {
test('CAADAQADegAD997LEUiQZafDlhIeAg', 'AgADegAD997LEQ')
})
it('serializes unique ids for common file ids', () => {
2023-09-24 01:32:22 +03:00
test('CAACAgEAAx0CVgtngQACAuFfU1GY9wiRG7A7jlIBbP2yvAostAACegAD997LEUiQZafDlhIeGwQ', 'AgADegAD997LEQ')
test('BQACAgIAAxkBAAEJnzNgit00IDsKd07OdSeanwz8osecYAACdAwAAueoWEicaPvNdOYEwB8E', 'AgADdAwAAueoWEg')
test(
'AAMCAgADGQEAAQmfM2CK3TQgOwp3Ts51J5qfDPyix5xgAAJ0DAAC56hYSJxo-8105gTAT_bYoy4AAwEAB20AA0JBAAIfBA',
'AQADdAwAAueoWEhy',
)
2023-09-24 01:32:22 +03:00
test('CAACAgIAAxkBAAEJny9gituz1_V_uSKBUuG_nhtzEtFOeQACXFoAAuCjggfYjw_KAAGSnkgfBA', 'AgADXFoAAuCjggc')
})
it('serializes unique ids for profile pictures', () => {
// big
2023-09-24 01:32:22 +03:00
test('AQADAgATySHBDgAEAwAD0npI3Bb___-wfxjpg7QCPf8pBQABHwQ', 'AQADySHBDgAE_ykFAAE')
// small
2023-09-24 01:32:22 +03:00
test('AQADAgATySHBDgAEAgAD0npI3Bb___-wfxjpg7QCPf0pBQABHwQ', 'AQADySHBDgAE_SkFAAE')
})
})