[react-packager] Support platform extensions in image requires

Summary:
We don't currently support platform extensions in asset modules.
This adds supports for it:

```
require('./a.png');
```

Will require 'a.ios.png' if it exists and 'a.png' if it doesn't.
This commit is contained in:
Amjad Masad
2015-09-04 15:21:58 -07:00
parent 8831bb10a1
commit 936e1d4a11
11 changed files with 413 additions and 86 deletions

View File

@@ -244,8 +244,16 @@ describe('processRequest', () => {
expect(res.end).toBeCalledWith('i am image');
});
it('should return 404', () => {
it('should parse the platform option', () => {
const req = {url: '/assets/imgs/a.png?platform=ios'};
const res = {end: jest.genMockFn()};
AssetServer.prototype.get.mockImpl(() => Promise.resolve('i am image'));
server.processRequest(req, res);
jest.runAllTimers();
expect(AssetServer.prototype.get).toBeCalledWith('imgs/a.png', 'ios');
expect(res.end).toBeCalledWith('i am image');
});
});