Skip to content

Commit

Permalink
mahathir/#3/clear-redundant-log-routes
Browse files Browse the repository at this point in the history
  • Loading branch information
mirmahathir1 committed Nov 30, 2023
1 parent 00e24cb commit a7f6c5c
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 155 deletions.
4 changes: 4 additions & 0 deletions config/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
SUPERADMIN_PASSWORD: 'badhandev',
SUPERADMIN_PHONE: '8801500000000',
}
71 changes: 71 additions & 0 deletions tests/logs/getLogs.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
const { badhanAxios } = require('../../api')
const validate = require('jsonschema').validate
const env = require('../../config/config')
const { processError } = require('../fixtures/helpers')
const logSchema={
type: "object",
additionalProperties: false,
properties: {
status: {type: "string"},
statusCode: {const: 200},
message: {type: "string"},
logs: {
type:"array",
minItems: 1,
items: {
type:"object",
additionalProperties: false,
properties: {
date: {type: "number"},
_id:{type:"string"},
name: {type: "string"},
hall: {type: "number"},
operation: {type:"string"}
},
required: ["date","_id","name","hall","operation"]
}
}
},
required: ["status", "statusCode", "message","logs"]
}

test('GET/log', async () => {
try {
let signInResponse = await badhanAxios.post('/users/signin', {
phone: env.SUPERADMIN_PHONE,
password: env.SUPERADMIN_PASSWORD
})

let getLogResponse = await badhanAxios.get('/log',{
headers:{
"x-auth":signInResponse.data.token
}
});


let getLogResponseValidationResult = validate(getLogResponse.data, logSchema);

expect(getLogResponseValidationResult.errors).toEqual([]);

await badhanAxios.delete('/users/signout', {
headers: {
'x-auth': signInResponse.data.token
}
})

} catch (e) {
throw processError(e)
}
})

test('GET/guest/log', async () => {
try {
let getLogsResponse = await badhanAxios.get('/guest/log');

let logsResponseValidationResult = validate(getLogsResponse.data, logSchema);

expect(logsResponseValidationResult.errors).toEqual([]);
} catch (e) {
throw processError(e)
}
})
155 changes: 0 additions & 155 deletions tests/logs/logByDateAndDonorId.test.js

This file was deleted.

0 comments on commit a7f6c5c

Please sign in to comment.