2024-11-09 19:43:30 +00:00
|
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
|
2024-11-10 03:18:55 +00:00
|
|
|
import { ADMIN_CONFIG_UPDATE_REQUEST } from 'soapbox/actions/admin.ts';
|
2022-01-31 20:26:42 +00:00
|
|
|
|
2024-11-10 03:18:55 +00:00
|
|
|
import reducer from './instance.ts';
|
2020-06-10 01:08:07 +00:00
|
|
|
|
|
|
|
describe('instance reducer', () => {
|
|
|
|
it('should return the initial state', () => {
|
2022-06-12 14:30:48 +00:00
|
|
|
const result = reducer(undefined, {} as any);
|
2022-03-09 05:25:30 +00:00
|
|
|
|
|
|
|
const expected = {
|
2021-07-19 21:15:42 +00:00
|
|
|
description_limit: 1500,
|
2022-03-09 05:25:30 +00:00
|
|
|
configuration: {
|
2022-11-21 17:21:02 +00:00
|
|
|
chats: {
|
2023-02-08 20:07:31 +00:00
|
|
|
max_characters: 5000,
|
|
|
|
max_media_attachments: 1,
|
2022-11-21 17:21:02 +00:00
|
|
|
},
|
2022-03-09 05:25:30 +00:00
|
|
|
statuses: {
|
2022-01-31 20:26:42 +00:00
|
|
|
max_characters: 500,
|
2022-01-31 23:52:12 +00:00
|
|
|
max_media_attachments: 4,
|
2022-03-09 05:25:30 +00:00
|
|
|
},
|
|
|
|
polls: {
|
2022-01-31 20:26:42 +00:00
|
|
|
max_options: 4,
|
|
|
|
max_characters_per_option: 25,
|
|
|
|
min_expiration: 300,
|
|
|
|
max_expiration: 2629746,
|
2022-03-09 05:25:30 +00:00
|
|
|
},
|
|
|
|
},
|
2021-01-18 20:14:08 +00:00
|
|
|
version: '0.0.0',
|
2022-03-09 05:25:30 +00:00
|
|
|
};
|
|
|
|
|
2023-09-24 01:41:24 +00:00
|
|
|
expect(result).toMatchObject(expected);
|
2020-06-10 01:08:07 +00:00
|
|
|
});
|
2022-01-31 20:26:42 +00:00
|
|
|
|
2023-10-09 03:18:34 +00:00
|
|
|
describe('ADMIN_CONFIG_UPDATE_REQUEST', async () => {
|
|
|
|
const { configs } = await import('soapbox/__fixtures__/pleroma-admin-config.json');
|
2022-03-20 23:41:47 +00:00
|
|
|
|
|
|
|
it('imports the configs', () => {
|
|
|
|
const action = {
|
|
|
|
type: ADMIN_CONFIG_UPDATE_REQUEST,
|
|
|
|
configs,
|
|
|
|
};
|
|
|
|
|
|
|
|
// The normalizer has `registrations: closed` by default
|
2022-06-12 14:30:48 +00:00
|
|
|
const state = reducer(undefined, {} as any);
|
2022-03-20 23:41:47 +00:00
|
|
|
expect(state.registrations).toBe(false);
|
|
|
|
|
|
|
|
// After importing the configs, registration will be open
|
2024-10-11 08:39:58 +00:00
|
|
|
// @ts-ignore don't know why the type is not working
|
2022-03-20 23:41:47 +00:00
|
|
|
const result = reducer(state, action);
|
|
|
|
expect(result.registrations).toBe(true);
|
|
|
|
});
|
|
|
|
});
|
2020-06-10 01:08:07 +00:00
|
|
|
});
|