fix tests
This commit is contained in:
parent
24437a04d4
commit
34d1b463a4
4 changed files with 18 additions and 17 deletions
|
@ -35,7 +35,7 @@ describe('AnnouncementService', () => {
|
|||
function createUser(data: Partial<MiUser> = {}) {
|
||||
const un = secureRndstr(16);
|
||||
return usersRepository.insert({
|
||||
id: genAidx(new Date()),
|
||||
id: genAidx(Date.now()),
|
||||
username: un,
|
||||
usernameLower: un,
|
||||
...data,
|
||||
|
|
|
@ -37,7 +37,7 @@ describe('RoleService', () => {
|
|||
function createUser(data: Partial<MiUser> = {}) {
|
||||
const un = secureRndstr(16);
|
||||
return usersRepository.insert({
|
||||
id: genAidx(new Date()),
|
||||
id: genAidx(Date.now()),
|
||||
username: un,
|
||||
usernameLower: un,
|
||||
...data,
|
||||
|
@ -47,7 +47,7 @@ describe('RoleService', () => {
|
|||
|
||||
function createRole(data: Partial<MiRole> = {}) {
|
||||
return rolesRepository.insert({
|
||||
id: genAidx(new Date()),
|
||||
id: genAidx(Date.now()),
|
||||
updatedAt: new Date(),
|
||||
lastUsedAt: new Date(),
|
||||
description: '',
|
||||
|
|
|
@ -23,6 +23,7 @@ import { secureRndstr } from '@/misc/secure-rndstr.js';
|
|||
import { DownloadService } from '@/core/DownloadService.js';
|
||||
import { MetaService } from '@/core/MetaService.js';
|
||||
import type { MiRemoteUser } from '@/models/User.js';
|
||||
import { genAidx } from '@/misc/id/aidx.js';
|
||||
import { MockResolver } from '../misc/mock-resolver.js';
|
||||
|
||||
const host = 'https://host1.test';
|
||||
|
@ -200,7 +201,7 @@ describe('ActivityPub', () => {
|
|||
describe('Renderer', () => {
|
||||
test('Render an announce with visibility: followers', () => {
|
||||
rendererService.renderAnnounce(null, {
|
||||
createdAt: new Date(0),
|
||||
id: genAidx(Date.now()),
|
||||
visibility: 'followers',
|
||||
} as MiNote);
|
||||
});
|
||||
|
|
|
@ -14,44 +14,44 @@ import { ulidRegExp, parseUlid } from '@/misc/id/ulid.js';
|
|||
|
||||
describe('misc:id', () => {
|
||||
test('aid', () => {
|
||||
const date = new Date();
|
||||
const date = Date.now();
|
||||
const gotAid = genAid(date);
|
||||
expect(gotAid).toMatch(aidRegExp);
|
||||
expect(parseAid(gotAid).date.getTime()).toBe(date.getTime());
|
||||
expect(parseAid(gotAid).date.getTime()).toBe(date);
|
||||
});
|
||||
|
||||
test('aidx', () => {
|
||||
const date = new Date();
|
||||
const date = Date.now();
|
||||
const gotAidx = genAidx(date);
|
||||
expect(gotAidx).toMatch(aidxRegExp);
|
||||
expect(parseAidx(gotAidx).date.getTime()).toBe(date.getTime());
|
||||
expect(parseAidx(gotAidx).date.getTime()).toBe(date);
|
||||
});
|
||||
|
||||
test('meid', () => {
|
||||
const date = new Date();
|
||||
const date = Date.now();
|
||||
const gotMeid = genMeid(date);
|
||||
expect(gotMeid).toMatch(meidRegExp);
|
||||
expect(parseMeid(gotMeid).date.getTime()).toBe(date.getTime());
|
||||
expect(parseMeid(gotMeid).date.getTime()).toBe(date);
|
||||
});
|
||||
|
||||
test('meidg', () => {
|
||||
const date = new Date();
|
||||
const date = Date.now();
|
||||
const gotMeidg = genMeidg(date);
|
||||
expect(gotMeidg).toMatch(meidgRegExp);
|
||||
expect(parseMeidg(gotMeidg).date.getTime()).toBe(date.getTime());
|
||||
expect(parseMeidg(gotMeidg).date.getTime()).toBe(date);
|
||||
});
|
||||
|
||||
test('objectid', () => {
|
||||
const date = new Date();
|
||||
const date = Date.now();
|
||||
const gotObjectId = genObjectId(date);
|
||||
expect(gotObjectId).toMatch(objectIdRegExp);
|
||||
expect(Math.floor(parseObjectId(gotObjectId).date.getTime() / 1000)).toBe(Math.floor(date.getTime() / 1000));
|
||||
expect(Math.floor(parseObjectId(gotObjectId).date.getTime() / 1000)).toBe(Math.floor(date / 1000));
|
||||
});
|
||||
|
||||
test('ulid', () => {
|
||||
const date = new Date();
|
||||
const gotUlid = ulid(date.getTime());
|
||||
const date = Date.now();
|
||||
const gotUlid = ulid(date);
|
||||
expect(gotUlid).toMatch(ulidRegExp);
|
||||
expect(parseUlid(gotUlid).date.getTime()).toBe(date.getTime());
|
||||
expect(parseUlid(gotUlid).date.getTime()).toBe(date);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue