Skip to content

Commit

Permalink
Add text search to campOfficeNotes & editableInfo and test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ritvje authored and googol committed Jul 17, 2016
1 parent bf4c1f8 commit d332676
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/common/models/participant.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export default function (Participant) {

or.push({ staffPosition: { regexp: `/${stripRegex(string)}/i` } });
or.push({ staffPositionInGenerator: { regexp: `/${stripRegex(string)}/i` } });
or.push({ campOfficeNotes: { regexp: `/${stripRegex(string)}/i` } });
or.push({ editableInfo: { regexp: `/${stripRegex(string)}/i` } });

const splitted = string.split(' ', 2);

Expand Down
16 changes: 16 additions & 0 deletions test/text-search.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ describe('Text search', () => {
'memberNumber': 123,
'staffPosition': null,
'staffPositionInGenerator': 'Tiskari',
'editableInfo': 'Muokattava teksti',
},
{
'participantId': 2,
Expand All @@ -42,6 +43,7 @@ describe('Text search', () => {
'memberNumber': 345,
'staffPosition': 'Jumppaohjaaja',
'staffPositionInGenerator': null,
'campOfficeNotes': 'Leiritoimiston jutut',
},
{
'participantId': 3,
Expand Down Expand Up @@ -189,4 +191,18 @@ describe('Text search', () => {
})
);

it('Query with camp office notes', () =>
queryParticipants({ 'textSearch':'Leiritoimisto' }, accessToken)
.then(res => {
expectParticipants([ 'Tero' ], res.body);
})
);

it('Query with editable info', () =>
queryParticipants({ 'textSearch':'Muokattava' }, accessToken)
.then(res => {
expectParticipants([ 'Teemu' ], res.body);
})
);

});

0 comments on commit d332676

Please sign in to comment.