From 61b28b37dbb5181d12689c9943a7de42831f4915 Mon Sep 17 00:00:00 2001 From: Junyi Date: Thu, 5 May 2022 11:59:13 +0800 Subject: [PATCH] fix(plugin-workflow): fix tests (#360) --- .../__tests__/instructions/condition.test.ts | 110 +++++++++--------- 1 file changed, 53 insertions(+), 57 deletions(-) diff --git a/packages/plugins/workflow/src/__tests__/instructions/condition.test.ts b/packages/plugins/workflow/src/__tests__/instructions/condition.test.ts index 98a7e1df7..5de88597d 100644 --- a/packages/plugins/workflow/src/__tests__/instructions/condition.test.ts +++ b/packages/plugins/workflow/src/__tests__/instructions/condition.test.ts @@ -119,7 +119,7 @@ describe('workflow > instructions > condition', () => { describe('group calculation', () => { it('and true', async () => { - const n1 = workflow.createNode({ + const n1 = await workflow.createNode({ type: 'condition', config: { calculation: { @@ -148,38 +148,36 @@ describe('workflow > instructions > condition', () => { }); it('and false', async () => { - await db.sequelize.transaction(async transaction => { - const n1 = workflow.createNode({ - type: 'condition', - config: { - calculation: { - group: { - type: 'and', - calculations: [ - { - calculator: 'equal', - operands: [{ value: 1 }, { value: 1 }] - }, - { - calculator: 'equal', - operands: [{ value: 0 }, { value: 1 }] - } - ] - } + const n1 = await workflow.createNode({ + type: 'condition', + config: { + calculation: { + group: { + type: 'and', + calculations: [ + { + calculator: 'equal', + operands: [{ value: 1 }, { value: 1 }] + }, + { + calculator: 'equal', + operands: [{ value: 0 }, { value: 1 }] + } + ] } } - }, { transaction }); - - const post = await PostModel.create({ title: 't1' }, { transaction }); - - const [execution] = await workflow.getExecutions({ transaction }); - const [job] = await execution.getJobs({ transaction }); - expect(job.result).toBe(false); + } }); + + const post = await PostModel.create({ title: 't1' }); + + const [execution] = await workflow.getExecutions(); + const [job] = await execution.getJobs(); + expect(job.result).toBe(false); }); it('or true', async () => { - const n1 = workflow.createNode({ + const n1 = await workflow.createNode({ type: 'condition', config: { calculation: { @@ -208,7 +206,7 @@ describe('workflow > instructions > condition', () => { }); it('or false', async () => { - const n1 = workflow.createNode({ + const n1 = await workflow.createNode({ type: 'condition', config: { calculation: { @@ -237,39 +235,37 @@ describe('workflow > instructions > condition', () => { }); it('nested', async () => { - await db.sequelize.transaction(async transaction => { - const n1 = workflow.createNode({ - type: 'condition', - config: { - calculation: { - group: { - type: 'and', - calculations: [ - { - calculator: 'equal', - operands: [{ value: 1 }, { value: 1 }] - }, - { - group: { - type: 'or', - calculations: [ - { calculator: 'equal', operands: [{ value: 0 }, { value: 1 }] }, - { calculator: 'equal', operands: [{ value: 0 }, { value: 1 }] } - ] - } + const n1 = await workflow.createNode({ + type: 'condition', + config: { + calculation: { + group: { + type: 'and', + calculations: [ + { + calculator: 'equal', + operands: [{ value: 1 }, { value: 1 }] + }, + { + group: { + type: 'or', + calculations: [ + { calculator: 'equal', operands: [{ value: 0 }, { value: 1 }] }, + { calculator: 'equal', operands: [{ value: 0 }, { value: 1 }] } + ] } - ] - } + } + ] } } - }, { transaction }); - - const post = await PostModel.create({ title: 't1' }, { transaction }); - - const [execution] = await workflow.getExecutions({ transaction }); - const [job] = await execution.getJobs({ transaction }); - expect(job.result).toBe(false); + } }); + + const post = await PostModel.create({ title: 't1' }); + + const [execution] = await workflow.getExecutions(); + const [job] = await execution.getJobs(); + expect(job.result).toBe(false); }); }); });