Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stage #49

Merged
merged 9 commits into from
Dec 9, 2021
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ config/
public/js/app
yarn.lock
coverage/
jest/
# jest/

# Logs
logs
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ module.exports = {
// runner: "jest-runner",

// The paths to modules that run some code to configure or set up the testing environment before each test
setupFiles: ['fake-indexeddb/auto', '<rootDir>/jest/setEnvVars.js'],
setupFiles: ['fake-indexeddb/auto', '<rootDir>/jest/setEnvVars.js', '<rootDir>/jest/MockLocalStorage.js'],

// A list of paths to modules that run some code to configure or set up the testing framework before each test
// setupFilesAfterEnv: [],
Expand Down
19 changes: 19 additions & 0 deletions jest/MockLocalStorage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class LocalStorage {
constructor() {
this.store = {};
}
clear() {
this.store = {};
}
getItem(key) {
return this.store[key] || null;
}
setItem(key, value) {
this.store[key] = String(value);
}
removeItem(key) {
delete this.store[key];
}
}

global.localStorage = new LocalStorage();
10 changes: 5 additions & 5 deletions jest/setEnvVars.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
process.env.REACT_APP_GOOGLE_REDIRECT_URL = 'https://wallet.dev.rumsan.net/google';
process.env.REACT_APP_GOOGLE_CLIENT_ID = '1037282848942-iorpo75krbdj1p40rqncs1i8504lgger.apps.googleusercontent.com';
process.env.REACT_APP_GOOGLE_REDIRECT_URL = 'https://googleRedirectUrl.com/google';
process.env.REACT_APP_GOOGLE_CLIENT_ID = '123456789-googleClientId.apps.googleusercontent.com';
process.env.REACT_APP_DEFAULT_NETWORK = 'https://testnetwork.esatya.io';
process.env.REACT_APP_DEFAULT_IPFS = 'https://upload.dev.rumsan.net';
process.env.REACT_APP_DEFAULT_IPFS_DOWNLOAD = 'https://ipfs.dev.rumsan.net/ipfs';
process.env.REACT_APP_DEFAULT_AGENCY_API = 'https://agency-nft.rahat.io/api/v1';
process.env.REACT_APP_DEFAULT_IPFS = 'https://upload.test.rumsan.net';
process.env.REACT_APP_DEFAULT_IPFS_DOWNLOAD = 'https://ipfs.test.rumsan.net/ipfs';
process.env.REACT_APP_DEFAULT_AGENCY_API = 'https://testAgency-nft.rahat.io/api/v1';
9 changes: 7 additions & 2 deletions src/services/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ const DataService = {
await db.data.clear();
await db.assets.clear();
await db.documents.clear();
await db.nfts.clear();
await db.transactions.clear();
await db.agencies.clear();
},

saveNetwork(network) {
Expand Down Expand Up @@ -141,13 +144,15 @@ const DataService = {

listTx(type) {
if (!type) return db.transactions.orderBy('timestamp').reverse().toArray();
return db.transactions.get({ type }).orderBy('timestamp').reverse();
return db.transactions.where({ type: type }).reverse().sortBy('timestamp');

// return db.transactions.get({ type }).orderBy('timestamp').reverse();
},

async addNft(nft) {
const { tokenId } = nft;
const storedNft = await this.getNft(tokenId);
if (!storedNft) return db.nfts.put({ ...nft, amount: 1 });
if (!storedNft) return db.nfts.put({ ...nft, amount: nft.amount ? nft.amount : 1 });
storedNft.amount++;
return db.nfts.put(storedNft);
},
Expand Down
Loading