add yargs bun and pm2
This commit is contained in:
parent
806cfa0ff6
commit
dbb090f93c
10
package.json
10
package.json
@ -53,12 +53,6 @@
|
|||||||
"yargs": "^18.0.0"
|
"yargs": "^18.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.27.4",
|
|
||||||
"@babel/plugin-proposal-decorators": "^7.27.1",
|
|
||||||
"@babel/plugin-transform-runtime": "^7.27.4",
|
|
||||||
"@babel/preset-env": "^7.27.2",
|
|
||||||
"@babel/preset-typescript": "^7.27.1",
|
|
||||||
"@babel/runtime": "^7.27.6",
|
|
||||||
"@eslint/compat": "^1.3.0",
|
"@eslint/compat": "^1.3.0",
|
||||||
"@eslint/eslintrc": "^3.3.1",
|
"@eslint/eslintrc": "^3.3.1",
|
||||||
"@eslint/js": "^9.29.0",
|
"@eslint/js": "^9.29.0",
|
||||||
@ -79,7 +73,6 @@
|
|||||||
"@types/yargs": "^17.0.33",
|
"@types/yargs": "^17.0.33",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.34.0",
|
"@typescript-eslint/eslint-plugin": "^8.34.0",
|
||||||
"@typescript-eslint/parser": "^8.34.0",
|
"@typescript-eslint/parser": "^8.34.0",
|
||||||
"babel-jest": "^30.0.0",
|
|
||||||
"bun-types": "^1.2.16",
|
"bun-types": "^1.2.16",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"eslint": "^9.29.0",
|
"eslint": "^9.29.0",
|
||||||
@ -95,7 +88,6 @@
|
|||||||
"prettier": "^3.5.3",
|
"prettier": "^3.5.3",
|
||||||
"source-map-support": "^0.5.21",
|
"source-map-support": "^0.5.21",
|
||||||
"supertest": "^7.1.1",
|
"supertest": "^7.1.1",
|
||||||
"ts-babel": "^6.1.7",
|
|
||||||
"ts-jest": "29.4.0",
|
"ts-jest": "29.4.0",
|
||||||
"ts-loader": "^9.5.2",
|
"ts-loader": "^9.5.2",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
@ -115,7 +107,7 @@
|
|||||||
"<rootDir>/test/**/*.test.ts"
|
"<rootDir>/test/**/*.test.ts"
|
||||||
],
|
],
|
||||||
"transform": {
|
"transform": {
|
||||||
"^.+\\.(js|jsx)$": "babel-jest",
|
"^.+\\.(js|jsx)$": "ts-jest",
|
||||||
"^.+\\.(ts|tsx)?$": "ts-jest"
|
"^.+\\.(ts|tsx)?$": "ts-jest"
|
||||||
},
|
},
|
||||||
"collectCoverageFrom": [
|
"collectCoverageFrom": [
|
||||||
|
1431
pnpm-lock.yaml
1431
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
@ -18,8 +18,6 @@ export async function start(
|
|||||||
config: CLIConfig,
|
config: CLIConfig,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
console.log('command start...');
|
console.log('command start...');
|
||||||
console.log(args);
|
|
||||||
console.log(config);
|
|
||||||
const script = args.typescript ? config.paths.ts : config.paths.js;
|
const script = args.typescript ? config.paths.ts : config.paths.js;
|
||||||
const params = [config.paths.bun, 'run'];
|
const params = [config.paths.bun, 'run'];
|
||||||
if (args.watch) {
|
if (args.watch) {
|
||||||
@ -66,6 +64,7 @@ export async function startPM2(
|
|||||||
args: Arguments<StartCommandArguments>,
|
args: Arguments<StartCommandArguments>,
|
||||||
config: CLIConfig,
|
config: CLIConfig,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
console.log('command startPM2...');
|
||||||
const { name } = await configure.get<AppConfig>('app');
|
const { name } = await configure.get<AppConfig>('app');
|
||||||
const script = args.typescript ? config.paths.ts : config.paths.js;
|
const script = args.typescript ? config.paths.ts : config.paths.js;
|
||||||
const pm2config = await getPm2Config(
|
const pm2config = await getPm2Config(
|
||||||
|
@ -61,10 +61,8 @@ export const createStartCommand: CommandItem<any, StartCommandArguments> = async
|
|||||||
},
|
},
|
||||||
handler: async (args: Arguments<StartCommandArguments>) => {
|
handler: async (args: Arguments<StartCommandArguments>) => {
|
||||||
console.log('createStartCommand handler start');
|
console.log('createStartCommand handler start');
|
||||||
console.log(app);
|
|
||||||
const { configure } = app;
|
const { configure } = app;
|
||||||
const config = getCLIConfig(args.tsConfig, args.nestConfig, args.entry);
|
const config = getCLIConfig(args.tsConfig, args.nestConfig, args.entry);
|
||||||
console.log(config);
|
|
||||||
if (args.prod || args.restart) {
|
if (args.prod || args.restart) {
|
||||||
await startPM2(configure, args, config);
|
await startPM2(configure, args, config);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Transform } from 'class-transformer';
|
import { Transform } from 'class-transformer';
|
||||||
import { Min, IsNumber, IsOptional } from 'class-validator';
|
import { IsNumber, IsOptional, Min } from 'class-validator';
|
||||||
import { toNumber } from 'lodash';
|
import { toNumber } from 'lodash';
|
||||||
|
|
||||||
import { DtoValidation } from '@/modules/core/decorator/dto.validation.decorator';
|
import { DtoValidation } from '@/modules/core/decorator/dto.validation.decorator';
|
||||||
@ -14,7 +14,7 @@ export class PaginateDto implements PaginateOptions {
|
|||||||
* 当前页
|
* 当前页
|
||||||
*/
|
*/
|
||||||
@Transform(({ value }) => toNumber(value))
|
@Transform(({ value }) => toNumber(value))
|
||||||
@Min(1, { message: '当前页必须大于1' })
|
@Min(1, { message: 'The current page must be greater than 1.' })
|
||||||
@IsNumber()
|
@IsNumber()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
page?: number = 1;
|
page?: number = 1;
|
||||||
@ -23,7 +23,7 @@ export class PaginateDto implements PaginateOptions {
|
|||||||
* 每页数据量
|
* 每页数据量
|
||||||
*/
|
*/
|
||||||
@Transform(({ value }) => toNumber(value))
|
@Transform(({ value }) => toNumber(value))
|
||||||
@Min(1, { message: '每页显示数据必须大于1' })
|
@Min(1, { message: 'The number of data displayed per page must be greater than 1.' })
|
||||||
@IsNumber()
|
@IsNumber()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
limit?: number = 10;
|
limit?: number = 10;
|
||||||
|
@ -21,6 +21,8 @@ import { createOptions } from '@/options';
|
|||||||
import { generateRandomNumber, generateUniqueRandomNumbers } from './generate-mock-data';
|
import { generateRandomNumber, generateUniqueRandomNumbers } from './generate-mock-data';
|
||||||
import { categoriesData, commentData, INIT_DATA, postData, tagData } from './test-data';
|
import { categoriesData, commentData, INIT_DATA, postData, tagData } from './test-data';
|
||||||
|
|
||||||
|
const URL_PREFIX = '/api/v1/content';
|
||||||
|
|
||||||
describe('nest app test', () => {
|
describe('nest app test', () => {
|
||||||
let datasource: DataSource;
|
let datasource: DataSource;
|
||||||
let app: NestFastifyApplication;
|
let app: NestFastifyApplication;
|
||||||
@ -79,7 +81,7 @@ describe('nest app test', () => {
|
|||||||
ids.map(async (id) => {
|
ids.map(async (id) => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: `/category/${id}`,
|
url: `${URL_PREFIX}/category/${id}`,
|
||||||
});
|
});
|
||||||
categories.push(result.json());
|
categories.push(result.json());
|
||||||
return result.json();
|
return result.json();
|
||||||
@ -119,7 +121,7 @@ describe('nest app test', () => {
|
|||||||
it('create category without name', async () => {
|
it('create category without name', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: {},
|
body: {},
|
||||||
});
|
});
|
||||||
expect(result.json()).toEqual({
|
expect(result.json()).toEqual({
|
||||||
@ -135,7 +137,7 @@ describe('nest app test', () => {
|
|||||||
it('create category with long name', async () => {
|
it('create category with long name', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: { name: 'A'.repeat(30) },
|
body: { name: 'A'.repeat(30) },
|
||||||
});
|
});
|
||||||
expect(result.json()).toEqual({
|
expect(result.json()).toEqual({
|
||||||
@ -149,7 +151,7 @@ describe('nest app test', () => {
|
|||||||
const rootCategory = categories.find((c) => !c.parent);
|
const rootCategory = categories.find((c) => !c.parent);
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: { name: rootCategory.name },
|
body: { name: rootCategory.name },
|
||||||
});
|
});
|
||||||
expect(result.json()).toEqual({
|
expect(result.json()).toEqual({
|
||||||
@ -163,7 +165,7 @@ describe('nest app test', () => {
|
|||||||
const testData = categories.find((item) => !isNil(item.parent));
|
const testData = categories.find((item) => !isNil(item.parent));
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: {
|
body: {
|
||||||
name: testData.name,
|
name: testData.name,
|
||||||
parent: testData.parent.id,
|
parent: testData.parent.id,
|
||||||
@ -179,7 +181,7 @@ describe('nest app test', () => {
|
|||||||
it('create category with invalid parent id format', async () => {
|
it('create category with invalid parent id format', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: {
|
body: {
|
||||||
name: 'New Category',
|
name: 'New Category',
|
||||||
parent: 'invalid-uuid',
|
parent: 'invalid-uuid',
|
||||||
@ -198,7 +200,7 @@ describe('nest app test', () => {
|
|||||||
it('create category with non-existent parent id', async () => {
|
it('create category with non-existent parent id', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: {
|
body: {
|
||||||
name: 'New Category',
|
name: 'New Category',
|
||||||
parent: '74e655b3-b69a-42ae-a101-41c224386e74',
|
parent: '74e655b3-b69a-42ae-a101-41c224386e74',
|
||||||
@ -214,7 +216,7 @@ describe('nest app test', () => {
|
|||||||
it('create category with negative custom order', async () => {
|
it('create category with negative custom order', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: {
|
body: {
|
||||||
name: 'New Category',
|
name: 'New Category',
|
||||||
customOrder: -1,
|
customOrder: -1,
|
||||||
@ -230,7 +232,7 @@ describe('nest app test', () => {
|
|||||||
it('create category with empty name', async () => {
|
it('create category with empty name', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: { name: '' },
|
body: { name: '' },
|
||||||
});
|
});
|
||||||
expect(result.json()).toEqual({
|
expect(result.json()).toEqual({
|
||||||
@ -243,7 +245,7 @@ describe('nest app test', () => {
|
|||||||
it('create category with whitespace name', async () => {
|
it('create category with whitespace name', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: { name: ' ' },
|
body: { name: ' ' },
|
||||||
});
|
});
|
||||||
expect(result.json()).toEqual({
|
expect(result.json()).toEqual({
|
||||||
@ -257,7 +259,7 @@ describe('nest app test', () => {
|
|||||||
const name = 'A'.repeat(25);
|
const name = 'A'.repeat(25);
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: { name },
|
body: { name },
|
||||||
});
|
});
|
||||||
expect(result.statusCode).toEqual(201);
|
expect(result.statusCode).toEqual(201);
|
||||||
@ -265,14 +267,14 @@ describe('nest app test', () => {
|
|||||||
expect(category.name).toBe(name);
|
expect(category.name).toBe(name);
|
||||||
await app.inject({
|
await app.inject({
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
url: `/category/${result.json().id}`,
|
url: `${URL_PREFIX}/category/${result.json().id}`,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('create category with name one char over limit (26 chars)', async () => {
|
it('create category with name one char over limit (26 chars)', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: { name: 'A'.repeat(26) },
|
body: { name: 'A'.repeat(26) },
|
||||||
});
|
});
|
||||||
expect(result.json()).toEqual({
|
expect(result.json()).toEqual({
|
||||||
@ -286,7 +288,7 @@ describe('nest app test', () => {
|
|||||||
const rootCategory = categories.find((c) => !c.parent);
|
const rootCategory = categories.find((c) => !c.parent);
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: { name: rootCategory.name },
|
body: { name: rootCategory.name },
|
||||||
});
|
});
|
||||||
expect(result.json()).toEqual({
|
expect(result.json()).toEqual({
|
||||||
@ -302,7 +304,7 @@ describe('nest app test', () => {
|
|||||||
|
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: {
|
body: {
|
||||||
name: existingChild.name,
|
name: existingChild.name,
|
||||||
parent: parentCategory.id,
|
parent: parentCategory.id,
|
||||||
@ -322,7 +324,7 @@ describe('nest app test', () => {
|
|||||||
|
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: {
|
body: {
|
||||||
name: childName,
|
name: childName,
|
||||||
parent: parent2.id,
|
parent: parent2.id,
|
||||||
@ -331,14 +333,14 @@ describe('nest app test', () => {
|
|||||||
expect(result.statusCode).toEqual(201);
|
expect(result.statusCode).toEqual(201);
|
||||||
await app.inject({
|
await app.inject({
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
url: `/category/${result.json().id}`,
|
url: `${URL_PREFIX}/category/${result.json().id}`,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('create category with parent set to null string', async () => {
|
it('create category with parent set to null string', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: {
|
body: {
|
||||||
name: 'Root Category',
|
name: 'Root Category',
|
||||||
parent: 'null', // 注意:这里传递字符串 'null'
|
parent: 'null', // 注意:这里传递字符串 'null'
|
||||||
@ -349,14 +351,14 @@ describe('nest app test', () => {
|
|||||||
expect(category.parent).toBeNull();
|
expect(category.parent).toBeNull();
|
||||||
await app.inject({
|
await app.inject({
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
url: `/category/${result.json().id}`,
|
url: `${URL_PREFIX}/category/${result.json().id}`,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('create category with parent set to null value', async () => {
|
it('create category with parent set to null value', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: {
|
body: {
|
||||||
name: 'Root Category',
|
name: 'Root Category',
|
||||||
parent: null,
|
parent: null,
|
||||||
@ -367,14 +369,14 @@ describe('nest app test', () => {
|
|||||||
expect(category.parent).toBeNull();
|
expect(category.parent).toBeNull();
|
||||||
await app.inject({
|
await app.inject({
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
url: `/category/${result.json().id}`,
|
url: `${URL_PREFIX}/category/${result.json().id}`,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('create category with empty parent id', async () => {
|
it('create category with empty parent id', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: {
|
body: {
|
||||||
name: 'New Category',
|
name: 'New Category',
|
||||||
parent: '',
|
parent: '',
|
||||||
@ -393,7 +395,7 @@ describe('nest app test', () => {
|
|||||||
it('create category with malformed UUID parent id', async () => {
|
it('create category with malformed UUID parent id', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: {
|
body: {
|
||||||
name: 'New Category',
|
name: 'New Category',
|
||||||
parent: 'not-a-valid-uuid-123',
|
parent: 'not-a-valid-uuid-123',
|
||||||
@ -412,7 +414,7 @@ describe('nest app test', () => {
|
|||||||
it('create category with customOrder as string', async () => {
|
it('create category with customOrder as string', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: {
|
body: {
|
||||||
name: 'New Category',
|
name: 'New Category',
|
||||||
customOrder: '10', // 字符串形式的数字
|
customOrder: '10', // 字符串形式的数字
|
||||||
@ -423,14 +425,14 @@ describe('nest app test', () => {
|
|||||||
expect(category.customOrder).toBe(10);
|
expect(category.customOrder).toBe(10);
|
||||||
await app.inject({
|
await app.inject({
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
url: `/category/${result.json().id}`,
|
url: `${URL_PREFIX}/category/${result.json().id}`,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('create category with customOrder as float', async () => {
|
it('create category with customOrder as float', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: {
|
body: {
|
||||||
name: 'New Category',
|
name: 'New Category',
|
||||||
customOrder: 5.5,
|
customOrder: 5.5,
|
||||||
@ -446,7 +448,7 @@ describe('nest app test', () => {
|
|||||||
it('create category with customOrder as negative number', async () => {
|
it('create category with customOrder as negative number', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: {
|
body: {
|
||||||
name: 'New Category',
|
name: 'New Category',
|
||||||
customOrder: -1,
|
customOrder: -1,
|
||||||
@ -462,7 +464,7 @@ describe('nest app test', () => {
|
|||||||
it('create category with customOrder as zero', async () => {
|
it('create category with customOrder as zero', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: {
|
body: {
|
||||||
name: 'New Category',
|
name: 'New Category',
|
||||||
customOrder: 0,
|
customOrder: 0,
|
||||||
@ -473,14 +475,14 @@ describe('nest app test', () => {
|
|||||||
expect(category.customOrder).toBe(0);
|
expect(category.customOrder).toBe(0);
|
||||||
await app.inject({
|
await app.inject({
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
url: `/category/${result.json().id}`,
|
url: `${URL_PREFIX}/category/${result.json().id}`,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('create category with customOrder as large number', async () => {
|
it('create category with customOrder as large number', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: {
|
body: {
|
||||||
name: 'New Category',
|
name: 'New Category',
|
||||||
customOrder: 999999,
|
customOrder: 999999,
|
||||||
@ -489,7 +491,7 @@ describe('nest app test', () => {
|
|||||||
expect(result.statusCode).toEqual(201);
|
expect(result.statusCode).toEqual(201);
|
||||||
await app.inject({
|
await app.inject({
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
url: `/category/${result.json().id}`,
|
url: `${URL_PREFIX}/category/${result.json().id}`,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -497,7 +499,7 @@ describe('nest app test', () => {
|
|||||||
const parent = categories.find((c) => !c.parent);
|
const parent = categories.find((c) => !c.parent);
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: {
|
body: {
|
||||||
name: 'Valid New Category',
|
name: 'Valid New Category',
|
||||||
parent: parent.id,
|
parent: parent.id,
|
||||||
@ -511,7 +513,7 @@ describe('nest app test', () => {
|
|||||||
expect(category.customOrder).toBe(5);
|
expect(category.customOrder).toBe(5);
|
||||||
await app.inject({
|
await app.inject({
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
url: `/category/${result.json().id}`,
|
url: `${URL_PREFIX}/category/${result.json().id}`,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -520,7 +522,7 @@ describe('nest app test', () => {
|
|||||||
const category = categories[0];
|
const category = categories[0];
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: {
|
body: {
|
||||||
name: 'Invalid Category',
|
name: 'Invalid Category',
|
||||||
parent: category.id,
|
parent: category.id,
|
||||||
@ -535,7 +537,7 @@ describe('nest app test', () => {
|
|||||||
it('update category without id', async () => {
|
it('update category without id', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: { name: 'Updated Category' },
|
body: { name: 'Updated Category' },
|
||||||
});
|
});
|
||||||
expect(result.json()).toEqual({
|
expect(result.json()).toEqual({
|
||||||
@ -552,7 +554,7 @@ describe('nest app test', () => {
|
|||||||
it('update category with invalid id format', async () => {
|
it('update category with invalid id format', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: {
|
body: {
|
||||||
id: 'invalid-uuid',
|
id: 'invalid-uuid',
|
||||||
name: 'Updated Category',
|
name: 'Updated Category',
|
||||||
@ -572,7 +574,7 @@ describe('nest app test', () => {
|
|||||||
it('update category with non-existent id', async () => {
|
it('update category with non-existent id', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: {
|
body: {
|
||||||
id: '74e655b3-b69a-42ae-a101-41c224386e74',
|
id: '74e655b3-b69a-42ae-a101-41c224386e74',
|
||||||
name: 'Updated Category',
|
name: 'Updated Category',
|
||||||
@ -585,7 +587,7 @@ describe('nest app test', () => {
|
|||||||
const category = categories[0];
|
const category = categories[0];
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: {
|
body: {
|
||||||
id: category.id,
|
id: category.id,
|
||||||
name: 'A'.repeat(30),
|
name: 'A'.repeat(30),
|
||||||
@ -604,7 +606,7 @@ describe('nest app test', () => {
|
|||||||
|
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: {
|
body: {
|
||||||
id: child1.id,
|
id: child1.id,
|
||||||
name: child2.name,
|
name: child2.name,
|
||||||
@ -621,7 +623,7 @@ describe('nest app test', () => {
|
|||||||
const category = categories[0];
|
const category = categories[0];
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: {
|
body: {
|
||||||
id: category.id,
|
id: category.id,
|
||||||
parent: 'invalid-uuid',
|
parent: 'invalid-uuid',
|
||||||
@ -641,7 +643,7 @@ describe('nest app test', () => {
|
|||||||
const category = categories[0];
|
const category = categories[0];
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: {
|
body: {
|
||||||
id: category.id,
|
id: category.id,
|
||||||
parent: '74e655b3-b69a-42ae-a101-41c224386e74',
|
parent: '74e655b3-b69a-42ae-a101-41c224386e74',
|
||||||
@ -658,7 +660,7 @@ describe('nest app test', () => {
|
|||||||
const category = categories[0];
|
const category = categories[0];
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: {
|
body: {
|
||||||
id: category.id,
|
id: category.id,
|
||||||
customOrder: -1,
|
customOrder: -1,
|
||||||
@ -675,7 +677,7 @@ describe('nest app test', () => {
|
|||||||
it('query categories with invalid page', async () => {
|
it('query categories with invalid page', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: '/category?page=0',
|
url: `${URL_PREFIX}/category?page=0`,
|
||||||
});
|
});
|
||||||
expect(result.json()).toEqual({
|
expect(result.json()).toEqual({
|
||||||
message: ['The current page must be greater than 1.'],
|
message: ['The current page must be greater than 1.'],
|
||||||
@ -687,7 +689,7 @@ describe('nest app test', () => {
|
|||||||
it('query categories with invalid limit', async () => {
|
it('query categories with invalid limit', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: '/category?limit=0',
|
url: `${URL_PREFIX}/category?limit=0`,
|
||||||
});
|
});
|
||||||
expect(result.json()).toEqual({
|
expect(result.json()).toEqual({
|
||||||
message: ['The number of data displayed per page must be greater than 1.'],
|
message: ['The number of data displayed per page must be greater than 1.'],
|
||||||
@ -707,7 +709,7 @@ describe('nest app test', () => {
|
|||||||
it('create tag without name', async () => {
|
it('create tag without name', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/tag',
|
url: `${URL_PREFIX}/tag`,
|
||||||
body: {},
|
body: {},
|
||||||
});
|
});
|
||||||
expect(result.json()).toEqual({
|
expect(result.json()).toEqual({
|
||||||
@ -724,7 +726,7 @@ describe('nest app test', () => {
|
|||||||
it('create tag with long name', async () => {
|
it('create tag with long name', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/tag',
|
url: `${URL_PREFIX}/tag`,
|
||||||
body: { name: 'A'.repeat(256) },
|
body: { name: 'A'.repeat(256) },
|
||||||
});
|
});
|
||||||
expect(result.json()).toEqual({
|
expect(result.json()).toEqual({
|
||||||
@ -738,7 +740,7 @@ describe('nest app test', () => {
|
|||||||
const existingTag = tags[0];
|
const existingTag = tags[0];
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/tag',
|
url: `${URL_PREFIX}/tag`,
|
||||||
body: { name: existingTag.name },
|
body: { name: existingTag.name },
|
||||||
});
|
});
|
||||||
expect(result.json()).toEqual({
|
expect(result.json()).toEqual({
|
||||||
@ -751,7 +753,7 @@ describe('nest app test', () => {
|
|||||||
it('create tag with long description', async () => {
|
it('create tag with long description', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/tag',
|
url: `${URL_PREFIX}/tag`,
|
||||||
body: {
|
body: {
|
||||||
name: 'NewTag',
|
name: 'NewTag',
|
||||||
desc: 'A'.repeat(501),
|
desc: 'A'.repeat(501),
|
||||||
@ -768,7 +770,7 @@ describe('nest app test', () => {
|
|||||||
it('update tag without id', async () => {
|
it('update tag without id', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
url: '/tag',
|
url: `${URL_PREFIX}/tag`,
|
||||||
body: { name: 'Updated Tag' },
|
body: { name: 'Updated Tag' },
|
||||||
});
|
});
|
||||||
expect(result.json()).toEqual({
|
expect(result.json()).toEqual({
|
||||||
@ -785,7 +787,7 @@ describe('nest app test', () => {
|
|||||||
it('update tag with invalid id format', async () => {
|
it('update tag with invalid id format', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
url: '/tag',
|
url: `${URL_PREFIX}/tag`,
|
||||||
body: {
|
body: {
|
||||||
id: 'invalid-uuid',
|
id: 'invalid-uuid',
|
||||||
name: 'Updated Tag',
|
name: 'Updated Tag',
|
||||||
@ -801,7 +803,7 @@ describe('nest app test', () => {
|
|||||||
it('update tag with non-existent id', async () => {
|
it('update tag with non-existent id', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
url: '/tag',
|
url: `${URL_PREFIX}/tag`,
|
||||||
body: {
|
body: {
|
||||||
id: '74e655b3-b69a-42ae-a101-41c224386e74',
|
id: '74e655b3-b69a-42ae-a101-41c224386e74',
|
||||||
name: 'Updated Tag',
|
name: 'Updated Tag',
|
||||||
@ -818,7 +820,7 @@ describe('nest app test', () => {
|
|||||||
const tag = tags[0];
|
const tag = tags[0];
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
url: '/tag',
|
url: `${URL_PREFIX}/tag`,
|
||||||
body: {
|
body: {
|
||||||
id: tag.id,
|
id: tag.id,
|
||||||
name: 'A'.repeat(256),
|
name: 'A'.repeat(256),
|
||||||
@ -835,7 +837,7 @@ describe('nest app test', () => {
|
|||||||
const [tag1, tag2] = tags;
|
const [tag1, tag2] = tags;
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
url: '/tag',
|
url: `${URL_PREFIX}/tag`,
|
||||||
body: {
|
body: {
|
||||||
id: tag1.id,
|
id: tag1.id,
|
||||||
name: tag2.name,
|
name: tag2.name,
|
||||||
@ -852,7 +854,7 @@ describe('nest app test', () => {
|
|||||||
const tag = tags[0];
|
const tag = tags[0];
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
url: '/tag',
|
url: `${URL_PREFIX}/tag`,
|
||||||
body: {
|
body: {
|
||||||
id: tag.id,
|
id: tag.id,
|
||||||
desc: 'A'.repeat(501),
|
desc: 'A'.repeat(501),
|
||||||
@ -878,7 +880,7 @@ describe('nest app test', () => {
|
|||||||
it('create post without title', async () => {
|
it('create post without title', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/posts',
|
url: `${URL_PREFIX}/posts`,
|
||||||
body: { body: 'Post content' },
|
body: { body: 'Post content' },
|
||||||
});
|
});
|
||||||
expect(result.json()).toEqual({
|
expect(result.json()).toEqual({
|
||||||
@ -894,7 +896,7 @@ describe('nest app test', () => {
|
|||||||
it('create post without body', async () => {
|
it('create post without body', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/posts',
|
url: `${URL_PREFIX}/posts`,
|
||||||
body: { title: 'New Post' },
|
body: { title: 'New Post' },
|
||||||
});
|
});
|
||||||
expect(result.json()).toEqual({
|
expect(result.json()).toEqual({
|
||||||
@ -907,7 +909,7 @@ describe('nest app test', () => {
|
|||||||
it('create post with long title', async () => {
|
it('create post with long title', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/posts',
|
url: `${URL_PREFIX}/posts`,
|
||||||
body: {
|
body: {
|
||||||
title: 'A'.repeat(256),
|
title: 'A'.repeat(256),
|
||||||
body: 'Post content',
|
body: 'Post content',
|
||||||
@ -923,7 +925,7 @@ describe('nest app test', () => {
|
|||||||
it('create post with long summary', async () => {
|
it('create post with long summary', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/posts',
|
url: `${URL_PREFIX}/posts`,
|
||||||
body: {
|
body: {
|
||||||
title: 'New Post',
|
title: 'New Post',
|
||||||
body: 'Content',
|
body: 'Content',
|
||||||
@ -940,7 +942,7 @@ describe('nest app test', () => {
|
|||||||
it('create post with invalid category', async () => {
|
it('create post with invalid category', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/posts',
|
url: `${URL_PREFIX}/posts`,
|
||||||
body: {
|
body: {
|
||||||
title: 'New Post',
|
title: 'New Post',
|
||||||
body: 'Content',
|
body: 'Content',
|
||||||
@ -957,7 +959,7 @@ describe('nest app test', () => {
|
|||||||
it('create post with non-existent category', async () => {
|
it('create post with non-existent category', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/posts',
|
url: `${URL_PREFIX}/posts`,
|
||||||
body: {
|
body: {
|
||||||
title: 'New Post',
|
title: 'New Post',
|
||||||
body: 'Content',
|
body: 'Content',
|
||||||
@ -974,7 +976,7 @@ describe('nest app test', () => {
|
|||||||
it('create post with invalid tag format', async () => {
|
it('create post with invalid tag format', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/posts',
|
url: `${URL_PREFIX}/posts`,
|
||||||
body: {
|
body: {
|
||||||
title: 'New Post',
|
title: 'New Post',
|
||||||
body: 'Content',
|
body: 'Content',
|
||||||
@ -991,7 +993,7 @@ describe('nest app test', () => {
|
|||||||
it('create post with non-existent tag', async () => {
|
it('create post with non-existent tag', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/posts',
|
url: `${URL_PREFIX}/posts`,
|
||||||
body: {
|
body: {
|
||||||
title: 'New Post',
|
title: 'New Post',
|
||||||
body: 'Content',
|
body: 'Content',
|
||||||
@ -1008,7 +1010,7 @@ describe('nest app test', () => {
|
|||||||
it('create post with long keyword', async () => {
|
it('create post with long keyword', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/posts',
|
url: `${URL_PREFIX}/posts`,
|
||||||
body: {
|
body: {
|
||||||
title: 'New Post',
|
title: 'New Post',
|
||||||
body: 'Content',
|
body: 'Content',
|
||||||
@ -1025,7 +1027,7 @@ describe('nest app test', () => {
|
|||||||
it('create post with negative custom order', async () => {
|
it('create post with negative custom order', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/posts',
|
url: `${URL_PREFIX}/posts`,
|
||||||
body: {
|
body: {
|
||||||
title: 'New Post',
|
title: 'New Post',
|
||||||
body: 'Content',
|
body: 'Content',
|
||||||
@ -1043,7 +1045,7 @@ describe('nest app test', () => {
|
|||||||
it('update post without id', async () => {
|
it('update post without id', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
url: '/posts',
|
url: `${URL_PREFIX}/posts`,
|
||||||
body: { title: 'Updated Post' },
|
body: { title: 'Updated Post' },
|
||||||
});
|
});
|
||||||
expect(result.json()).toEqual({
|
expect(result.json()).toEqual({
|
||||||
@ -1059,7 +1061,7 @@ describe('nest app test', () => {
|
|||||||
it('update post with invalid id format', async () => {
|
it('update post with invalid id format', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
url: '/posts',
|
url: `${URL_PREFIX}/posts`,
|
||||||
body: {
|
body: {
|
||||||
id: 'invalid-uuid',
|
id: 'invalid-uuid',
|
||||||
title: 'Updated Post',
|
title: 'Updated Post',
|
||||||
@ -1078,7 +1080,7 @@ describe('nest app test', () => {
|
|||||||
it('update post with non-existent id', async () => {
|
it('update post with non-existent id', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
url: '/posts',
|
url: `${URL_PREFIX}/posts`,
|
||||||
body: {
|
body: {
|
||||||
id: '74e655b3-b69a-42ae-a101-41c224386e74',
|
id: '74e655b3-b69a-42ae-a101-41c224386e74',
|
||||||
title: 'Updated Post non-existent id',
|
title: 'Updated Post non-existent id',
|
||||||
@ -1095,7 +1097,7 @@ describe('nest app test', () => {
|
|||||||
const post = posts[0];
|
const post = posts[0];
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
url: '/posts',
|
url: `${URL_PREFIX}/posts`,
|
||||||
body: {
|
body: {
|
||||||
id: post.id,
|
id: post.id,
|
||||||
title: 'A'.repeat(256),
|
title: 'A'.repeat(256),
|
||||||
@ -1122,7 +1124,7 @@ describe('nest app test', () => {
|
|||||||
const post = posts[0];
|
const post = posts[0];
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/comment',
|
url: `${URL_PREFIX}/comment`,
|
||||||
body: { post: post.id },
|
body: { post: post.id },
|
||||||
});
|
});
|
||||||
expect(result.json()).toEqual({
|
expect(result.json()).toEqual({
|
||||||
@ -1138,7 +1140,7 @@ describe('nest app test', () => {
|
|||||||
it('create comment without post', async () => {
|
it('create comment without post', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/comment',
|
url: `${URL_PREFIX}/comment`,
|
||||||
body: { body: 'Test comment' },
|
body: { body: 'Test comment' },
|
||||||
});
|
});
|
||||||
expect(result.json()).toEqual({
|
expect(result.json()).toEqual({
|
||||||
@ -1152,7 +1154,7 @@ describe('nest app test', () => {
|
|||||||
const post = posts[0];
|
const post = posts[0];
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/comment',
|
url: `${URL_PREFIX}/comment`,
|
||||||
body: {
|
body: {
|
||||||
body: 'A'.repeat(1001),
|
body: 'A'.repeat(1001),
|
||||||
post: post.id,
|
post: post.id,
|
||||||
@ -1168,7 +1170,7 @@ describe('nest app test', () => {
|
|||||||
it('create comment with invalid post format', async () => {
|
it('create comment with invalid post format', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/comment',
|
url: `${URL_PREFIX}/comment`,
|
||||||
body: {
|
body: {
|
||||||
body: 'Test comment',
|
body: 'Test comment',
|
||||||
post: 'invalid-uuid',
|
post: 'invalid-uuid',
|
||||||
@ -1184,7 +1186,7 @@ describe('nest app test', () => {
|
|||||||
it('create comment with non-existent post', async () => {
|
it('create comment with non-existent post', async () => {
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/comment',
|
url: `${URL_PREFIX}/comment`,
|
||||||
body: {
|
body: {
|
||||||
body: 'Test comment',
|
body: 'Test comment',
|
||||||
post: '74e655b3-b69a-42ae-a101-41c224386e74',
|
post: '74e655b3-b69a-42ae-a101-41c224386e74',
|
||||||
@ -1201,7 +1203,7 @@ describe('nest app test', () => {
|
|||||||
const post = posts[0];
|
const post = posts[0];
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/comment',
|
url: `${URL_PREFIX}/comment`,
|
||||||
body: {
|
body: {
|
||||||
body: 'Test comment',
|
body: 'Test comment',
|
||||||
post: post.id,
|
post: post.id,
|
||||||
@ -1219,7 +1221,7 @@ describe('nest app test', () => {
|
|||||||
const post = posts[0];
|
const post = posts[0];
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/comment',
|
url: `${URL_PREFIX}/comment`,
|
||||||
body: {
|
body: {
|
||||||
body: 'Test comment',
|
body: 'Test comment',
|
||||||
post: post.id,
|
post: post.id,
|
||||||
@ -1251,7 +1253,7 @@ async function addCategory(
|
|||||||
const item = data[index];
|
const item = data[index];
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/category',
|
url: `${URL_PREFIX}/category`,
|
||||||
body: { ...pick(item, ['name', 'customOrder']), parent: parentId },
|
body: { ...pick(item, ['name', 'customOrder']), parent: parentId },
|
||||||
});
|
});
|
||||||
const addedItem: CategoryEntity = result.json();
|
const addedItem: CategoryEntity = result.json();
|
||||||
@ -1269,7 +1271,7 @@ async function addTag(app: NestFastifyApplication, data: RecordAny[]): Promise<T
|
|||||||
const item = data[index];
|
const item = data[index];
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/tag',
|
url: `${URL_PREFIX}/tag`,
|
||||||
body: item,
|
body: item,
|
||||||
});
|
});
|
||||||
const addedItem: TagEntity = result.json();
|
const addedItem: TagEntity = result.json();
|
||||||
@ -1293,7 +1295,7 @@ async function addPost(
|
|||||||
item.tags = generateUniqueRandomNumbers(0, tags.length - 1, 3).map((idx) => tags[idx]);
|
item.tags = generateUniqueRandomNumbers(0, tags.length - 1, 3).map((idx) => tags[idx]);
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/posts',
|
url: `${URL_PREFIX}/posts`,
|
||||||
body: item,
|
body: item,
|
||||||
});
|
});
|
||||||
const addedItem: PostEntity = result.json();
|
const addedItem: PostEntity = result.json();
|
||||||
@ -1323,7 +1325,7 @@ async function addComment(
|
|||||||
: undefined;
|
: undefined;
|
||||||
const result = await app.inject({
|
const result = await app.inject({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/comment',
|
url: `${URL_PREFIX}/comment`,
|
||||||
body: item,
|
body: item,
|
||||||
});
|
});
|
||||||
const addedItem = result.json();
|
const addedItem = result.json();
|
||||||
|
Loading…
Reference in New Issue
Block a user