Skip to content

Commit

Permalink
Finish venue page unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
HappyNTH committed Sep 1, 2024
1 parent 6a9e98f commit 282fd79
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 27 deletions.
80 changes: 55 additions & 25 deletions tests/unit/pages/venues/Venue.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'vitest';

import { fixTextSpacing, mount } from '#testSupport/helpers';
import { NuxtLinkStub } from '#testSupport/stubs';
import {
GenericApolloResponse,
GenericNodeConnection
Expand All @@ -19,7 +19,8 @@ describe('Venue page', function () {
let accessibilityInfoContainer;

async function mountComponent(
addressChanges = {}
addressChanges = {},
includeAccessibilityInfo = true
) {
venuePageComponent = await mount(Venue, {
shallow: false,
Expand All @@ -31,23 +32,28 @@ describe('Venue page', function () {
queryResponses: [
GenericApolloResponse(
'venue',
FakeVenue({
address: FakeAddress(addressChanges),
productions: GenericNodeConnection([
Production({
name: 'Bins',
slug: 'bins',
isBookable: false,
end: '2020-10-18T00:00:00'
}),
Production({
name: 'Centuary',
slug: 'centuary',
isBookable: false,
end: '2019-10-19T00:00:00'
})
])
})
FakeVenue(
{
address: FakeAddress(addressChanges),
productions: GenericNodeConnection([
Production({
name: 'Bins',
slug: 'bins',
isBookable: false,
end: '2020-10-18T00:00:00'
}),
Production({
name: 'Centuary',
slug: 'centuary',
isBookable: false,
end: '2019-10-19T00:00:00'
})
])
},
undefined,
undefined,
includeAccessibilityInfo
)
)
]
},
Expand Down Expand Up @@ -133,19 +139,43 @@ describe('Venue page', function () {
});

it('displays default text if no accessibility info present', async () => {
await mountComponent(
({},
{
accessibilityInfo: null
})
);
await mountComponent(undefined, false);
console.log(accessibilityInfoContainer.text());
expect(accessibilityInfoContainer.text()).to.contain(
'No accessibility information available for this venue'
);
});
});

describe('venue production list', () => {
let links;
let table;
let tableRows;
beforeEach(() => {
table = venuePageComponent.find({ ref: 'production-list' });
tableRows = table.findAll('tr');
links = table.findAllComponents(NuxtLinkStub);
});

it('correct number of productions', () => {
expect(tableRows.length).to.equal(2);
expect(links.length).to.equal(2);
});

it('table rows have correct text', () => {
expect(tableRows.at(0).text()).to.contain('Bins');
expect(tableRows.at(0).text()).to.contain('October 2020');

expect(tableRows.at(1).text()).to.contain('Centuary');
expect(tableRows.at(1).text()).to.contain('October 2019');
});

it('has correct links', () => {
expect(links.at(0).attributes('to')).to.equal('/production/bins');
expect(links.at(1).attributes('to')).to.equal('/production/centuary');
});
});

it('checks map doesnt exist with invalid lat or long', async () => {
await mountComponent({
latitude: null
Expand Down
7 changes: 5 additions & 2 deletions tests/unit/support/fixtures/Venue.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import ProductionNode from './Production.js';
export default (
overrides = {},
includePerformance = false,
includeProduction = true
includeProduction = true,
includeAccessibilityInfo = true
) => {
return Object.assign(
{
Expand All @@ -29,7 +30,9 @@ export default (
productions: GenericConnection(
includeProduction ? [ProductionNode()] : []
),
accessibilityInfo: 'Wheelchair access available'
accessibilityInfo: includeAccessibilityInfo
? 'Wheelchair access available'
: null
},
overrides
);
Expand Down

0 comments on commit 282fd79

Please sign in to comment.