42 lines
1.5 KiB
TypeScript
42 lines
1.5 KiB
TypeScript
import { describe } from 'mocha'
|
|
import { expect } from 'chai'
|
|
import { parseFileId } from '../src/parse'
|
|
import { toUniqueFileId } from '../src/serialize-unique'
|
|
|
|
// 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', () => {
|
|
test(
|
|
'CAACAgEAAx0CVgtngQACAuFfU1GY9wiRG7A7jlIBbP2yvAostAACegAD997LEUiQZafDlhIeGwQ',
|
|
'AgADegAD997LEQ'
|
|
)
|
|
test(
|
|
'BQACAgIAAxkBAAEJnzNgit00IDsKd07OdSeanwz8osecYAACdAwAAueoWEicaPvNdOYEwB8E',
|
|
'AgADdAwAAueoWEg'
|
|
)
|
|
test(
|
|
'AAMCAgADGQEAAQmfM2CK3TQgOwp3Ts51J5qfDPyix5xgAAJ0DAAC56hYSJxo-8105gTAT_bYoy4AAwEAB20AA0JBAAIfBA',
|
|
'AQADT_bYoy4AA0JBAAI'
|
|
)
|
|
test(
|
|
'CAACAgIAAxkBAAEJny9gituz1_V_uSKBUuG_nhtzEtFOeQACXFoAAuCjggfYjw_KAAGSnkgfBA',
|
|
'AgADXFoAAuCjggc'
|
|
)
|
|
})
|
|
|
|
it('serializes unique ids for profile pictures', () => {
|
|
// big
|
|
test('AQADAgATySHBDgAEAwAD0npI3Bb___-wfxjpg7QCPf8pBQABHwQ', 'AQADySHBDgAE_ykFAAE')
|
|
// small
|
|
test('AQADAgATySHBDgAEAgAD0npI3Bb___-wfxjpg7QCPf0pBQABHwQ', 'AQADySHBDgAE_SkFAAE')
|
|
})
|
|
})
|