Code Monkey home page Code Monkey logo

Comments (11)

matthewshirley avatar matthewshirley commented on August 20, 2024 1

Scoped this out with Jest and RobotJS.

const ioHook = require('./index')
const robot = require("robotjs");

// The assertion for a promise must be returned.
it('receives the text "Hello World"', (done) => {
    let currentKey = 0;

    const actualCharacters = [];
    const expectedChracters = ['H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd'];
    
    const eventCallback = (event) => {
        actualCharacters.push(String.fromCharCode(event.keychar))
        
        if (currentKey === expectedChracters.length) {
            expect(actualCharacters).toEqual(expectedChracters);
        }

        currentKey += 1;
        done();
    };

    ioHook.on('keypress', eventCallback);
    ioHook.start()

    robot.typeString("Hello World");
});

from iohook.

Djiit avatar Djiit commented on August 20, 2024

This is great! Do you want to put this in a PR? Currently merging all the existing ones. Thanks !

from iohook.

matthewshirley avatar matthewshirley commented on August 20, 2024

Let's write a test for the shortcuts and maybe test the mouse.

from iohook.

Djiit avatar Djiit commented on August 20, 2024

@DCzajkowski it seems that the test are not passing on CI https://travis-ci.org/WilixLead/iohook/jobs/378076504

from iohook.

DCzajkowski avatar DCzajkowski commented on August 20, 2024

It is something Travis related, no?

Cannot find module '/home/travis/build/WilixLead/iohook/builds/node-v64-linux-x64/build/Release/iohook.node' from 'index.js'

from iohook.

Djiit avatar Djiit commented on August 20, 2024

I don't know. is there anything you run before npm run test ?

from iohook.

DCzajkowski avatar DCzajkowski commented on August 20, 2024

Not really. BUT, I have hard time building the whole thing because of version mismatches etc. I don't think it's my code that broke anything, because I have not touched anything regarding builds... So I have no clue what causes Travis to fail

from iohook.

Djiit avatar Djiit commented on August 20, 2024

Actually it is the tests not passing :). I think I will silence them for now.

from iohook.

DCzajkowski avatar DCzajkowski commented on August 20, 2024

Ehh... Do you know how to fix them?

from iohook.

DCzajkowski avatar DCzajkowski commented on August 20, 2024

This could help: jestjs/jest#5123

from iohook.

ash0x0 avatar ash0x0 commented on August 20, 2024

Closing as stale.

from iohook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.