Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: define Instance model #837

Merged
merged 4 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions pkg/federation/model/__snapshots__/instance.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Instance > should create new instance 1`] = `
Instance {
"adminContact": "https://example.com/contact",
"adminName": "Pulsate project",
"deliverState": "normal",
"description": "pulsate official instance",
"extentions": [
"quote",
"emoji_reaction",
],
"firstContact": 2023-09-10T00:00:00.000Z,
"fqdn": "social.example.com:3000",
"id": "1",
"isLocal": true,
"name": "Pulsate social",
"silenced": "normal",
"softwareName": "Pulsate",
"softwareVersion": "0.1.0",
"state": "normal",
"updated": [
Symbol(OptionNone),
],
}
`;
41 changes: 41 additions & 0 deletions pkg/federation/model/instance.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { describe, expect, it } from 'vitest';
import { Instance, type InstanceID } from './instance.js';

describe('Instance', () => {
it('should create new instance', () => {
const res = Instance.new({
id: '1' as InstanceID,
name: 'Pulsate social',
fqdn: new URL('https://social.example.com:3000'),
softwareName: 'Pulsate',
softwareVersion: '0.1.0',
extentions: ['quote', 'emoji_reaction'],
adminName: 'Pulsate project',
description: 'pulsate official instance',
adminContact: 'https://example.com/contact',
isLocal: true,
firstContact: new Date('2023-09-10T00:00:00.000Z'),
});

expect(res).toMatchSnapshot();
});

it('should set Unknown/Unknwon if software version or name empty', () => {
const res = Instance.new({
id: '1' as InstanceID,
name: 'Pulsate social',
fqdn: new URL('https://social.example.com:3000'),
softwareName: '',
softwareVersion: '',
extentions: ['quote', 'emoji_reaction'],
adminName: 'Pulsate project',
description: 'pulsate official instance',
adminContact: 'https://example.com/contact',
isLocal: true,
firstContact: new Date('2023-09-10T00:00:00.000Z'),
});

expect(res.getSoftwareName()).toBe('Unknown');
expect(res.getSoftwareVersion()).toBe('Unknown');
});
});
Loading