fix(lib): fix issue with CameraRoll.saveImageWithTag and new save function with options

This commit is contained in:
Bartol Karuza 2019-08-14 21:31:43 +02:00
parent c958493441
commit 7519cb5fa8
2 changed files with 7 additions and 5 deletions

View File

@ -120,7 +120,7 @@ class CameraRoll {
console.warn( console.warn(
'`CameraRoll.saveImageWithTag()` is deprecated. Use `CameraRoll.saveToCameraRoll()` instead.', '`CameraRoll.saveImageWithTag()` is deprecated. Use `CameraRoll.saveToCameraRoll()` instead.',
); );
return this.saveToCameraRoll(tag, {type: 'photo'}); return this.saveToCameraRoll(tag, 'photo');
} }
static deletePhotos(photos: Array<string>) { static deletePhotos(photos: Array<string>) {
@ -157,8 +157,11 @@ class CameraRoll {
} }
return RNCCameraRoll.saveToCameraRoll(tag, {type, album}); return RNCCameraRoll.saveToCameraRoll(tag, {type, album});
} }
static saveToCameraRoll(tag: string, type?: photo | video) { static saveToCameraRoll(
CameraRoll.save(tag, {type}); tag: string,
type?: 'photo' | 'video' | 'auto',
): Promise<string> {
return CameraRoll.save(tag, {type});
} }
/** /**
* Returns a Promise with photo identifier objects from the local camera * Returns a Promise with photo identifier objects from the local camera

View File

@ -26,11 +26,10 @@ describe('CameraRoll', () => {
}); });
it('Should call save', async () => { it('Should call save', async () => {
await CameraRoll.save('a tag', {type:'photo'}); await CameraRoll.save('a tag', {type: 'photo'});
expect(NativeModule.saveToCameraRoll.mock.calls).toMatchSnapshot(); expect(NativeModule.saveToCameraRoll.mock.calls).toMatchSnapshot();
}); });
it('Should call getPhotos', async () => { it('Should call getPhotos', async () => {
await CameraRoll.getPhotos({first: 0}); await CameraRoll.getPhotos({first: 0});
expect(NativeModule.getPhotos.mock.calls).toMatchSnapshot(); expect(NativeModule.getPhotos.mock.calls).toMatchSnapshot();