diff --git a/src/app/lnd/transactions/send-payment-modal/send-payment.component.spec.ts b/src/app/lnd/transactions/send-payment-modal/send-payment.component.spec.ts index 82d35079..828e2a69 100644 --- a/src/app/lnd/transactions/send-payment-modal/send-payment.component.spec.ts +++ b/src/app/lnd/transactions/send-payment-modal/send-payment.component.spec.ts @@ -65,7 +65,7 @@ describe('LightningSendPaymentsComponent', () => { }); it('should get lnd store value on ngOnInit', () => { - const storeSpy = spyOn(store, 'select').and.returnValue(of(mockRTLStoreState.lnd.nodeSettings)); + const storeSpy = spyOn(store, 'select').and.returnValue(of(mockRTLStoreState.root.selNode)); component.ngOnInit(); if (component.selNode) { expect(component.selNode.lnImplementation).toBe('LND'); @@ -112,7 +112,7 @@ describe('LightningSendPaymentsComponent', () => { expect(component.zeroAmtInvoice).toEqual(false); expect(component.paymentReq.control.errors).toBe(null); expect(component.paymentError).toEqual(''); - expect(component.paymentDecodedHint).toEqual(''); + expect(component.paymentDecodedHintPre).toEqual(''); }); it('should update title on advanced panel toggle', () => { @@ -130,7 +130,7 @@ describe('LightningSendPaymentsComponent', () => { it('should return from decode payment when pay request length is less than hundred ', () => { component.onPaymentRequestEntry('lntb4u1psvdzaypp55'); - expect(component.paymentDecodedHint).toEqual(''); + expect(component.paymentDecodedHintPre).toEqual(''); }); it('should decode payment when pay request is for the zero amount invoice', () => { @@ -142,7 +142,7 @@ describe('LightningSendPaymentsComponent', () => { component.onPaymentRequestEntry(component.paymentRequest); fixture.detectChanges(); expect(component.zeroAmtInvoice).toBe(true); - expect(component.paymentDecodedHint).toEqual('Memo: Testing Empty Invoice for LND 3'); + expect(component.paymentDecodedHintPre).toEqual('Memo: Testing Empty Invoice for LND 3'); expect(component.filteredMinAmtActvChannels).toEqual(component.activeChannels); }); @@ -153,7 +153,7 @@ describe('LightningSendPaymentsComponent', () => { 'cwjfjxgpcuqqqxsqqyqqqqlgqqqqqqgq9q9qy9qsqwf6a4w9uqthm3aslwt03ucqt03e8j2atxrmt022d5kaw65cmqc3pnghz5xmsh2tlz9syhaulrxtwmvh3gdx9j33gec6yryc' + 'wh2g05qgqdnftgk'); expect(component.zeroAmtInvoice).toBe(true); - expect(component.paymentDecodedHint).toEqual('Memo: Testing Empty Invoice for LND 3'); + expect(component.paymentDecodedHintPre).toEqual('Memo: Testing Empty Invoice for LND 3'); expect(component.filteredMinAmtActvChannels).toEqual(component.activeChannels); expect(component.paymentAmount).toBeNull(); component.onSendPayment(); @@ -165,14 +165,15 @@ describe('LightningSendPaymentsComponent', () => { it('should decode payment when pay request changed and fiat conversion is true', () => { const updatedSelNode: Node = JSON.parse(JSON.stringify(component.selNode)); - updatedSelNode.fiatConversion = true; - updatedSelNode.currencyUnits = ['BTC', 'SAT', 'USD']; + updatedSelNode.settings.fiatConversion = true; + updatedSelNode.settings.currencyUnits = ['SATS', 'BTC', 'USD']; Object.defineProperty(component, 'selNode', { value: updatedSelNode }); component.onPaymentRequestEntry('lntb4u1psvdzaypp555uks3f6774kl3vdy2dfr00j847pyxtrqelsdnczuxnmtqv99srsdpy23jhxarfdenjqmn8wfuzq3' + 'txvejkxarnyq6qcqp2sp5xjzu6pz2sf8x4v8nmr58kjdm6k05etjfq9c96mwkhzl0g9j7sjkqrzjq28vwprzypa40c75myejm8s2aenkeykcnd7flvy9plp2yjq56nvr' + 'c8ss5cqqqzgqqqqqqqlgqqqqqqgq9q9qy9qsqpt6u4rwfrck3tmpn54kdxjx3xdch62t5wype2f44mmlar07y749xt9elhfhf6dnlfk2tjwg3qpy8njh6remphfcc0630a' + 'q38j0s3hrgpv4eel3'); - expect(component.paymentDecodedHint).toEqual('Sending: 400 Sats (USD 0.13) | Memo: Testing ngrx Effects 4'); + expect(component.paymentDecodedHintPre).toEqual('Sending: 400 Sats ('); + expect(component.paymentDecodedHintPost).toEqual('0.13) | Memo: Testing ngrx Effects 4'); }); it('should decode payment when pay request changed and fiat conversion is false', () => { @@ -180,12 +181,12 @@ describe('LightningSendPaymentsComponent', () => { 'vejkxarnyq6qcqp2sp5xjzu6pz2sf8x4v8nmr58kjdm6k05etjfq9c96mwkhzl0g9j7sjkqrzjq28vwprzypa40c75myejm8s2aenkeykcnd7flvy9plp2yjq56nvrc8s' + 's5cqqqzgqqqqqqqlgqqqqqqgq9q9qy9qsqpt6u4rwfrck3tmpn54kdxjx3xdch62t5wype2f44mmlar07y749xt9elhfhf6dnlfk2tjwg3qpy8njh6remphfcc0630aq38j' + '0s3hrgpv4eel3'); - expect(component.paymentDecodedHint).toEqual('Sending: 400 Sats | Memo: Testing ngrx Effects 4'); + expect(component.paymentDecodedHintPre).toEqual('Sending: 400 Sats | Memo: Testing ngrx Effects 4'); }); it('should throw an error from decode payment when pay request is not found', () => { component.onPaymentRequestEntry('p555uks3f6774kl3vdy2dfr00j847pyxtrqelsdnczuxnmtqv99srsdpy23jhxarfdenjqmn8wfuzq3txvejkxarnyq6qcqp2sp3434dsfdsf'); - expect(component.paymentDecodedHint).toEqual('ERROR: Request Failed!'); + expect(component.paymentDecodedHintPre).toEqual('ERROR: Request Failed!'); }); it('should convert Sats to USD by calling convertCurrency method from CommonService', () => { diff --git a/src/app/shared/test-helpers/test-data.ts b/src/app/shared/test-helpers/test-data.ts index 4403faa4..e722b682 100644 --- a/src/app/shared/test-helpers/test-data.ts +++ b/src/app/shared/test-helpers/test-data.ts @@ -749,8 +749,8 @@ export const mockActionsData = { unannouncedChannels: false, fiatConversion: true, currencyUnits: [ + 'Sats', 'BTC', - 'SATS', 'USD' ], bitcoindConfigPath: '', @@ -772,22 +772,6 @@ export const mockActionsData = { lnNode: 'LN Node Name', lnImplementation: 'LND' }, - resetChildrenStores: { - userPersona: 'MERCHANT', - channelBackupPath: '', - unannouncedChannels: false, - fiatConversion: true, - selCurrencyUnit: '', - currencyUnits: [ - 'Sats', - 'BTC' - ], - lnImplementation: 'LND', - swapServerUrl: '', - boltzServerUrl: '', - enableOffers: false, - enablePeerswap: false - }, setSelectedNode: { settings: { userPersona: 'MERCHANT', @@ -1002,21 +986,6 @@ export const mockRTLStoreState = { } }, lnd: { - nodeSettings: { - userPersona: 'OPERATOR', - channelBackupPath: '..\\\\RTL\\\\backup\\\\node-1', - unannouncedChannels: false, - fiatConversion: true, - selCurrencyUnit: 'USD', - currencyUnits: [ - 'Sats', - 'BTC', - 'USD' - ], - lnImplementation: 'LND', - swapServerUrl: 'https://127.0.0.1:8081', - boltzServerUrl: 'https://127.0.0.1:9003' - }, information: { version: '0.12.1-beta commit=v0.12.1-beta', commit_hash: 'd233f61383f2f950aa06f5b09da5b0e78e784fae', @@ -48640,21 +48609,6 @@ export const mockRTLStoreState = { } }, cln: { - nodeSettings: { - userPersona: 'OPERATOR', - channelBackupPath: '..\\\\RTL\\\\backup\\\\node-1', - unannouncedChannels: false, - fiatConversion: true, - selCurrencyUnit: 'USD', - currencyUnits: [ - 'Sats', - 'BTC', - 'USD' - ], - lnImplementation: 'LND', - swapServerUrl: 'https://127.0.0.1:8081', - boltzServerUrl: 'https://127.0.0.1:9003' - }, information: {}, fees: {}, feeRatesPerKB: {}, @@ -48674,21 +48628,6 @@ export const mockRTLStoreState = { utxos: [] }, ecl: { - nodeSettings: { - userPersona: 'OPERATOR', - channelBackupPath: '..\\\\RTL\\\\backup\\\\node-1', - unannouncedChannels: false, - fiatConversion: true, - selCurrencyUnit: 'USD', - currencyUnits: [ - 'Sats', - 'BTC', - 'USD' - ], - lnImplementation: 'LND', - swapServerUrl: 'https://127.0.0.1:8081', - boltzServerUrl: 'https://127.0.0.1:9003' - }, information: {}, fees: {}, activeChannels: [], diff --git a/src/app/store/rtl.effects.spec.ts b/src/app/store/rtl.effects.spec.ts index d7b61bb6..2e0f498a 100644 --- a/src/app/store/rtl.effects.spec.ts +++ b/src/app/store/rtl.effects.spec.ts @@ -87,7 +87,7 @@ describe('RTL Root Effects', () => { expect(storeDispatchSpy.calls.all()[1].args[0]).toEqual(updateRootAPICallStatus({ payload: { action: 'UpdateSelNode', status: APICallStatusEnum.INITIATED } })); expect(storeDispatchSpy.calls.all()[2].args[0]).toEqual(updateRootAPICallStatus({ payload: { action: 'UpdateSelNode', status: APICallStatusEnum.COMPLETED } })); expect(storeDispatchSpy.calls.all()[3].args[0]).toEqual(closeSpinner({ payload: UI_MESSAGES.UPDATE_SELECTED_NODE })); - expect(storeDispatchSpy.calls.all()[4].args[0]).toEqual(resetRootStore({ payload: mockActionsData.resetRootStore })); + expect(storeDispatchSpy.calls.all()[4].args[0]).toEqual(resetRootStore({ payload: mockActionsData.setSelectedNode })); expect(storeDispatchSpy.calls.all()[5].args[0]).toEqual(resetLNDStore()); expect(storeDispatchSpy.calls.all()[6].args[0]).toEqual(resetCLNStore()); expect(storeDispatchSpy.calls.all()[7].args[0]).toEqual(resetECLStore()); diff --git a/src/app/store/rtl.reducers.spec.ts b/src/app/store/rtl.reducers.spec.ts index bfea3477..632ccebd 100644 --- a/src/app/store/rtl.reducers.spec.ts +++ b/src/app/store/rtl.reducers.spec.ts @@ -1,9 +1,8 @@ import { mockActionsData } from '../shared/test-helpers/test-data'; -import { UI_MESSAGES } from '../shared/services/consts-enums-functions'; import { initRootState } from './rtl.state'; import { RootReducer } from './rtl.reducers'; -import { setSelectedNode } from './rtl.actions'; +import { resetRootStore } from './rtl.actions'; describe('RTL reducer', () => { describe('default action', () => { @@ -13,10 +12,10 @@ describe('RTL reducer', () => { }); }); - describe('Action SetSelectedNode', () => { - it('should set selected node', () => { - const SetSelectedNodeAction = setSelectedNode({ payload: { uiMessage: UI_MESSAGES.NO_SPINNER, prevLnNodeIndex: -1, currentLnNode: mockActionsData.setSelectedNode, isInitialSetup: false } }); - const newState = RootReducer(initRootState, SetSelectedNodeAction); + describe('Action Reset Root Store', () => { + it('should reset root store with new setup', () => { + const ResetRootStoreAction = resetRootStore({ payload: mockActionsData.setSelectedNode }); + const newState = RootReducer(initRootState, ResetRootStoreAction); expect(newState.selNode.settings.themeMode).toBe('NIGHT'); expect(newState.selNode.settings.themeColor).toBe('TEAL');