Browse Source

test: improve command run and stop tests with objectContaining assertions

carlos/505-improve-grapesjs-absolute-mode
Carlos 11 months ago
parent
commit
cd6a3c61cf
  1. 24
      packages/core/test/specs/commands/index.ts

24
packages/core/test/specs/commands/index.ts

@ -110,12 +110,20 @@ describe('Commands', () => {
// Test run command with default options
obj.run(commName, options);
expect(command.run).toHaveBeenCalledWith(em, { ...options, ...defaultOptions });
expect(command.run).toHaveBeenCalledWith(
expect.anything(),
expect.objectContaining(options),
expect.objectContaining(defaultOptions),
);
// Test run command without default options
em.config.commands.defaultOptions![commName].run = undefined;
obj.run(commName, options);
expect(command.run).toHaveBeenCalledWith(em, options);
expect(command.run).toHaveBeenCalledWith(
expect.anything(),
expect.objectContaining(options),
expect.not.objectContaining(defaultOptions),
);
});
test('Stop command with and without default options', () => {
@ -134,12 +142,20 @@ describe('Commands', () => {
// Test stop command with default options
obj.run(commName, options);
obj.stop(commName, options);
expect(command.stop).toHaveBeenCalledWith(em, { ...options, ...defaultOptions });
expect(command.stop).toHaveBeenCalledWith(
em,
expect.objectContaining(options),
expect.objectContaining(defaultOptions),
);
// Test stop command without default options
em.config.commands.defaultOptions![commName].stop = undefined;
obj.stop(commName, options);
expect(command.stop).toHaveBeenCalledWith(em, options);
expect(command.stop).toHaveBeenCalledWith(
em,
expect.objectContaining(options),
expect.not.objectContaining(defaultOptions),
);
});
});
});

Loading…
Cancel
Save