Skip to content

Commit

Permalink
Unit tests for filters (#940)
Browse files Browse the repository at this point in the history
* update user roles update window

* final tweaks

* syncing with origin

* added filterValidation tests

* finished tests for bountyHeaderLanguageFilter, bountyHeaderFilter functions

* prettier

* bug fix

* fixed a/t/t test

* test: fixed test to pass

* fix: no new yarn.lock

---------

Co-authored-by: kevkevin <oapallikunnel@gmail.com>
  • Loading branch information
cosmicpotato137 and kevkevinpal authored Nov 15, 2023
1 parent ca1c253 commit 01b20d3
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
50 changes: 50 additions & 0 deletions frontend/app/src/people/utils/__tests__/filterValidation.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { bountyHeaderFilter, bountyHeaderLanguageFilter } from '../filterValidation';

describe('testing filters', () => {
describe('bountyHeaderFilter', () => {
test('o/t/t', () => {
expect(bountyHeaderFilter({ Open: true }, true, true)).toEqual(false);
});
test('a/t/t', () => {
expect(bountyHeaderFilter({ Assigned: true }, true, true)).toEqual(false);
});
test('p/t/t', () => {
expect(bountyHeaderFilter({ Paid: true }, true, true)).toEqual(true);
});
test('/t/t', () => {
expect(bountyHeaderFilter({}, true, true)).toEqual(true);
});
test('o/f/t', () => {
expect(bountyHeaderFilter({ Open: true }, false, true)).toEqual(false);
});
test('a/f/t', () => {
expect(bountyHeaderFilter({ Assigned: true }, false, true)).toEqual(true);
});
test('p/f/t', () => {
expect(bountyHeaderFilter({ Paid: true }, false, true)).toEqual(false);
});
});
describe('bountyHeaderLanguageFilter', () => {
test('match', () => {
expect(bountyHeaderLanguageFilter(['Javascript', 'Python'], { Javascript: true })).toEqual(
false
);
});
test('no-match', () => {
expect(
bountyHeaderLanguageFilter(['Javascript'], { Python: true, Javascript: false })
).toEqual(false);
});
test('no filters', () => {
expect(bountyHeaderLanguageFilter(['Javascript'], {})).toEqual(true);
});
test('no languages', () => {
expect(bountyHeaderLanguageFilter([], { Javascript: true })).toEqual(false);
});
test('false filters', () => {
expect(
bountyHeaderLanguageFilter(['Javascript'], { Javascript: false, Python: false })
).toEqual(true);
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import WidgetViewer from '../WidgetSwitchViewer';
import { uiStore } from '../../../store/ui';
// import crypto from 'crypto';
// import moment from 'moment';

beforeAll(() => {});

afterAll(() => {});

describe('testing helpers', () => {});

0 comments on commit 01b20d3

Please sign in to comment.