From e45bbcf99e2505321fe4f9f8ee5f161b7e1f50f3 Mon Sep 17 00:00:00 2001 From: Tom Byers Date: Thu, 16 Jul 2020 16:28:59 +0100 Subject: [PATCH] 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. --- tests/javascripts/radioSelect.test.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/javascripts/radioSelect.test.js b/tests/javascripts/radioSelect.test.js index 9360486c1..abd307672 100644 --- a/tests/javascripts/radioSelect.test.js +++ b/tests/javascripts/radioSelect.test.js @@ -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();