Skip to content

Commit

Permalink
test(storage): ensure modular API are exported properly (#7926)
Browse files Browse the repository at this point in the history
  • Loading branch information
russellwheatley authored Jul 30, 2024
1 parent 3223792 commit 275f23a
Show file tree
Hide file tree
Showing 5 changed files with 399 additions and 27 deletions.
121 changes: 120 additions & 1 deletion packages/storage/__tests__/storage.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
import { describe, expect, it } from '@jest/globals';

import storage, { firebase } from '../lib';
import storage, {
firebase,
getStorage,
connectStorageEmulator,
ref,
deleteObject,
getBlob,
getBytes,
getDownloadURL,
getMetadata,
getStream,
list,
listAll,
updateMetadata,
uploadBytes,
uploadBytesResumable,
uploadString,
refFromURL,
setMaxOperationRetryTime,
setMaxUploadRetryTime,
putFile,
writeToFile,
toString,
child,
setMaxDownloadRetryTime,
} from '../lib';

describe('Storage', function () {
describe('namespace', function () {
Expand Down Expand Up @@ -45,4 +70,98 @@ describe('Storage', function () {
expect(bar).toEqual(['10.0.2.2', 9000]);
});
});

describe('modular', function () {
it('`getStorage` function is properly exposed to end user', function () {
expect(getStorage).toBeDefined();
});

it('`connectStorageEmulator` function is properly exposed to end user', function () {
expect(connectStorageEmulator).toBeDefined();
});

it('`ref` function is properly exposed to end user', function () {
expect(ref).toBeDefined();
});

it('`deleteObject` function is properly exposed to end user', function () {
expect(deleteObject).toBeDefined();
});

it('`getBlob` function is properly exposed to end user', function () {
expect(getBlob).toBeDefined();
});

it('`getBytes` function is properly exposed to end user', function () {
expect(getBytes).toBeDefined();
});

it('`getDownloadURL` function is properly exposed to end user', function () {
expect(getDownloadURL).toBeDefined();
});

it('`getMetadata` function is properly exposed to end user', function () {
expect(getMetadata).toBeDefined();
});

it('`getStream` function is properly exposed to end user', function () {
expect(getStream).toBeDefined();
});

it('`list` function is properly exposed to end user', function () {
expect(list).toBeDefined();
});

it('`listAll` function is properly exposed to end user', function () {
expect(listAll).toBeDefined();
});

it('`updateMetadata` function is properly exposed to end user', function () {
expect(updateMetadata).toBeDefined();
});

it('`uploadBytes` function is properly exposed to end user', function () {
expect(uploadBytes).toBeDefined();
});

it('`uploadBytesResumable` function is properly exposed to end user', function () {
expect(uploadBytesResumable).toBeDefined();
});

it('`uploadString` function is properly exposed to end user', function () {
expect(uploadString).toBeDefined();
});

it('`refFromURL` function is properly exposed to end user', function () {
expect(refFromURL).toBeDefined();
});

it('`setMaxOperationRetryTime` function is properly exposed to end user', function () {
expect(setMaxOperationRetryTime).toBeDefined();
});

it('`setMaxUploadRetryTime` function is properly exposed to end user', function () {
expect(setMaxUploadRetryTime).toBeDefined();
});

it('`putFile` function is properly exposed to end user', function () {
expect(putFile).toBeDefined();
});

it('`writeToFile` function is properly exposed to end user', function () {
expect(writeToFile).toBeDefined();
});

it('`toString` function is properly exposed to end user', function () {
expect(toString).toBeDefined();
});

it('`child` function is properly exposed to end user', function () {
expect(child).toBeDefined();
});

it('`setMaxDownloadRetryTime` function is properly exposed to end user', function () {
expect(setMaxDownloadRetryTime).toBeDefined();
});
});
});
2 changes: 2 additions & 0 deletions packages/storage/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1172,3 +1172,5 @@ declare module '@react-native-firebase/app' {
}
}
}

export * from './modular';
27 changes: 2 additions & 25 deletions packages/storage/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,6 @@ import { getGsUrlParts, getHttpUrlParts, handleStorageEvent } from './utils';
import version from './version';
import fallBackModule from './web/RNFBStorageModule';

export {
getStorage,
connectStorageEmulator,
ref,
deleteObject,
getBlob,
getBytes,
getDownloadURL,
getMetadata,
getStream,
list,
listAll,
updateMetadata,
putFile,
writeToFile,
toString,
child,
setMaxDownloadRetryTime,
setMaxOperationRetryTime,
setMaxUploadRetryTime,
refFromURL,
uploadString,
uploadBytesResumable,
} from '../modular/index';

const namespace = 'storage';
const nativeEvents = ['storage_event'];
const nativeModuleName = 'RNFBStorageModule';
Expand Down Expand Up @@ -233,4 +208,6 @@ export default createModuleNamespace({
// firebase.storage().X(...);
export const firebase = getFirebaseRoot();

export * from './modular';

setReactNativeModule(nativeModuleName, fallBackModule);
Loading

0 comments on commit 275f23a

Please sign in to comment.