Skip to content

Commit

Permalink
fix: toucher log test
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre Haller committed Apr 8, 2020
1 parent 6df2803 commit c7f2abd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/species/toucher.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export default userConfig => (logger, randomizer) => {
config.showAction(touches);
}
if (logger && config.log) {
logger.log('gremlin', 'toucher ', touchType, 'at', posX, posY, details);
logger.log('gremlin', 'toucher', touchType, 'at', posX, posY, details);
}
};
touchTypes[touchType](position, targetElement, log);
Expand Down
15 changes: 9 additions & 6 deletions src/species/toucher.spec.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import toucher from './toucher';

jest.useFakeTimers();

describe('toucher', () => {
const dispatchEventSpy = jest.fn();
const initEventSpy = jest.fn();
let inputText;
let chanceMock;
let consoleMock;

beforeEach(() => {
chanceMock = {
Expand All @@ -15,6 +15,7 @@ describe('toucher', () => {
integer: ({ max }) => max,
pick: types => types[0],
};
consoleMock = { log: jest.fn() };

inputText = document.createElement('input');
inputText.setAttribute('type', 'text');
Expand Down Expand Up @@ -44,11 +45,13 @@ describe('toucher', () => {
document.body.innerHTML = '';
});

it.skip('should log the toucher', () => {
// const species = toucher({ log: true })(console, chanceMock);
// species();
// expect(consoleSpy).toHaveBeenCalledTimes(1);
// expect(consoleSpy).toHaveBeenCalledWith('gremlin', 'toucher type', 'A', 'at', 10, 10);
it('should log the toucher', () => {
const species = toucher({ log: true })(consoleMock, chanceMock);

species();
jest.runAllTimers();
expect(consoleMock.log).toHaveBeenCalledTimes(1);
expect(consoleMock.log).toHaveBeenCalledWith('gremlin', 'toucher', 'tap', 'at', 10, 10, { duration: 700 });
});

it("should touch the element but don't show element", () => {
Expand Down

0 comments on commit c7f2abd

Please sign in to comment.