Skip to content

Instantly share code, notes, and snippets.

@sipamungkas
Created September 8, 2022 07:40
Show Gist options
  • Save sipamungkas/8922cded82ac909cd62369957eb17c81 to your computer and use it in GitHub Desktop.
Save sipamungkas/8922cded82ac909cd62369957eb17c81 to your computer and use it in GitHub Desktop.

Revisions

  1. sipamungkas created this gist Sep 8, 2022.
    27 changes: 27 additions & 0 deletions react-native-blob-util-mock.MD
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    # React native Blob Util Mock for unit test

    Package Link: [react-native-blob-util](https://github.com/RonRadtke/react-native-blob-util)

    ## mock code
    ```javascript
    jest.mock('react-native-blob-util', () => {
    return {
    __esModule: true,
    default: {
    DocumentDir: jest.fn(),
    config: jest.fn(() => ({
    fetch: jest.fn(() => ({
    progress: jest.fn().mockResolvedValue(true),
    })),
    })),
    fs: {
    cp: jest.fn().mockResolvedValue(true),
    dirs: {
    CacheDir: '/mockCacheDir',
    },
    unlink: jest.fn(),
    },
    },
    };
    });
    ```