RealOrangeOne / react-native-mock

A fully mocked and test-friendly version of react native (maintainers wanted)
MIT License
570 stars 153 forks source link

Add Network mocks: XMLHttpRequest, FormData, Headers, Response #119

Closed taylesworth closed 7 years ago

taylesworth commented 7 years ago

I have some tests that rely on network APIs that exist in React Native but not in react-native-mock. This PR adds those APIs and resolves https://github.com/RealOrangeOne/react-native-mock/issues/103.

RealOrangeOne commented 7 years ago

Thanks for doing this. I don't really like the way it's done. Could you strip out all the special defineProperty stuff that's just copied from react-native, and just use Object.assign on global directly. It's a lot of code that really isnt needed. I do like that youre keeping the implementations of the APIs, just the mocking isnt standard. Also, linter is failing

taylesworth commented 7 years ago

@RealOrangeOne Changes made. I kept InitializeCore.js but stripped it down to just what was necessary. I thought it would be good to keep those property definitions in a file that corresponds to where they are defined in React Native itself. But I can move them to either react-native.js or mock.js if you prefer.

RealOrangeOne commented 7 years ago

I like this cut down file. But I don't like that it's not really doing what it says. It'd be nice if we could change defineGlobalProperty to be in a utils file in the src dir, then move the uses of it into react-native.js. Keep everything following roughly the same structure

taylesworth commented 7 years ago

@RealOrangeOne Ready for another look.