Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/utils/__tests__/validation.test.js
Show First 20 Lines • Show All 258 Lines • ▼ Show 20 Lines | describe('Validation utils', () => { | ||||
it(`Correctly validates token stats for token with no minting baton`, () => { | it(`Correctly validates token stats for token with no minting baton`, () => { | ||||
expect(isValidTokenStats(cGenStatsValid)).toBe(true); | expect(isValidTokenStats(cGenStatsValid)).toBe(true); | ||||
}); | }); | ||||
it(`Recognizes a token stats object with missing required keys as invalid`, () => { | it(`Recognizes a token stats object with missing required keys as invalid`, () => { | ||||
expect(isValidTokenStats(noCovidStatsInvalid)).toBe(false); | expect(isValidTokenStats(noCovidStatsInvalid)).toBe(false); | ||||
}); | }); | ||||
it(`Recognizes a valid cashtab settings object`, () => { | it(`Recognizes a valid cashtab settings object`, () => { | ||||
expect( | expect( | ||||
isValidCashtabSettings({ fiatCurrency: 'usd', sendModal: false }), | isValidCashtabSettings({ | ||||
fiatCurrency: 'usd', | |||||
sendModal: false, | |||||
autoCameraOn: true, | |||||
}), | |||||
).toBe(true); | ).toBe(true); | ||||
}); | }); | ||||
it(`Rejects a cashtab settings object for an unsupported currency`, () => { | it(`Rejects a cashtab settings object for an unsupported currency`, () => { | ||||
expect( | expect( | ||||
isValidCashtabSettings({ fiatCurrency: 'xau', sendModal: false }), | isValidCashtabSettings({ fiatCurrency: 'xau', sendModal: false }), | ||||
).toBe(false); | ).toBe(false); | ||||
}); | }); | ||||
it(`Rejects a corrupted cashtab settings object for an unsupported currency`, () => { | it(`Rejects a corrupted cashtab settings object for an unsupported currency`, () => { | ||||
▲ Show 20 Lines • Show All 390 Lines • ▼ Show 20 Lines | describe('Validation utils', () => { | ||||
it('updates an invalid settings object and keeps existing valid settings intact', () => | it('updates an invalid settings object and keeps existing valid settings intact', () => | ||||
expect( | expect( | ||||
parseInvalidSettingsForMigration({ | parseInvalidSettingsForMigration({ | ||||
fiatCurrency: 'gbp', | fiatCurrency: 'gbp', | ||||
}), | }), | ||||
).toStrictEqual({ | ).toStrictEqual({ | ||||
fiatCurrency: 'gbp', | fiatCurrency: 'gbp', | ||||
sendModal: false, | sendModal: false, | ||||
autoCameraOn: true, | |||||
})); | })); | ||||
it('sets settings object with no exsting valid settings to default values', () => | it('sets settings object with no exsting valid settings to default values', () => | ||||
expect(parseInvalidSettingsForMigration({})).toStrictEqual({ | expect(parseInvalidSettingsForMigration({})).toStrictEqual({ | ||||
fiatCurrency: 'usd', | fiatCurrency: 'usd', | ||||
sendModal: false, | sendModal: false, | ||||
autoCameraOn: true, | |||||
})); | })); | ||||
it('does nothing if valid settings object is present in localStorage', () => | it('does nothing if valid settings object is present in localStorage', () => | ||||
expect( | expect( | ||||
parseInvalidSettingsForMigration({ | parseInvalidSettingsForMigration({ | ||||
fiatCurrency: 'brl', | fiatCurrency: 'brl', | ||||
sendModal: true, | sendModal: true, | ||||
autoCameraOn: true, | |||||
}), | }), | ||||
).toStrictEqual({ | ).toStrictEqual({ | ||||
fiatCurrency: 'brl', | fiatCurrency: 'brl', | ||||
sendModal: true, | sendModal: true, | ||||
autoCameraOn: true, | |||||
})); | })); | ||||
}); | }); |