zilverline / react-tap-event-plugin

Instant TapEvents for React
http://facebook.github.io/react/
MIT License
1.07k stars 110 forks source link

how to test touch in my project #107

Open wendy-92 opened 7 years ago

wendy-92 commented 7 years ago

when i test my component with onTouchTap I gotReactWrapper::simulate() event 'touchTap' does not exist and if run test with simulate('click'),i will can't get anything here is my test code

injectTapEventPlugin();

const expect = chai.expect;
// let store;
let app;
describe('login', () => {
  beforeEach(() => {
    app = mount (
      <Provider store={store}>
          <App>
            <LoginWrapper />
          </App>
      </Provider>
    )
  })
  describe('Enzyme Mount', function () {
    it('Add a new Todo', function (done) {
      const nameInput = app.find(TextField).get(0);
      const passwordInput = app.find(TextField).get(1);
      nameInput.setState({'uid':'demo'});
      passwordInput.setState({'pwd':'daemon'})
      app.find(ArrowRight).simulate('touchTap');
      const check = () => {
        console.log(JSON.parse((localStorage.getItem('AUTH'))).loggedIn,'))');
        expect(JSON.parse((localStorage.getItem('AUTH'))).loggedIn).to.equal(true);
        //expect(JSON.parse((localStorage.getItem('AUTH'))).loggedIn).to.equal(true);
        done();
      }
      setTimeout(check, 4000);
      console.log(JSON.parse((localStorage.getItem('AUTH'))).loggedIn);

    });
  });
});