change props in tests for transaction links + zaubersprüche

This commit is contained in:
ogerly 2022-03-17 21:47:11 +01:00
parent f5b0ef2265
commit 78a1459971
4 changed files with 33 additions and 38 deletions

View File

@ -19,7 +19,7 @@ const propsData = {
createdAt: '2022-03-16T14:22:40.000Z', createdAt: '2022-03-16T14:22:40.000Z',
holdAvailableAmount: '5.13109484759482747111', holdAvailableAmount: '5.13109484759482747111',
id: 87, id: 87,
memo: 'asdasdaadsdd asd asdadss', memo: 'Eene meene Siegerpreis, vor mir steht ein Schokoeis. Hex-hex!',
redeemedAt: null, redeemedAt: null,
validUntil: '2022-03-30T14:22:40.000Z', validUntil: '2022-03-30T14:22:40.000Z',
}, },
@ -29,13 +29,15 @@ const propsData = {
createdAt: '2022-03-16T14:22:40.000Z', createdAt: '2022-03-16T14:22:40.000Z',
holdAvailableAmount: '5.13109484759482747111', holdAvailableAmount: '5.13109484759482747111',
id: 86, id: 86,
memo: 'asdasdaadsdd asd asdadss', memo: 'Eene meene buntes Laub, auf dem Schrank da liegt kein Staub.',
redeemedAt: null, redeemedAt: null,
validUntil: '2022-03-30T14:22:40.000Z', validUntil: '2022-03-30T14:22:40.000Z',
}, },
], ],
transactionLinkCount: 3, transactionLinkCount: 3,
value: { currentPage: 1, pending: false, pageSize: 5 }, value: 1,
pending: false,
pageSize: 5,
} }
describe('CollapseLinksList', () => { describe('CollapseLinksList', () => {
@ -59,9 +61,7 @@ describe('CollapseLinksList', () => {
}) })
it('emits input', () => { it('emits input', () => {
expect(wrapper.emitted('input')).toEqual([ expect(wrapper.emitted('input')).toEqual([[2]])
[{ currentPage: 2, pageSize: 5, pending: false }],
])
}) })
}) })
@ -73,9 +73,7 @@ describe('CollapseLinksList', () => {
}) })
it('emits input ', () => { it('emits input ', () => {
expect(wrapper.emitted('input')).toEqual([ expect(wrapper.emitted('input')).toEqual([[0]])
[{ currentPage: 0, pageSize: 5, pending: false }],
])
}) })
}) })
@ -83,7 +81,9 @@ describe('CollapseLinksList', () => {
describe('one more link to load', () => { describe('one more link to load', () => {
beforeEach(async () => { beforeEach(async () => {
await wrapper.setProps({ await wrapper.setProps({
value: { currentPage: 1, pending: false, pageSize: 5 }, value: 1,
pending: false,
pageSize: 5,
}) })
}) })
@ -95,7 +95,9 @@ describe('CollapseLinksList', () => {
describe('less than pageSize links to load', () => { describe('less than pageSize links to load', () => {
beforeEach(async () => { beforeEach(async () => {
await wrapper.setProps({ await wrapper.setProps({
value: { currentPage: 1, pending: false, pageSize: 5 }, value: 1,
pending: false,
pageSize: 5,
transactionLinkCount: 6, transactionLinkCount: 6,
}) })
}) })
@ -108,7 +110,9 @@ describe('CollapseLinksList', () => {
describe('more than pageSize links to load', () => { describe('more than pageSize links to load', () => {
beforeEach(async () => { beforeEach(async () => {
await wrapper.setProps({ await wrapper.setProps({
value: { currentPage: 1, pending: false, pageSize: 5 }, value: 1,
pending: false,
pageSize: 5,
transactionLinkCount: 16, transactionLinkCount: 16,
}) })
}) })

View File

@ -42,23 +42,24 @@ export default {
type: Number, type: Number,
required: true, required: true,
}, },
value: { type: Object, required: true }, value: { type: Number, required: true },
pageSize: { type: Number, default: 5 },
pending: { type: Boolean, default: false }, pending: { type: Boolean, default: false },
}, },
methods: { methods: {
resetTransactionLinkList() { resetTransactionLinkList() {
this.$emit('input', { ...this.value, currentPage: 0 }) this.$emit('input', 0)
}, },
loadMoreLinks() { loadMoreLinks() {
this.$emit('input', { ...this.value, currentPage: this.value.currentPage + 1 }) this.$emit('input', this.value + 1)
}, },
}, },
computed: { computed: {
buttonText() { buttonText() {
const i = this.transactionLinkCount - this.transactionLinks.length const i = this.transactionLinkCount - this.transactionLinks.length
if (i === 1) return this.$tc('link-load', 0) if (i === 1) return this.$tc('link-load', 0)
if (i <= this.value.pageSize) return this.$tc('link-load', 1, { n: i }) if (i <= this.pageSize) return this.$tc('link-load', 1, { n: i })
return this.$tc('link-load', 2, { n: this.value.pageSize }) return this.$tc('link-load', 2, { n: this.pageSize })
}, },
}, },
} }

View File

@ -117,11 +117,9 @@ describe('TransactionLinksSummary', () => {
beforeEach(async () => { beforeEach(async () => {
jest.clearAllMocks() jest.clearAllMocks()
await wrapper.setData({ await wrapper.setData({
variables: { currentPage: 0,
currentPage: 0, pending: false,
pending: false, pageSize: 5,
pageSize: 5,
},
}) })
}) })
@ -197,11 +195,9 @@ describe('TransactionLinksSummary', () => {
}, },
}) })
await wrapper.setData({ await wrapper.setData({
variables: { currentPage: 2,
currentPage: 2, pending: false,
pending: false, pageSize: 5,
pageSize: 5,
},
}) })
}) })

View File

@ -26,8 +26,9 @@
<b-collapse v-model="visible"> <b-collapse v-model="visible">
<collapse-links-list <collapse-links-list
v-model="variables" v-model="currentPage"
:pending="pending" :pending="pending"
:pageSize="pageSize"
:transactionLinkCount="transactionLinkCount" :transactionLinkCount="transactionLinkCount"
:transactionLinks="transactionLinks" :transactionLinks="transactionLinks"
/> />
@ -72,10 +73,8 @@ export default {
return { return {
visible: false, visible: false,
transactionLinks: [], transactionLinks: [],
variables: { currentPage: 1,
currentPage: 1, pageSize: 5,
pageSize: 5,
},
pending: false, pending: false,
} }
}, },
@ -83,7 +82,7 @@ export default {
async updateListTransactionLinks() { async updateListTransactionLinks() {
if (this.currentPage === 0) { if (this.currentPage === 0) {
this.transactionLinks = [] this.transactionLinks = []
this.variables.currentPage = 1 this.currentPage = 1
} else { } else {
this.pending = true this.pending = true
this.$apollo this.$apollo
@ -106,11 +105,6 @@ export default {
} }
}, },
}, },
computed: {
currentPage() {
return this.variables.currentPage
},
},
watch: { watch: {
currentPage() { currentPage() {
this.updateListTransactionLinks() this.updateListTransactionLinks()