2022-03-26 12:23:29 -07:00
|
|
|
import { InstanceRecord } from 'soapbox/normalizers';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2020-05-17 12:44:33 -07:00
|
|
|
import {
|
|
|
|
parseVersion,
|
|
|
|
getFeatures,
|
|
|
|
} from '../features';
|
|
|
|
|
|
|
|
describe('parseVersion', () => {
|
|
|
|
it('with Pleroma version string', () => {
|
2020-06-07 12:26:28 -07:00
|
|
|
const version = '2.7.2 (compatible; Pleroma 2.0.5-6-ga36eb5ea-plerasstodon+dev)';
|
2020-05-17 12:44:33 -07:00
|
|
|
expect(parseVersion(version)).toEqual({
|
|
|
|
software: 'Pleroma',
|
2022-04-27 11:50:13 -07:00
|
|
|
version: '2.0.5-6-ga36eb5ea-plerasstodon',
|
2020-05-17 12:44:33 -07:00
|
|
|
compatVersion: '2.7.2',
|
2022-04-27 11:50:13 -07:00
|
|
|
build: 'dev',
|
2020-05-17 12:44:33 -07:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('with Mastodon version string', () => {
|
2020-06-07 12:26:28 -07:00
|
|
|
const version = '3.0.0';
|
2020-05-17 12:44:33 -07:00
|
|
|
expect(parseVersion(version)).toEqual({
|
|
|
|
software: 'Mastodon',
|
|
|
|
version: '3.0.0',
|
|
|
|
compatVersion: '3.0.0',
|
|
|
|
});
|
|
|
|
});
|
2022-04-10 16:21:52 -07:00
|
|
|
|
|
|
|
it('with a Pixelfed version string', () => {
|
|
|
|
const version = '2.7.2 (compatible; Pixelfed 0.11.2)';
|
|
|
|
expect(parseVersion(version)).toEqual({
|
|
|
|
software: 'Pixelfed',
|
|
|
|
version: '0.11.2',
|
|
|
|
compatVersion: '2.7.2',
|
|
|
|
});
|
|
|
|
});
|
2022-04-27 11:50:13 -07:00
|
|
|
|
|
|
|
it('with a Truth Social version string', () => {
|
|
|
|
const version = '3.4.1 (compatible; TruthSocial 1.0.0)';
|
|
|
|
expect(parseVersion(version)).toEqual({
|
|
|
|
software: 'TruthSocial',
|
|
|
|
version: '1.0.0',
|
|
|
|
compatVersion: '3.4.1',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('with a Mastodon fork', () => {
|
|
|
|
const version = '3.5.1+glitch';
|
|
|
|
expect(parseVersion(version)).toEqual({
|
|
|
|
software: 'Mastodon',
|
|
|
|
version: '3.5.1',
|
|
|
|
compatVersion: '3.5.1',
|
|
|
|
build: 'glitch',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('with a Pleroma fork', () => {
|
|
|
|
const version = '2.7.2 (compatible; Pleroma 2.4.2+cofe)';
|
|
|
|
expect(parseVersion(version)).toEqual({
|
|
|
|
software: 'Pleroma',
|
|
|
|
version: '2.4.2',
|
|
|
|
compatVersion: '2.7.2',
|
|
|
|
build: 'cofe',
|
|
|
|
});
|
|
|
|
});
|
2020-05-17 12:44:33 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('getFeatures', () => {
|
|
|
|
describe('emojiReacts', () => {
|
|
|
|
it('is true for Pleroma 2.0+', () => {
|
2022-03-26 12:23:29 -07:00
|
|
|
const instance = InstanceRecord({
|
2020-05-17 12:44:33 -07:00
|
|
|
version: '2.7.2 (compatible; Pleroma 2.0.5-6-ga36eb5ea-plerasstodon+dev)',
|
|
|
|
});
|
2020-06-07 12:26:28 -07:00
|
|
|
const features = getFeatures(instance);
|
2020-05-17 12:44:33 -07:00
|
|
|
expect(features.emojiReacts).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('is false for Pleroma < 2.0', () => {
|
2022-03-26 12:23:29 -07:00
|
|
|
const instance = InstanceRecord({
|
2020-05-17 12:44:33 -07:00
|
|
|
version: '2.7.2 (compatible; Pleroma 1.1.50-42-g3d9ac6ae-develop)',
|
|
|
|
});
|
2020-06-07 12:26:28 -07:00
|
|
|
const features = getFeatures(instance);
|
2020-05-17 12:44:33 -07:00
|
|
|
expect(features.emojiReacts).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('is false for Mastodon', () => {
|
2022-03-26 12:23:29 -07:00
|
|
|
const instance = InstanceRecord({ version: '3.1.4' });
|
2020-06-07 12:26:28 -07:00
|
|
|
const features = getFeatures(instance);
|
2020-05-17 12:44:33 -07:00
|
|
|
expect(features.emojiReacts).toBe(false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('suggestions', () => {
|
|
|
|
it('is true for Mastodon 2.4.3+', () => {
|
2022-03-26 12:23:29 -07:00
|
|
|
const instance = InstanceRecord({ version: '2.4.3' });
|
2020-06-07 12:26:28 -07:00
|
|
|
const features = getFeatures(instance);
|
2020-05-17 12:44:33 -07:00
|
|
|
expect(features.suggestions).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('is false for Mastodon < 2.4.3', () => {
|
2022-03-26 12:23:29 -07:00
|
|
|
const instance = InstanceRecord({ version: '2.4.2' });
|
2020-06-07 12:26:28 -07:00
|
|
|
const features = getFeatures(instance);
|
2020-05-17 12:44:33 -07:00
|
|
|
expect(features.suggestions).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('is false for Pleroma', () => {
|
2022-03-26 12:23:29 -07:00
|
|
|
const instance = InstanceRecord({
|
2020-05-17 12:44:33 -07:00
|
|
|
version: '2.7.2 (compatible; Pleroma 1.1.50-42-g3d9ac6ae-develop)',
|
|
|
|
});
|
2020-06-07 12:26:28 -07:00
|
|
|
const features = getFeatures(instance);
|
2020-05-17 12:44:33 -07:00
|
|
|
expect(features.suggestions).toBe(false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('trends', () => {
|
|
|
|
it('is true for Mastodon 3.0.0+', () => {
|
2022-03-26 12:23:29 -07:00
|
|
|
const instance = InstanceRecord({ version: '3.0.0' });
|
2020-06-07 12:26:28 -07:00
|
|
|
const features = getFeatures(instance);
|
2020-05-17 12:44:33 -07:00
|
|
|
expect(features.trends).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('is false for Mastodon < 3.0.0', () => {
|
2022-03-26 12:23:29 -07:00
|
|
|
const instance = InstanceRecord({ version: '2.4.3' });
|
2020-06-07 12:26:28 -07:00
|
|
|
const features = getFeatures(instance);
|
2020-05-17 12:44:33 -07:00
|
|
|
expect(features.trends).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('is false for Pleroma', () => {
|
2022-03-26 12:23:29 -07:00
|
|
|
const instance = InstanceRecord({
|
2020-05-17 12:44:33 -07:00
|
|
|
version: '2.7.2 (compatible; Pleroma 1.1.50-42-g3d9ac6ae-develop)',
|
|
|
|
});
|
2020-06-07 12:26:28 -07:00
|
|
|
const features = getFeatures(instance);
|
2020-05-17 12:44:33 -07:00
|
|
|
expect(features.trends).toBe(false);
|
|
|
|
});
|
|
|
|
});
|
2020-06-07 12:31:04 -07:00
|
|
|
|
2020-06-07 12:52:13 -07:00
|
|
|
describe('focalPoint', () => {
|
|
|
|
it('is true for Mastodon 2.3.0+', () => {
|
2022-03-26 12:23:29 -07:00
|
|
|
const instance = InstanceRecord({ version: '2.3.0' });
|
2020-06-07 12:52:13 -07:00
|
|
|
const features = getFeatures(instance);
|
|
|
|
expect(features.focalPoint).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('is false for Pleroma', () => {
|
2022-03-26 12:23:29 -07:00
|
|
|
const instance = InstanceRecord({
|
2020-06-07 12:52:13 -07:00
|
|
|
version: '2.7.2 (compatible; Pleroma 1.1.50-42-g3d9ac6ae-develop)',
|
|
|
|
});
|
|
|
|
const features = getFeatures(instance);
|
|
|
|
expect(features.focalPoint).toBe(false);
|
|
|
|
});
|
|
|
|
});
|
2020-05-17 12:44:33 -07:00
|
|
|
});
|