Last active
November 17, 2019 22:31
Revisions
-
oshell revised this gist
Nov 17, 2019 . 1 changed file with 4 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import React from 'react'; import { shallow } from 'enzyme'; import App from './App'; it('button click changes color of box', async () => { const app = shallow(<App />); expect(app.find('.box').length).toEqual(1); // cache button element @@ -15,9 +15,6 @@ it('button click changes color of box', () => { } }; // pass mocked event object await button.props().onClick(eventMock); expect(app.find('.box.red').length).toEqual(1); }); -
oshell created this gist
Nov 17, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ import React from 'react'; import { shallow } from 'enzyme'; import App from './App'; it('button click changes color of box', () => { const app = shallow(<App />); expect(app.find('.box').length).toEqual(1); // cache button element const button = app.find('button').last(); const eventMock = { target: { getAttribute: function() { return button.props()['data-color'] } } }; // pass mocked event object const promise = button.props().onClick(eventMock); promise.then(() => { expect(app.find('.box.red').length).toEqual(1); }); });