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

36 lines
1.1 KiB
TypeScript
Raw Normal View History

2023-06-20 12:24:39 -07:00
import { buildStatus } from 'soapbox/jest/factory';
2022-06-08 09:06:14 -07:00
import {
hasIntegerMediaIds,
defaultMediaVisibility,
} from '../status';
describe('hasIntegerMediaIds()', () => {
it('returns true for a Pleroma deleted status', () => {
2023-06-20 12:24:39 -07:00
const status = buildStatus(require('soapbox/__fixtures__/pleroma-status-deleted.json'));
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', () => {
2023-06-20 12:24:39 -07:00
const status = buildStatus({ sensitive: true });
2022-06-08 09:06:14 -07:00
expect(defaultMediaVisibility(status, 'default')).toBe(false);
});
it('hides media when displayMedia is hide_all', () => {
2023-06-20 12:24:39 -07:00
const status = buildStatus({});
2022-06-08 09:06:14 -07:00
expect(defaultMediaVisibility(status, 'hide_all')).toBe(false);
});
it('shows sensitive media when displayMedia is show_all', () => {
2023-06-20 12:24:39 -07:00
const status = buildStatus({ sensitive: true });
2022-06-08 09:06:14 -07:00
expect(defaultMediaVisibility(status, 'show_all')).toBe(true);
});
});