mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-02 07:01:30 -08:00
Fix summarize test
This commit is contained in:
parent
6f656d3b6b
commit
c8d5b4b18d
|
@ -10,10 +10,7 @@ let summarizeNode: Summarize;
|
||||||
let mockExecuteFunctions: MockProxy<IExecuteFunctions>;
|
let mockExecuteFunctions: MockProxy<IExecuteFunctions>;
|
||||||
|
|
||||||
describe('Test Summarize Node, execute', () => {
|
describe('Test Summarize Node, execute', () => {
|
||||||
let nodeExecutionOutputSpy: jest.SpyInstance;
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
nodeExecutionOutputSpy = jest.spyOn(NodeExecutionOutput.prototype, 'constructor' as any);
|
|
||||||
|
|
||||||
summarizeNode = new Summarize();
|
summarizeNode = new Summarize();
|
||||||
mockExecuteFunctions = mock<IExecuteFunctions>({
|
mockExecuteFunctions = mock<IExecuteFunctions>({
|
||||||
getNode: jest.fn().mockReturnValue({ name: 'test-node' }),
|
getNode: jest.fn().mockReturnValue({ name: 'test-node' }),
|
||||||
|
@ -26,7 +23,6 @@ describe('Test Summarize Node, execute', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
nodeExecutionOutputSpy.mockRestore();
|
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -47,16 +43,14 @@ describe('Test Summarize Node, execute', () => {
|
||||||
|
|
||||||
const result = await summarizeNode.execute.call(mockExecuteFunctions);
|
const result = await summarizeNode.execute.call(mockExecuteFunctions);
|
||||||
|
|
||||||
expect(result).toBeDefined();
|
expect(result).toBeInstanceOf(NodeExecutionOutput);
|
||||||
expect(nodeExecutionOutputSpy).toHaveBeenCalledWith(
|
expect(result).toEqual([[{ json: { sum_nonexistentField: 0 }, pairedItem: [{ item: 0 }] }]]);
|
||||||
expect.any(Array),
|
expect((result as NodeExecutionOutput).getHints()).toEqual([
|
||||||
expect.arrayContaining([
|
{
|
||||||
expect.objectContaining({
|
|
||||||
message: expect.stringContaining('nonexistentField'),
|
|
||||||
location: 'outputPane',
|
location: 'outputPane',
|
||||||
}),
|
message: "The field 'nonexistentField' does not exist in any items",
|
||||||
]),
|
},
|
||||||
);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw error if node version is < 1.1 and fields not found', async () => {
|
it('should throw error if node version is < 1.1 and fields not found', async () => {
|
||||||
|
|
Loading…
Reference in a new issue