Fix comparison of original categories with new

These tests make sure the sub-categories shown
when a category is selected are right but the
comparison looked for a direct match between the
labels for both types.

This looks for the category label in the
sub-category label instead, ie.

'Today at' in 'Today at 1pm'.

...instead of

'Today at' === 'Today at 1pm', which will always
fail.
This commit is contained in:
Tom Byers
2020-07-16 16:28:59 +01:00
committed by Chris Hill-Scott
parent 909f2d4678
commit e45bbcf99e

View File

@@ -159,10 +159,13 @@ describe('RadioSelect', () => {
describe(`clicking the button for ${category} should`, () => {
const categoryRegExp = new RegExp('^' + category);
let originalOptionsForcategory;
beforeEach(() => {
// get all the options in the original page for this category
originalOptionsForCategory = originalOptionsForAllCategories.filter(option => option.label === category);
originalOptionsForCategory = originalOptionsForAllCategories.filter(option => categoryRegExp.test(option.label));
// start module
window.GOVUK.modules.start();