pl-api: initialize tests
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
/node_modules/
|
||||
yarn-error.log*
|
||||
coverage/
|
||||
@ -18,5 +18,5 @@
|
||||
"typeRoots": ["./src/types", "./node_modules/@types", "./node_modules"],
|
||||
"types": ["vite/client", "vite-plugin-compile-time/client", "dom-chromium-ai"]
|
||||
},
|
||||
"exclude": ["src/**/*.test.ts", "src/**/*.test.tsx"]
|
||||
"exclude": ["tests/**/*.test.ts", "tests/**/*.test.tsx"]
|
||||
}
|
||||
|
||||
@ -24,7 +24,10 @@
|
||||
"lint": "oxlint",
|
||||
"fmt": "oxfmt",
|
||||
"fmt:check": "oxfmt --check",
|
||||
"precommit": "lint-staged"
|
||||
"precommit": "lint-staged",
|
||||
"test": "vitest run",
|
||||
"test:watch": "vitest",
|
||||
"test:coverage": "vitest run --coverage"
|
||||
},
|
||||
"dependencies": {
|
||||
"blurhash": "^2.0.5",
|
||||
@ -39,6 +42,7 @@
|
||||
"@types/http-link-header": "^1.0.7",
|
||||
"@types/node": "^25.3.0",
|
||||
"@types/semver": "^7.7.1",
|
||||
"@vitest/coverage-v8": "4.0.18",
|
||||
"oxfmt": "^0.35.0",
|
||||
"oxlint": "^1.50.0",
|
||||
"typedoc": "^0.28.17",
|
||||
@ -47,6 +51,7 @@
|
||||
"typescript": "^5.9.3",
|
||||
"vite": "^7.3.1",
|
||||
"vite-plugin-dts": "^4.5.4",
|
||||
"vitest": "^4.0.18",
|
||||
"ws": "^8.19.0"
|
||||
},
|
||||
"lint-staged": {
|
||||
|
||||
29
packages/pl-api/tests/utils/accounts.test.ts
Normal file
29
packages/pl-api/tests/utils/accounts.test.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { isDefaultAvatar, isDefaultHeader } from '@/utils/accounts';
|
||||
|
||||
describe('isDefaultHeader', () => {
|
||||
it('detects GoToSocial default header', () => {
|
||||
expect(isDefaultHeader('https://gts.mkljczk.pl/assets/default_header.webp')).toBe(true);
|
||||
});
|
||||
|
||||
it('detects NeoDB default headers', () => {
|
||||
expect(isDefaultHeader('https://neodb.social/static/img/missing.5fa23ea9f65e.png')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isDefaultAvatar', () => {
|
||||
it('detects GoToSocial default avatar', () => {
|
||||
expect(
|
||||
isDefaultAvatar('https://gts.mkljczk.pl/assets/default_avatars/GoToSocial_icon4.webp'),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('returns false for non-default avatar', () => {
|
||||
expect(
|
||||
isDefaultAvatar(
|
||||
'https://example.com/fileserver/01Z0G3Q7MWJ7DKMFYA2DDZ9T32/attachment/original/01KGZ1PKJF1JJ4GVKRBB2F2QME.jpegavatar.jpg',
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
@ -5,6 +5,9 @@
|
||||
"module": "ESNext",
|
||||
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||
"skipLibCheck": true,
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
},
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { fileURLToPath, URL } from 'node:url';
|
||||
import { resolve } from 'path';
|
||||
|
||||
import { defineConfig } from 'vite';
|
||||
@ -5,7 +6,7 @@ import dts from 'vite-plugin-dts';
|
||||
|
||||
import pkg from './package.json';
|
||||
|
||||
export default defineConfig({
|
||||
export default defineConfig(() => ({
|
||||
plugins: [dts({ include: ['lib'], insertTypesEntry: true })],
|
||||
build: {
|
||||
copyPublicDir: false,
|
||||
@ -21,7 +22,21 @@ export default defineConfig({
|
||||
external: Object.keys(pkg.dependencies),
|
||||
},
|
||||
},
|
||||
resolve: {
|
||||
alias: [
|
||||
{
|
||||
find: '@/',
|
||||
replacement: fileURLToPath(new URL('./lib/', import.meta.url)),
|
||||
},
|
||||
],
|
||||
},
|
||||
server: {
|
||||
port: Number(process.env.PORT ?? 7313),
|
||||
},
|
||||
});
|
||||
test: {
|
||||
globals: true,
|
||||
environment: 'jsdom',
|
||||
include: ['tests/**/*.test.{ts,tsx}'],
|
||||
css: false,
|
||||
},
|
||||
}));
|
||||
|
||||
6
pnpm-lock.yaml
generated
6
pnpm-lock.yaml
generated
@ -468,6 +468,9 @@ importers:
|
||||
'@types/semver':
|
||||
specifier: ^7.7.1
|
||||
version: 7.7.1
|
||||
'@vitest/coverage-v8':
|
||||
specifier: 4.0.18
|
||||
version: 4.0.18(vitest@4.0.18(@types/node@25.3.0)(jiti@1.21.7)(jsdom@28.1.0)(lightningcss@1.31.1)(sass-embedded@1.97.3)(sass@1.97.3)(terser@5.46.0)(yaml@2.8.2))
|
||||
oxfmt:
|
||||
specifier: ^0.35.0
|
||||
version: 0.35.0
|
||||
@ -492,6 +495,9 @@ importers:
|
||||
vite-plugin-dts:
|
||||
specifier: ^4.5.4
|
||||
version: 4.5.4(@types/node@25.3.0)(rollup@4.57.1)(typescript@5.9.3)(vite@7.3.1(@types/node@25.3.0)(jiti@1.21.7)(lightningcss@1.31.1)(sass-embedded@1.97.3)(sass@1.97.3)(terser@5.46.0)(yaml@2.8.2))
|
||||
vitest:
|
||||
specifier: ^4.0.18
|
||||
version: 4.0.18(@types/node@25.3.0)(jiti@1.21.7)(jsdom@28.1.0)(lightningcss@1.31.1)(sass-embedded@1.97.3)(sass@1.97.3)(terser@5.46.0)(yaml@2.8.2)
|
||||
ws:
|
||||
specifier: ^8.19.0
|
||||
version: 8.19.0
|
||||
|
||||
Reference in New Issue
Block a user