我想用几个不同的输入执行POST调用。 因此,每次我提供网址以创建带有名称(id)的日记时, **检查响应状态是否为201 **检查reposne.body.id是否为请求创建的日记ID **检查response.body.type是否为请求创建的日记类型。
test.only('Getting a list of requested type of journals', async () => {
const commonUrl = '/1/tenant/1/administration/99998/journal';
for (const jornalName of [
{ value: 'VRK3' },
{ value: 'INK3' },
{ value: 'CASH' },
{ value: 'MEM1' },
{ value: 'BNK1' },
]) {
const response = await utils.performRequest(
request
.put(utils.api(commonUrl + jornalName.value))
.set(authHeader)
.send([
{
description: 'test',
type: 'sales',
ledger_account_id: 60,
},
{
description: 'test',
type: 'purchase',
ledger_account_id: 120,
},
{
description: 'test',
type: 'cash',
ledger_account_id: 830,
},
{
description: 'test',
type: 'general',
ledger_account_id: 170,
},
{
description: 'test',
type: 'bank',
ledger_account_id: 625,
},
]),
);
if (expect(response.status).toEqual(201)) {
console.log(
`Journal ${jornalName.value} created with automatic range assignment`,
);
}
expect(response.body.id).toBe(`${jornalName.value}`);
expect(response.body.type).toBe([
'sales',
'purchase',
'cash',
'general',
'bank',
]);
}
});