2021-04-29 22:30:36 +03:00
|
|
|
import { expect } from 'chai'
|
2023-06-05 03:30:48 +03:00
|
|
|
import { describe } from 'mocha'
|
2022-06-30 16:32:56 +03:00
|
|
|
|
|
|
|
import { parseFileId, toUniqueFileId } from '../src'
|
2021-04-29 22:30:36 +03:00
|
|
|
|
|
|
|
// 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',
|
2023-06-05 03:30:48 +03:00
|
|
|
'AgADegAD997LEQ',
|
2021-04-29 22:30:36 +03:00
|
|
|
)
|
|
|
|
test(
|
|
|
|
'BQACAgIAAxkBAAEJnzNgit00IDsKd07OdSeanwz8osecYAACdAwAAueoWEicaPvNdOYEwB8E',
|
2023-06-05 03:30:48 +03:00
|
|
|
'AgADdAwAAueoWEg',
|
2021-04-29 22:30:36 +03:00
|
|
|
)
|
|
|
|
test(
|
|
|
|
'AAMCAgADGQEAAQmfM2CK3TQgOwp3Ts51J5qfDPyix5xgAAJ0DAAC56hYSJxo-8105gTAT_bYoy4AAwEAB20AA0JBAAIfBA',
|
2023-06-05 03:30:48 +03:00
|
|
|
'AQADdAwAAueoWEhy',
|
2021-04-29 22:30:36 +03:00
|
|
|
)
|
|
|
|
test(
|
|
|
|
'CAACAgIAAxkBAAEJny9gituz1_V_uSKBUuG_nhtzEtFOeQACXFoAAuCjggfYjw_KAAGSnkgfBA',
|
2023-06-05 03:30:48 +03:00
|
|
|
'AgADXFoAAuCjggc',
|
2021-04-29 22:30:36 +03:00
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('serializes unique ids for profile pictures', () => {
|
|
|
|
// big
|
2021-06-06 15:20:41 +03:00
|
|
|
test(
|
|
|
|
'AQADAgATySHBDgAEAwAD0npI3Bb___-wfxjpg7QCPf8pBQABHwQ',
|
2023-06-05 03:30:48 +03:00
|
|
|
'AQADySHBDgAE_ykFAAE',
|
2021-06-06 15:20:41 +03:00
|
|
|
)
|
2021-04-29 22:30:36 +03:00
|
|
|
// small
|
2021-06-06 15:20:41 +03:00
|
|
|
test(
|
|
|
|
'AQADAgATySHBDgAEAgAD0npI3Bb___-wfxjpg7QCPf0pBQABHwQ',
|
2023-06-05 03:30:48 +03:00
|
|
|
'AQADySHBDgAE_SkFAAE',
|
2021-06-06 15:20:41 +03:00
|
|
|
)
|
2021-04-29 22:30:36 +03:00
|
|
|
})
|
|
|
|
})
|