Skip to content

Commit

Permalink
Fix tests, begin implementing CurrencyDirectory and CurrencyDefinitio…
Browse files Browse the repository at this point in the history
…nStorage for a dynamic coin list
  • Loading branch information
michaeltout committed May 18, 2023
1 parent 877a500 commit acd3889
Show file tree
Hide file tree
Showing 24 changed files with 686 additions and 169 deletions.
11 changes: 0 additions & 11 deletions __mocks__/agama-wallet-lib/agama-wallet-lib-electrums.js

This file was deleted.

12 changes: 6 additions & 6 deletions __mocks__/ethers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const mockedModule = jest.mock('ethers');
mockedModule.getDefaultProvider = jest.fn()
mockedModule.providers = {
EtherscanProvider: jest.fn()
}
// const mockedModule = jest.mock('ethers');
// mockedModule.getDefaultProvider = jest.fn()
// mockedModule.providers = {
// EtherscanProvider: jest.fn()
// }

module.exports = mockedModule;
// module.exports = mockedModule;
3 changes: 2 additions & 1 deletion __mocks__/redux/mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ function mockRedux() {
store.dispatch(action)
}
}
}
},
compose: () => {}
}
}

Expand Down
99 changes: 97 additions & 2 deletions debug/setupJest.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,107 @@
const mockAgamaWalletLibElectrums = require('../__mocks__/agama-wallet-lib/agama-wallet-lib-electrums')
const mockVerusLightClient = require('../__mocks__/react-native-verus-light-client/mock')
const mockRnAlertAsync = require('../__mocks__/react-native-alert-async/mock')
const mockRedux = require('../__mocks__/redux/mock')

jest.mock('agama-wallet-lib/src/electrum-servers', () => mockAgamaWalletLibElectrums());
jest.mock('react-native-verus-light-client', () => mockVerusLightClient());
jest.mock('react-native-alert-async', () => mockRnAlertAsync());
jest.mock('redux', () => mockRedux());
jest.mock('@react-native-async-storage/async-storage', () =>
require('@react-native-async-storage/async-storage/jest/async-storage-mock')
);
jest.mock('react-native-crypto', () =>
require('crypto')
);
jest.mock('react-native-keychain', () => ({
setGenericPassword: jest.fn(() => Promise.resolve('mockPass')),
getGenericPassword: jest.fn(() => Promise.resolve('mockPass')),
resetGenericPassword: jest.fn(() => Promise.resolve(null)),
}));
jest.mock('react-native-fs', () => {
return {
mkdir: jest.fn(),
moveFile: jest.fn(),
copyFile: jest.fn(),
pathForBundle: jest.fn(),
pathForGroup: jest.fn(),
getFSInfo: jest.fn(),
getAllExternalFilesDirs: jest.fn(),
unlink: jest.fn(),
exists: jest.fn(),
stopDownload: jest.fn(),
resumeDownload: jest.fn(),
isResumable: jest.fn(),
stopUpload: jest.fn(),
completeHandlerIOS: jest.fn(),
readDir: jest.fn(),
readDirAssets: jest.fn(),
existsAssets: jest.fn(),
readdir: jest.fn(),
setReadable: jest.fn(),
stat: jest.fn(),
readFile: jest.fn(),
read: jest.fn(),
readFileAssets: jest.fn(),
hash: jest.fn(),
copyFileAssets: jest.fn(),
copyFileAssetsIOS: jest.fn(),
copyAssetsVideoIOS: jest.fn(),
writeFile: jest.fn(),
appendFile: jest.fn(),
write: jest.fn(),
downloadFile: jest.fn(),
uploadFiles: jest.fn(),
touch: jest.fn(),
MainBundlePath: jest.fn(),
CachesDirectoryPath: jest.fn(),
DocumentDirectoryPath: jest.fn(),
ExternalDirectoryPath: jest.fn(),
ExternalStorageDirectoryPath: jest.fn(),
TemporaryDirectoryPath: jest.fn(),
LibraryDirectoryPath: jest.fn(),
PicturesDirectoryPath: jest.fn(),
};
});
jest.mock('react-native-randombytes', () => {
return {
randomBytes: (length, cb) => {
if (!cb) {
return Buffer.alloc(length)
} else {
cb(null, Buffer.alloc(length))
}
}
};
});
jest.mock('react-native-iphone-x-helper', () => {
return {
isIphoneX: jest.fn(),
ifIphoneX: jest.fn(),
getStatusBarHeight: jest.fn(),
getBottomSpace: jest.fn(),
};
});
jest.mock('react-native-haptic-feedback', () => {
return {
trigger: jest.fn(),
};
});
jest.mock('@react-native-community/netinfo', () => {
return {
getCurrentConnectivity: jest.fn(),
isConnectionMetered: jest.fn(),
addListener: jest.fn(),
removeListeners: jest.fn(),
isConnected: {
fetch: () => {
return Promise.resolve(true);
},
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
},
};
});
jest.mock('ethers', () => require('ethers/dist/ethers.umd'));
jest.mock('react-native-url-polyfill', () => require('url'));

global.fetch = require('../__mocks__/react-native-fetch/fetch')

Expand Down
1 change: 1 addition & 0 deletions env/main.android.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"SERVICE_STORAGE_INTERNAL_KEY": "serviceStoredData",
"NOTIFICATIONS_STORAGE_INTERNAL_KEY": "notifications",
"WIDGET_STORAGE_INTERNAL_KEY": "widgets",
"CURRENCY_DEFINITION_STORAGE_INTERNAL_KEY": "currencyDefinitions",

"WYRE_ACCESSIBLE": true
}
1 change: 1 addition & 0 deletions env/main.ios.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"SERVICE_STORAGE_INTERNAL_KEY": "serviceStoredData",
"NOTIFICATIONS_STORAGE_INTERNAL_KEY": "notifications",
"WIDGET_STORAGE_INTERNAL_KEY": "widgets",
"CURRENCY_DEFINITION_STORAGE_INTERNAL_KEY": "currencyDefinitions",

"WYRE_ACCESSIBLE": true
}
1 change: 1 addition & 0 deletions ios/assets/env/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"SERVICE_STORAGE_INTERNAL_KEY": "serviceStoredData",
"NOTIFICATIONS_STORAGE_INTERNAL_KEY": "notifications",
"WIDGET_STORAGE_INTERNAL_KEY": "widgets",
"CURRENCY_DEFINITION_STORAGE_INTERNAL_KEY": "currencyDefinitions",

"WYRE_ACCESSIBLE": true
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"bundle-android": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/",
"bundle-ios": "react-native bundle --dev false --entry-file index.js --bundle-output ios/main.jsbundle --platform ios --assets-dest='./ios'",
"dist-android": "cd android && ./gradlew assembleRelease && cd ..",
"test": "snyk test && jest",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
Expand Down
Loading

0 comments on commit acd3889

Please sign in to comment.