only one describe block on top level

This commit is contained in:
Moriz Wahl 2021-10-22 08:58:37 +02:00
parent 1e15b5d312
commit db6cea4cbd

View File

@ -4,7 +4,7 @@ import GdtTransactionList from './GdtTransactionList'
const localVue = global.localVue
const apolloMockNull = jest.fn().mockResolvedValue({
const apolloMock = jest.fn().mockResolvedValue({
data: {
listGDTEntries: {
count: 0,
@ -13,48 +13,6 @@ const apolloMockNull = jest.fn().mockResolvedValue({
},
})
const apolloMock = jest.fn().mockResolvedValue({
data: {
listGDTEntries: {
count: 4,
gdtEntries: [
{
amount: 100,
gdt: 1700,
factor: 17,
comment: '',
date: '2021-05-02T17:20:11+00:00',
gdtEntryType: GdtEntryType.FORM,
},
{
amount: 1810,
gdt: 362,
factor: 0.2,
comment: 'Dezember 20',
date: '2020-12-31T12:00:00+00:00',
gdtEntryType: GdtEntryType.GLOBAL_MODIFICATOR,
},
{
amount: 100,
gdt: 1700,
factor: 17,
comment: '',
date: '2020-05-07T17:00:00+00:00',
gdtEntryType: GdtEntryType.FORM,
},
{
amount: 100,
gdt: 110,
factor: 22,
comment: '',
date: '2020-04-10T13:28:00+00:00',
gdtEntryType: GdtEntryType.ELOPAGE_PUBLISHER,
},
],
},
},
})
const toastErrorMock = jest.fn()
const windowScrollToMock = jest.fn()
@ -82,7 +40,7 @@ describe('GdtTransactionList ', () => {
error: toastErrorMock,
},
$apollo: {
query: apolloMockNull,
query: apolloMock,
},
}
@ -100,40 +58,59 @@ describe('GdtTransactionList ', () => {
})
it('links to https://gradido.net/en/memberships/ when clicking', async () => {
const link = 'https://gradido.net/' + state.language + '/memberships/'
expect(wrapper.find('.gdt-funding').attributes('href')).toBe(link)
expect(wrapper.find('.gdt-funding').attributes('href')).toBe(
'https://gradido.net/' + state.language + '/memberships/',
)
})
})
})
describe('GdtTransactionList', () => {
let wrapper
const mocks = {
$store: {
state,
commit: jest.fn(),
},
$i18n: {
locale: 'en',
},
$t: jest.fn((t) => t),
$n: jest.fn((n) => n),
$d: jest.fn((d) => d),
$toasted: {
error: toastErrorMock,
},
$apollo: {
query: apolloMock,
},
}
const Wrapper = () => {
return mount(GdtTransactionList, { localVue, mocks })
}
describe('mount - When transactions are loaded', () => {
beforeEach(() => {
apolloMock.mockResolvedValue({
data: {
listGDTEntries: {
count: 4,
gdtEntries: [
{
id: 1,
amount: 100,
gdt: 1700,
factor: 17,
comment: '',
date: '2021-05-02T17:20:11+00:00',
gdtEntryType: GdtEntryType.FORM,
},
{
id: 2,
amount: 1810,
gdt: 362,
factor: 0.2,
comment: 'Dezember 20',
date: '2020-12-31T12:00:00+00:00',
gdtEntryType: GdtEntryType.GLOBAL_MODIFICATOR,
},
{
id: 3,
amount: 100,
gdt: 1700,
factor: 17,
comment: '',
date: '2020-05-07T17:00:00+00:00',
gdtEntryType: GdtEntryType.FORM,
},
{
id: 4,
amount: 100,
gdt: 110,
factor: 22,
comment: '',
date: '2020-04-10T13:28:00+00:00',
gdtEntryType: GdtEntryType.ELOPAGE_PUBLISHER,
},
],
},
},
})
wrapper = Wrapper()
})
@ -141,7 +118,7 @@ describe('GdtTransactionList', () => {
expect(wrapper.find('div.gdt-transaction-list').exists()).toBeTruthy()
})
it('renders the not funding button ', () => {
it('does not render the funding button ', () => {
expect(wrapper.find('.gdt-funding').exists()).toBe(false)
})