Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed getFilter function to descern between '3_d' and '3_m' #216

Merged
merged 3 commits into from
Oct 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/modules/mhct-lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,10 @@ function getFilter(tester) {
if (!tester)
return;
tester = `${tester}`;
if (tester.startsWith('3'))
if (tester.startsWith('3_d') || tester.startsWith('3d'))
tester = '3_days';
else if (tester.startsWith('3_m') || tester.startsWith('3m'))
tester = '3_months';
else if (tester.startsWith('all'))
tester = 'alltime';
else if (tester === 'current') {
Expand Down
6 changes: 4 additions & 2 deletions tests/modules/mhct-lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ test('getFilter', suite => {
});
suite.test('given string input - returns known shortcuts', t => {
const inputs = [
{ input: '3', expected: '3_days' },
{ input: '3day', expected: '3_days' },
{ input: '3_d', expected: '3_days' },
{ input: '3days', expected: '3_days' },
{ input: '3_m', expected: '3_months' },
{ input: '3months', expected: '3_months' },
{ input: 'all', expected: 'alltime' },
{ input: 'allowance', expected: 'alltime' },
{ input: 'current', expected: '1_month' }, //NOTE this can only be asserted because we don't load the filter list
Expand Down