Skip to content

Commit

Permalink
Merge pull request #7517 from qmonmert/sinonvsvitest
Browse files Browse the repository at this point in the history
Replace sinon by vitest in tests files (generated Vue app)
  • Loading branch information
pascalgrimaud authored Sep 18, 2023
2 parents b98500f + 5d21597 commit b221a19
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import { describe, it, expect } from 'vitest';
import sinon from 'sinon';
import { describe, it, expect, vi } from 'vitest';

import ConsoleLogger from '@/common/secondary/ConsoleLogger';

describe('ConsoleLogger', () => {
it('should log an error', () => {
const logger = {
error: sinon.stub(),
error: vi.fn(),
};
const consoleLogger = new ConsoleLogger(logger as any);
const error = new Error('Error message');

consoleLogger.error('An error occurs', error);

const [message, errorPassed] = logger.error.getCall(0).args;
expect(message).toBe('An error occurs\n');
expect(errorPassed).toBeInstanceOf(Error);
expect(errorPassed.message).toBe('Error message');
expect(logger.error).toHaveBeenCalledTimes(1);
expect(logger.error).toBeCalledWith('An error occurs\n', error);
});
});

0 comments on commit b221a19

Please sign in to comment.