Skip to content

Commit

Permalink
Add addittional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oltionchampari committed Mar 31, 2020
1 parent a6b1777 commit 942e1d2
Showing 1 changed file with 47 additions and 4 deletions.
51 changes: 47 additions & 4 deletions tests/lineup/internal/cmds.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,59 @@ describe('Serialize LineUp v4 filter for provenance graph', () => {
expect(serializeLineUpFilter(lineUpFilter)).not.toMatchObject({filter: {value: '/12345/gm', isRegExp: true}, filterMissing: false});
expect(serializeLineUpFilter(lineUpFilter)).not.toMatchObject({filter: {value: '/abc/gm', isRegExp: false}, filterMissing: false});
});

it('filter as array', () => {
const lineUpFilter = {filter: ['chromosome', 'gender'], filterMissing: false};
expect(serializeLineUpFilter(lineUpFilter)).toMatchObject({filter: {value: ['chromosome', 'gender'], isRegExp: false}, filterMissing: false});
});

it('filter as null', () => {
const lineUpFilter = {filter: null, filterMissing: false};
expect(serializeLineUpFilter(lineUpFilter)).toMatchObject({filter: {value: null, isRegExp: false}, filterMissing: false});
});

it('filter as null and use regular expression true', () => {
const lineUpFilter = {filter: /null/, filterMissing: false};
expect(serializeLineUpFilter(lineUpFilter)).toMatchObject({filter: {value: /null/, isRegExp: true}, filterMissing: false});
});
});


describe('Restore LineUp filter from provenance graph', () => {
it('filter as string', () => {
expect(restoreRegExp('abc')).toBe('abc');
expect(typeof restoreRegExp('abc')).toBe('string');
expect(restoreRegExp('abc')).toMatchObject({filter: 'abc', filterMissing: false});
expect(restoreRegExp('abc').hasOwnProperty('filterMissing')).toBeTruthy();
});

it('filter as null', () => {
expect(restoreRegExp(null)).toMatchObject({filter: null, filterMissing: false});
});

it('filter as IRegExpFilter with `value:abc`, `isRegexp:false`', () => {
expect(restoreRegExp({value: 'abc', isRegExp: false})).toMatchObject({filter: 'abc', filterMissing: false});
});

it('filter as IRegExpFilter with `value:null`, `isRegexp:false`', () => {
expect(restoreRegExp({value: null, isRegExp: false})).toMatchObject({filter: null, filterMissing: false});
});

it('filter as IRegExpFilter with `value:/^abc/gm`, `isRegexp:true`', () => {
expect(restoreRegExp({value: '/^abc/gm', isRegExp: true})).toMatchObject({filter: /^abc/gm, filterMissing: false});
});

it('filter as ISerializableLineUpFilter', () => {
const fromGraphFilter = {filter: {value: '/abc$/gm', isRegExp: true}, filterMissing: false};
expect(restoreRegExp(fromGraphFilter)).toMatchObject({filter: /abc$/gm, filterMissing: false});
});

it('filter as ISerializableLineUpFilter with property `filterMissing: true`', () => {
const fromGraphFilter = {filter: {value: '/abc$/gm', isRegExp: true}, filterMissing: true};
expect(restoreRegExp(fromGraphFilter)).toMatchObject({filter: /abc$/gm, filterMissing: true});
});

it('filter as IRegExpFilter', () => {
expect(restoreRegExp({value: '/abc/gm', isRegExp: true})).toMatchObject(/abc/gm);
it('filter as ISerializableLineUpFilter with property `value: null`', () => {
const fromGraphFilter = {filter: {value: null, isRegExp: false}, filterMissing: true};
expect(restoreRegExp(fromGraphFilter)).toMatchObject({filter: null, filterMissing: true});
});
});

0 comments on commit 942e1d2

Please sign in to comment.