Browse Source

feature(payment): add basic tests for payments reducer

renovate/lint-staged-8.x
Jack Mallers 8 years ago
parent
commit
8d88bf99ba
  1. 64
      test/reducers/__snapshots__/channels.spec.js.snap
  2. 169
      test/reducers/__snapshots__/invoice.spec.js.snap
  3. 46
      test/reducers/__snapshots__/payment.spec.js.snap
  4. 2
      test/reducers/invoice.spec.js
  5. 52
      test/reducers/payment.spec.js

64
test/reducers/__snapshots__/channels.spec.js.snap

@ -1,5 +1,69 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`reducers channelsReducer should correctly getChannels 1`] = `
Object {
"channel": null,
"channelForm": Object {
"isOpen": false,
"local_amt": "",
"node_key": "",
"push_amt": "",
},
"channels": Array [],
"channelsLoading": true,
"openingChannel": false,
"pendingChannels": Object {
"pending_closing_channels": Array [],
"pending_force_closing_channels": Array [],
"pending_open_channels": Array [],
"total_limbo_balance": "",
},
}
`;
exports[`reducers channelsReducer should correctly openingChannel 1`] = `
Object {
"channel": null,
"channelForm": Object {
"isOpen": false,
"local_amt": "",
"node_key": "",
"push_amt": "",
},
"channels": Array [],
"channelsLoading": false,
"openingChannel": true,
"pendingChannels": Object {
"pending_closing_channels": Array [],
"pending_force_closing_channels": Array [],
"pending_open_channels": Array [],
"total_limbo_balance": "",
},
}
`;
exports[`reducers channelsReducer should correctly receiveChannel 1`] = `
Object {
"channel": null,
"channelForm": Object {
"isOpen": false,
"local_amt": "",
"node_key": "",
"push_amt": "",
},
"channels": Array [
1,
2,
],
"channelsLoading": false,
"openingChannel": false,
"pendingChannels": Array [
3,
4,
],
}
`;
exports[`reducers channelsReducer should correctly setChannel 1`] = `
Object {
"channel": "channel",

169
test/reducers/__snapshots__/invoice.spec.js.snap

@ -0,0 +1,169 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`reducers invoiceReducer should correctly getInvoice 1`] = `
Object {
"data": Object {},
"formInvoice": Object {
"amount": "0",
"payreq": "",
"r_hash": "",
},
"invoice": null,
"invoiceLoading": true,
"invoices": Array [],
"invoicesSearchText": "",
}
`;
exports[`reducers invoiceReducer should correctly getInvoices 1`] = `
Object {
"data": Object {},
"formInvoice": Object {
"amount": "0",
"payreq": "",
"r_hash": "",
},
"invoice": null,
"invoiceLoading": true,
"invoices": Array [],
"invoicesSearchText": "",
}
`;
exports[`reducers invoiceReducer should correctly invcoiceFailed 1`] = `
Object {
"data": null,
"formInvoice": Object {
"amount": "0",
"payreq": "",
"r_hash": "",
},
"invoice": null,
"invoiceLoading": false,
"invoices": Array [],
"invoicesSearchText": "",
}
`;
exports[`reducers invoiceReducer should correctly invcoiceSuccessful 1`] = `
Object {
"data": Object {},
"formInvoice": Object {
"amount": "0",
"payreq": "",
"r_hash": "",
},
"invoice": null,
"invoiceLoading": false,
"invoices": Array [
"foo",
],
"invoicesSearchText": "",
}
`;
exports[`reducers invoiceReducer should correctly receiveFormInvoice 1`] = `
Object {
"data": Object {},
"formInvoice": Object {
"payreq": "foo",
},
"invoice": null,
"invoiceLoading": false,
"invoices": Array [],
"invoicesSearchText": "",
}
`;
exports[`reducers invoiceReducer should correctly receiveInvoice 1`] = `
Object {
"data": Object {},
"formInvoice": Object {
"amount": "0",
"payreq": "",
"r_hash": "",
},
"invoice": "foo",
"invoiceLoading": false,
"invoices": Array [],
"invoicesSearchText": "",
}
`;
exports[`reducers invoiceReducer should correctly receiveInvoices 1`] = `
Object {
"data": Object {},
"formInvoice": Object {
"amount": "0",
"payreq": "",
"r_hash": "",
},
"invoice": null,
"invoiceLoading": false,
"invoices": Array [
1,
2,
],
"invoicesSearchText": "",
}
`;
exports[`reducers invoiceReducer should correctly searchInvoices 1`] = `
Object {
"data": Object {},
"formInvoice": Object {
"amount": "0",
"payreq": "",
"r_hash": "",
},
"invoice": null,
"invoiceLoading": false,
"invoices": Array [],
"invoicesSearchText": "foo",
}
`;
exports[`reducers invoiceReducer should correctly sendInvoice 1`] = `
Object {
"data": Object {},
"formInvoice": Object {
"amount": "0",
"payreq": "",
"r_hash": "",
},
"invoice": null,
"invoiceLoading": true,
"invoices": Array [],
"invoicesSearchText": "",
}
`;
exports[`reducers invoiceReducer should correctly setInvoice 1`] = `
Object {
"data": Object {},
"formInvoice": Object {
"amount": "0",
"payreq": "",
"r_hash": "",
},
"invoice": "foo",
"invoiceLoading": false,
"invoices": Array [],
"invoicesSearchText": "",
}
`;
exports[`reducers invoiceReducer should handle initial state 1`] = `
Object {
"data": Object {},
"formInvoice": Object {
"amount": "0",
"payreq": "",
"r_hash": "",
},
"invoice": null,
"invoiceLoading": false,
"invoices": Array [],
"invoicesSearchText": "",
}
`;

46
test/reducers/__snapshots__/payment.spec.js.snap

@ -0,0 +1,46 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`reducers paymentReducer should correctly getPayments 1`] = `
Object {
"payment": null,
"paymentLoading": true,
"payments": Array [],
}
`;
exports[`reducers paymentReducer should correctly paymentSuccessful 1`] = `
Object {
"payment": null,
"paymentLoading": false,
"payments": Array [
"foo",
],
}
`;
exports[`reducers paymentReducer should correctly receivePayments 1`] = `
Object {
"payment": null,
"paymentLoading": false,
"payments": Array [
1,
2,
],
}
`;
exports[`reducers paymentReducer should correctly sendPayment 1`] = `
Object {
"payment": "foo",
"paymentLoading": false,
"payments": Array [],
}
`;
exports[`reducers paymentReducer should handle initial state 1`] = `
Object {
"payment": null,
"paymentLoading": false,
"payments": Array [],
}
`;

2
test/reducers/invoice.spec.js

@ -9,7 +9,7 @@ import invoiceReducer, {
SEND_INVOICE,
INVOICE_SUCCESSFUL,
INVOICE_FAILED
} from '../../app/reducers/info'
} from '../../app/reducers/invoice'
describe('reducers', () => {
describe('invoiceReducer', () => {

52
test/reducers/payment.spec.js

@ -0,0 +1,52 @@
import paymentReducer, {
SET_PAYMENT,
GET_PAYMENTS,
RECEIVE_PAYMENTS,
SEND_PAYMENT,
PAYMENT_SUCCESSFULL,
PAYMENT_FAILED
} from '../../app/reducers/payment'
describe('reducers', () => {
describe('paymentReducer', () => {
it('should handle initial state', () => {
expect(paymentReducer(undefined, {})).toMatchSnapshot()
})
it('should have SET_PAYMENT', () => {
expect(SET_PAYMENT).toEqual('SET_PAYMENT')
})
it('should have RECEIVE_PAYMENTS', () => {
expect(RECEIVE_PAYMENTS).toEqual('RECEIVE_PAYMENTS')
})
it('should have SEND_PAYMENT', () => {
expect(SEND_PAYMENT).toEqual('SEND_PAYMENT')
})
it('should have PAYMENT_SUCCESSFULL', () => {
expect(PAYMENT_SUCCESSFULL).toEqual('PAYMENT_SUCCESSFULL')
})
it('should have PAYMENT_FAILED', () => {
expect(PAYMENT_FAILED).toEqual('PAYMENT_FAILED')
})
it('should correctly sendPayment', () => {
expect(paymentReducer(undefined, { type: SET_PAYMENT, payment: 'foo' })).toMatchSnapshot()
})
it('should correctly getPayments', () => {
expect(paymentReducer(undefined, { type: GET_PAYMENTS })).toMatchSnapshot()
})
it('should correctly receivePayments', () => {
expect(paymentReducer(undefined, { type: RECEIVE_PAYMENTS, payments: [1, 2] })).toMatchSnapshot()
})
it('should correctly paymentSuccessful', () => {
expect(paymentReducer(undefined, { type: PAYMENT_SUCCESSFULL, payment: 'foo' })).toMatchSnapshot()
})
})
})
Loading…
Cancel
Save