2020-08-14 13:28:09 -07:00
|
|
|
import { fromJS } from 'immutable';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2023-06-20 12:24:39 -07:00
|
|
|
import { buildStatus } from 'soapbox/jest/factory';
|
2022-06-04 00:22:36 -07:00
|
|
|
|
2022-01-10 14:01:24 -08:00
|
|
|
import { shouldFilter } from '../timelines';
|
2020-08-14 13:28:09 -07:00
|
|
|
|
|
|
|
describe('shouldFilter', () => {
|
|
|
|
it('returns false under normal circumstances', () => {
|
|
|
|
const columnSettings = fromJS({});
|
2023-06-20 12:24:39 -07:00
|
|
|
const status = buildStatus({});
|
2020-08-14 13:28:09 -07:00
|
|
|
expect(shouldFilter(status, columnSettings)).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('reblog: returns true when `shows.reblog == false`', () => {
|
|
|
|
const columnSettings = fromJS({ shows: { reblog: false } });
|
2023-06-20 12:24:39 -07:00
|
|
|
const status = buildStatus({ reblog: {} });
|
2020-08-14 13:28:09 -07:00
|
|
|
expect(shouldFilter(status, columnSettings)).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('reblog: returns false when `shows.reblog == true`', () => {
|
|
|
|
const columnSettings = fromJS({ shows: { reblog: true } });
|
2023-06-20 12:24:39 -07:00
|
|
|
const status = buildStatus({ reblog: {} });
|
2020-08-14 13:28:09 -07:00
|
|
|
expect(shouldFilter(status, columnSettings)).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('reply: returns true when `shows.reply == false`', () => {
|
|
|
|
const columnSettings = fromJS({ shows: { reply: false } });
|
2023-06-20 12:24:39 -07:00
|
|
|
const status = buildStatus({ in_reply_to_id: '1234' });
|
2020-08-14 13:28:09 -07:00
|
|
|
expect(shouldFilter(status, columnSettings)).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('reply: returns false when `shows.reply == true`', () => {
|
|
|
|
const columnSettings = fromJS({ shows: { reply: true } });
|
2023-06-20 12:24:39 -07:00
|
|
|
const status = buildStatus({ in_reply_to_id: '1234' });
|
2020-08-14 13:28:09 -07:00
|
|
|
expect(shouldFilter(status, columnSettings)).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('direct: returns true when `shows.direct == false`', () => {
|
|
|
|
const columnSettings = fromJS({ shows: { direct: false } });
|
2023-06-20 12:24:39 -07:00
|
|
|
const status = buildStatus({ visibility: 'direct' });
|
2020-08-14 13:28:09 -07:00
|
|
|
expect(shouldFilter(status, columnSettings)).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('direct: returns false when `shows.direct == true`', () => {
|
|
|
|
const columnSettings = fromJS({ shows: { direct: true } });
|
2023-06-20 12:24:39 -07:00
|
|
|
const status = buildStatus({ visibility: 'direct' });
|
2020-08-14 13:28:09 -07:00
|
|
|
expect(shouldFilter(status, columnSettings)).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('direct: returns false for a public post when `shows.direct == false`', () => {
|
|
|
|
const columnSettings = fromJS({ shows: { direct: false } });
|
2023-06-20 12:24:39 -07:00
|
|
|
const status = buildStatus({ visibility: 'public' });
|
2020-08-14 13:28:09 -07:00
|
|
|
expect(shouldFilter(status, columnSettings)).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('multiple settings', () => {
|
|
|
|
const columnSettings = fromJS({ shows: { reblog: false, reply: false, direct: false } });
|
2023-06-20 12:24:39 -07:00
|
|
|
const status = buildStatus({ reblog: null, in_reply_to_id: null, visibility: 'direct' });
|
2020-08-14 13:28:09 -07:00
|
|
|
expect(shouldFilter(status, columnSettings)).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('multiple settings', () => {
|
|
|
|
const columnSettings = fromJS({ shows: { reblog: false, reply: true, direct: false } });
|
2023-06-20 12:24:39 -07:00
|
|
|
const status = buildStatus({ reblog: null, in_reply_to_id: '1234', visibility: 'public' });
|
2020-08-14 13:28:09 -07:00
|
|
|
expect(shouldFilter(status, columnSettings)).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('multiple settings', () => {
|
|
|
|
const columnSettings = fromJS({ shows: { reblog: true, reply: false, direct: true } });
|
2023-06-20 12:24:39 -07:00
|
|
|
const status = buildStatus({ reblog: {}, in_reply_to_id: '1234', visibility: 'direct' });
|
2020-08-14 13:28:09 -07:00
|
|
|
expect(shouldFilter(status, columnSettings)).toBe(true);
|
|
|
|
});
|
|
|
|
});
|