Skip to content

Commit

Permalink
Merge pull request #7 from edx/mfrank/fix-product-types-hook
Browse files Browse the repository at this point in the history
fix: product types hook
  • Loading branch information
MaxFrank13 authored Jul 6, 2023
2 parents cd51ae5 + b8e340d commit 5ad3ea2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const useProductTypes = () => {

if (search) {
// remove the "?" and split the query string at "="
const splitString = search.slice(1).split('=');
const splitString = search.slice(1).split('&')[0].split('=');

// if the key is not "product_types", use a default setting
if (splitString[0] !== 'product_types') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,14 @@ describe('useProductTypes', () => {

expect(productTypes).toEqual(['boot_camp', 'course']);
});

test('returns a filtered list if additional key-value pairs are provided in the query string', () => {
global.query_string = '?product_types=boot_camp,course&external_link=true';

const { result } = renderHook(() => useProductTypes());

const productTypes = result.current;

expect(productTypes).toEqual(['boot_camp', 'course']);
});
});

0 comments on commit 5ad3ea2

Please sign in to comment.