2022-03-16 18:54:41 -07:00
|
|
|
|
|
|
|
import { normalizeStatus } from 'soapbox/normalizers/status';
|
|
|
|
|
2022-06-08 09:06:14 -07:00
|
|
|
import {
|
|
|
|
hasIntegerMediaIds,
|
|
|
|
defaultMediaVisibility,
|
|
|
|
} from '../status';
|
2022-03-16 18:54:41 -07:00
|
|
|
|
2022-07-06 09:57:32 -07:00
|
|
|
import type { ReducerStatus } from 'soapbox/reducers/statuses';
|
|
|
|
|
2022-03-16 18:54:41 -07:00
|
|
|
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;
|
2022-03-16 18:54:41 -07:00
|
|
|
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);
|
|
|
|
});
|
|
|
|
});
|