fix(plugin-workflow): fix tests (#360)
This commit is contained in:
parent
bf987e9f59
commit
61b28b37db
@ -119,7 +119,7 @@ describe('workflow > instructions > condition', () => {
|
|||||||
|
|
||||||
describe('group calculation', () => {
|
describe('group calculation', () => {
|
||||||
it('and true', async () => {
|
it('and true', async () => {
|
||||||
const n1 = workflow.createNode({
|
const n1 = await workflow.createNode({
|
||||||
type: 'condition',
|
type: 'condition',
|
||||||
config: {
|
config: {
|
||||||
calculation: {
|
calculation: {
|
||||||
@ -148,38 +148,36 @@ describe('workflow > instructions > condition', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('and false', async () => {
|
it('and false', async () => {
|
||||||
await db.sequelize.transaction(async transaction => {
|
const n1 = await workflow.createNode({
|
||||||
const n1 = workflow.createNode({
|
type: 'condition',
|
||||||
type: 'condition',
|
config: {
|
||||||
config: {
|
calculation: {
|
||||||
calculation: {
|
group: {
|
||||||
group: {
|
type: 'and',
|
||||||
type: 'and',
|
calculations: [
|
||||||
calculations: [
|
{
|
||||||
{
|
calculator: 'equal',
|
||||||
calculator: 'equal',
|
operands: [{ value: 1 }, { value: 1 }]
|
||||||
operands: [{ value: 1 }, { value: 1 }]
|
},
|
||||||
},
|
{
|
||||||
{
|
calculator: 'equal',
|
||||||
calculator: 'equal',
|
operands: [{ value: 0 }, { value: 1 }]
|
||||||
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 () => {
|
it('or true', async () => {
|
||||||
const n1 = workflow.createNode({
|
const n1 = await workflow.createNode({
|
||||||
type: 'condition',
|
type: 'condition',
|
||||||
config: {
|
config: {
|
||||||
calculation: {
|
calculation: {
|
||||||
@ -208,7 +206,7 @@ describe('workflow > instructions > condition', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('or false', async () => {
|
it('or false', async () => {
|
||||||
const n1 = workflow.createNode({
|
const n1 = await workflow.createNode({
|
||||||
type: 'condition',
|
type: 'condition',
|
||||||
config: {
|
config: {
|
||||||
calculation: {
|
calculation: {
|
||||||
@ -237,39 +235,37 @@ describe('workflow > instructions > condition', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('nested', async () => {
|
it('nested', async () => {
|
||||||
await db.sequelize.transaction(async transaction => {
|
const n1 = await workflow.createNode({
|
||||||
const n1 = workflow.createNode({
|
type: 'condition',
|
||||||
type: 'condition',
|
config: {
|
||||||
config: {
|
calculation: {
|
||||||
calculation: {
|
group: {
|
||||||
group: {
|
type: 'and',
|
||||||
type: 'and',
|
calculations: [
|
||||||
calculations: [
|
{
|
||||||
{
|
calculator: 'equal',
|
||||||
calculator: 'equal',
|
operands: [{ value: 1 }, { value: 1 }]
|
||||||
operands: [{ value: 1 }, { value: 1 }]
|
},
|
||||||
},
|
{
|
||||||
{
|
group: {
|
||||||
group: {
|
type: 'or',
|
||||||
type: 'or',
|
calculations: [
|
||||||
calculations: [
|
{ calculator: 'equal', operands: [{ value: 0 }, { value: 1 }] },
|
||||||
{ calculator: 'equal', operands: [{ value: 0 }, { value: 1 }] },
|
{ 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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user