mirror of
https://github.com/logto-io/logto.git
synced 2025-02-03 21:48:55 -05:00
refactor(test): remove unnecessary expect.objectContaining (#1659)
This commit is contained in:
parent
7dfbc300b0
commit
379410e090
2 changed files with 109 additions and 137 deletions
|
@ -44,10 +44,10 @@ describe('GET /swagger.json', () => {
|
||||||
expect(response.body).toMatchObject({
|
expect(response.body).toMatchObject({
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||||
openapi: expect.any(String),
|
openapi: expect.any(String),
|
||||||
info: expect.objectContaining({
|
info: {
|
||||||
title: expect.any(String),
|
title: expect.any(String),
|
||||||
version: expect.any(String),
|
version: expect.any(String),
|
||||||
}),
|
},
|
||||||
paths: expect.any(Object),
|
paths: expect.any(Object),
|
||||||
/* eslint-enable @typescript-eslint/no-unsafe-assignment */
|
/* eslint-enable @typescript-eslint/no-unsafe-assignment */
|
||||||
});
|
});
|
||||||
|
@ -79,18 +79,14 @@ describe('GET /swagger.json', () => {
|
||||||
const swaggerRequest = createSwaggerRequest([testTagRouter]);
|
const swaggerRequest = createSwaggerRequest([testTagRouter]);
|
||||||
|
|
||||||
const response = await swaggerRequest.get('/swagger.json');
|
const response = await swaggerRequest.get('/swagger.json');
|
||||||
expect(response.body.paths).toMatchObject(
|
expect(response.body.paths).toMatchObject({
|
||||||
expect.objectContaining({
|
'/api/mock': {
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
get: { tags: ['Mock'] },
|
||||||
'/api/mock': expect.objectContaining({
|
},
|
||||||
get: expect.objectContaining({ tags: ['Mock'] }),
|
'/api/.well-known': {
|
||||||
}),
|
put: { tags: ['.well-known'] },
|
||||||
'/api/.well-known': expect.objectContaining({
|
},
|
||||||
put: expect.objectContaining({ tags: ['.well-known'] }),
|
});
|
||||||
}),
|
|
||||||
/* eslint-enable @typescript-eslint/no-unsafe-assignment */
|
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should parse the path parameters', async () => {
|
it('should parse the path parameters', async () => {
|
||||||
|
@ -108,11 +104,9 @@ describe('GET /swagger.json', () => {
|
||||||
const swaggerRequest = createSwaggerRequest([queryParametersRouter]);
|
const swaggerRequest = createSwaggerRequest([queryParametersRouter]);
|
||||||
|
|
||||||
const response = await swaggerRequest.get('/swagger.json');
|
const response = await swaggerRequest.get('/swagger.json');
|
||||||
expect(response.body.paths).toMatchObject(
|
expect(response.body.paths).toMatchObject({
|
||||||
expect.objectContaining({
|
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
||||||
'/api/mock/:id/:field': {
|
'/api/mock/:id/:field': {
|
||||||
get: expect.objectContaining({
|
get: {
|
||||||
parameters: [
|
parameters: [
|
||||||
{
|
{
|
||||||
name: 'id',
|
name: 'id',
|
||||||
|
@ -127,11 +121,9 @@ describe('GET /swagger.json', () => {
|
||||||
schema: { type: 'string' },
|
schema: { type: 'string' },
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
/* eslint-enable @typescript-eslint/no-unsafe-assignment */
|
},
|
||||||
})
|
});
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('parse query parameters', () => {
|
describe('parse query parameters', () => {
|
||||||
|
@ -149,11 +141,9 @@ describe('GET /swagger.json', () => {
|
||||||
);
|
);
|
||||||
const swaggerRequest = createSwaggerRequest([queryParametersRouter]);
|
const swaggerRequest = createSwaggerRequest([queryParametersRouter]);
|
||||||
const response = await swaggerRequest.get('/swagger.json');
|
const response = await swaggerRequest.get('/swagger.json');
|
||||||
expect(response.body.paths).toMatchObject(
|
expect(response.body.paths).toMatchObject({
|
||||||
expect.objectContaining({
|
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
||||||
'/api/mock': {
|
'/api/mock': {
|
||||||
get: expect.objectContaining({
|
get: {
|
||||||
parameters: [
|
parameters: [
|
||||||
{
|
{
|
||||||
name: 'id',
|
name: 'id',
|
||||||
|
@ -172,11 +162,9 @@ describe('GET /swagger.json', () => {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
/* eslint-enable @typescript-eslint/no-unsafe-assignment */
|
},
|
||||||
})
|
});
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should append page and page_size to the query parameters when the route uses pagination', async () => {
|
it('should append page and page_size to the query parameters when the route uses pagination', async () => {
|
||||||
|
@ -184,17 +172,13 @@ describe('GET /swagger.json', () => {
|
||||||
queryParametersRouter.get('/mock', koaPagination(), () => ({}));
|
queryParametersRouter.get('/mock', koaPagination(), () => ({}));
|
||||||
const swaggerRequest = createSwaggerRequest([queryParametersRouter]);
|
const swaggerRequest = createSwaggerRequest([queryParametersRouter]);
|
||||||
const response = await swaggerRequest.get('/swagger.json');
|
const response = await swaggerRequest.get('/swagger.json');
|
||||||
expect(response.body.paths).toMatchObject(
|
expect(response.body.paths).toMatchObject({
|
||||||
expect.objectContaining({
|
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
||||||
'/api/mock': {
|
'/api/mock': {
|
||||||
get: expect.objectContaining({
|
get: {
|
||||||
parameters: paginationParameters,
|
parameters: paginationParameters,
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
/* eslint-enable @typescript-eslint/no-unsafe-assignment */
|
},
|
||||||
})
|
});
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -211,11 +195,9 @@ describe('GET /swagger.json', () => {
|
||||||
);
|
);
|
||||||
const swaggerRequest = createSwaggerRequest([queryParametersRouter]);
|
const swaggerRequest = createSwaggerRequest([queryParametersRouter]);
|
||||||
const response = await swaggerRequest.get('/swagger.json');
|
const response = await swaggerRequest.get('/swagger.json');
|
||||||
expect(response.body.paths).toMatchObject(
|
expect(response.body.paths).toMatchObject({
|
||||||
expect.objectContaining({
|
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
||||||
'/api/mock': {
|
'/api/mock': {
|
||||||
post: expect.objectContaining({
|
post: {
|
||||||
requestBody: {
|
requestBody: {
|
||||||
required: true,
|
required: true,
|
||||||
content: {
|
content: {
|
||||||
|
@ -232,11 +214,9 @@ describe('GET /swagger.json', () => {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
/* eslint-enable @typescript-eslint/no-unsafe-assignment */
|
},
|
||||||
})
|
});
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('should use correct responses', () => {
|
describe('should use correct responses', () => {
|
||||||
|
@ -248,11 +228,9 @@ describe('GET /swagger.json', () => {
|
||||||
const swaggerRequest = createSwaggerRequest([mockRouter]);
|
const swaggerRequest = createSwaggerRequest([mockRouter]);
|
||||||
const response = await swaggerRequest.get('/swagger.json');
|
const response = await swaggerRequest.get('/swagger.json');
|
||||||
expect(response.body.paths).toMatchObject({
|
expect(response.body.paths).toMatchObject({
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
'/api/mock': {
|
||||||
'/api/mock': expect.objectContaining({
|
delete: { responses: defaultResponses },
|
||||||
delete: expect.objectContaining({ responses: defaultResponses }),
|
},
|
||||||
}),
|
|
||||||
/* eslint-enable @typescript-eslint/no-unsafe-assignment */
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -277,20 +255,18 @@ describe('GET /swagger.json', () => {
|
||||||
const swaggerRequest = createSwaggerRequest([mockRouter]);
|
const swaggerRequest = createSwaggerRequest([mockRouter]);
|
||||||
const response = await swaggerRequest.get('/swagger.json');
|
const response = await swaggerRequest.get('/swagger.json');
|
||||||
expect(response.body.paths).toMatchObject({
|
expect(response.body.paths).toMatchObject({
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
||||||
'/api/mock': {
|
'/api/mock': {
|
||||||
get: expect.objectContaining({
|
get: {
|
||||||
responses: {
|
responses: {
|
||||||
'204': { description: 'No Content' },
|
'204': { description: 'No Content' },
|
||||||
},
|
},
|
||||||
}),
|
},
|
||||||
patch: expect.objectContaining({
|
patch: {
|
||||||
responses: {
|
responses: {
|
||||||
'202': { description: 'Accepted' },
|
'202': { description: 'Accepted' },
|
||||||
},
|
},
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
/* eslint-enable @typescript-eslint/no-unsafe-assignment */
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -88,8 +88,7 @@ describe('GET /.well-known/sign-in-exp', () => {
|
||||||
const response = await sessionRequest.get('/.well-known/sign-in-exp');
|
const response = await sessionRequest.get('/.well-known/sign-in-exp');
|
||||||
expect(signInExperienceQuerySpyOn).toHaveBeenCalledTimes(1);
|
expect(signInExperienceQuerySpyOn).toHaveBeenCalledTimes(1);
|
||||||
expect(response.status).toEqual(200);
|
expect(response.status).toEqual(200);
|
||||||
expect(response.body).toMatchObject(
|
expect(response.body).toMatchObject({
|
||||||
expect.objectContaining({
|
|
||||||
...mockSignInExperience,
|
...mockSignInExperience,
|
||||||
socialConnectors: [
|
socialConnectors: [
|
||||||
{
|
{
|
||||||
|
@ -109,8 +108,7 @@ describe('GET /.well-known/sign-in-exp', () => {
|
||||||
id: mockWechatNativeConnectorInstance.connector.id,
|
id: mockWechatNativeConnectorInstance.connector.id,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
});
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return admin console settings', async () => {
|
it('should return admin console settings', async () => {
|
||||||
|
@ -119,8 +117,7 @@ describe('GET /.well-known/sign-in-exp', () => {
|
||||||
expect(signInExperienceQuerySpyOn).not.toBeCalled();
|
expect(signInExperienceQuerySpyOn).not.toBeCalled();
|
||||||
expect(response.status).toEqual(200);
|
expect(response.status).toEqual(200);
|
||||||
|
|
||||||
expect(response.body).toMatchObject(
|
expect(response.body).toMatchObject({
|
||||||
expect.objectContaining({
|
|
||||||
...adminConsoleSignInExperience,
|
...adminConsoleSignInExperience,
|
||||||
branding: {
|
branding: {
|
||||||
...adminConsoleSignInExperience.branding,
|
...adminConsoleSignInExperience.branding,
|
||||||
|
@ -128,7 +125,6 @@ describe('GET /.well-known/sign-in-exp', () => {
|
||||||
},
|
},
|
||||||
socialConnectors: [],
|
socialConnectors: [],
|
||||||
signInMode: SignInMode.SignIn,
|
signInMode: SignInMode.SignIn,
|
||||||
})
|
});
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue