bigbuffet-rw/app/soapbox/utils/__tests__/status.test.ts

38 lines
1.2 KiB
TypeScript
Raw Normal View History

import { normalizeStatus } from 'soapbox/normalizers/status';
2022-06-08 09:06:14 -07:00
import {
hasIntegerMediaIds,
defaultMediaVisibility,
} from '../status';
2022-07-06 09:57:32 -07:00
import type { ReducerStatus } from 'soapbox/reducers/statuses';
describe('hasIntegerMediaIds()', () => {
it('returns true for a Pleroma deleted status', () => {
2022-07-06 09:57:32 -07:00
const status = normalizeStatus(require('soapbox/__fixtures__/pleroma-status-deleted.json')) as ReducerStatus;
expect(hasIntegerMediaIds(status)).toBe(true);
});
});
2022-06-08 09:06:14 -07:00
describe('defaultMediaVisibility()', () => {
it('returns false with no status', () => {
expect(defaultMediaVisibility(undefined, 'default')).toBe(false);
});
it('hides sensitive media by default', () => {
2022-07-06 09:57:32 -07:00
const status = normalizeStatus({ sensitive: true }) as ReducerStatus;
2022-06-08 09:06:14 -07:00
expect(defaultMediaVisibility(status, 'default')).toBe(false);
});
it('hides media when displayMedia is hide_all', () => {
2022-07-06 09:57:32 -07:00
const status = normalizeStatus({}) as ReducerStatus;
2022-06-08 09:06:14 -07:00
expect(defaultMediaVisibility(status, 'hide_all')).toBe(false);
});
it('shows sensitive media when displayMedia is show_all', () => {
2022-07-06 09:57:32 -07:00
const status = normalizeStatus({ sensitive: true }) as ReducerStatus;
2022-06-08 09:06:14 -07:00
expect(defaultMediaVisibility(status, 'show_all')).toBe(true);
});
});