2022-03-16 19:33:09 -07:00
|
|
|
import { Record as ImmutableRecord } from 'immutable';
|
2022-03-12 13:33:53 -08:00
|
|
|
|
|
|
|
import { normalizeAttachment } from '../attachment';
|
|
|
|
|
|
|
|
describe('normalizeAttachment()', () => {
|
|
|
|
it('adds base fields', () => {
|
2022-03-16 19:33:09 -07:00
|
|
|
const attachment = {};
|
2022-03-12 13:33:53 -08:00
|
|
|
const result = normalizeAttachment(attachment);
|
|
|
|
|
|
|
|
expect(ImmutableRecord.isRecord(result)).toBe(true);
|
|
|
|
expect(result.type).toEqual('unknown');
|
|
|
|
expect(result.url).toEqual('');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('infers preview_url from url', () => {
|
2022-03-16 19:33:09 -07:00
|
|
|
const attachment = { url: 'https://site.fedi/123.png' };
|
2022-03-12 13:33:53 -08:00
|
|
|
const result = normalizeAttachment(attachment);
|
|
|
|
|
|
|
|
expect(result.preview_url).toEqual('https://site.fedi/123.png');
|
|
|
|
});
|
|
|
|
});
|