Skip to content

Commit

Permalink
Merge pull request #8 from twin-te/search-codes
Browse files Browse the repository at this point in the history
検索クエリ修正
  • Loading branch information
SIY1121 authored Apr 3, 2022
2 parents b08674c + bff1165 commit 9acaa17
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions __tests__/usecase/searchCourse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,33 @@ test('不正なlimit', () => {
).rejects.toThrow(InvalidArgumentError)
})

test('キーワード指定&科目番号指定&時間割', async () => {
const res = await searchCourseUseCase({
year: 2020,
keywords: ['科学'],
codes: ['FF'],
timetable: {
FallA: {
Thu: [false, true, false, false, false, false, false, false, false],
},
FallB: {
Thu: [false, true, false, false, false, false, false, false, false],
},
FallC: {
Thu: [false, true, false, false, false, false, false, false, false],
},
},
searchMode: SearchMode.Contain,
offset: 0,
limit: 30,
})
expect(res.length > 0).toBe(true)
expect(res.length <= 30).toBe(true)
res.forEach((c) =>
expect(c.name.includes('科学') && c.code.startsWith('FF')).toBe(true)
)
})

test('時間割 contain1', async () => {
const res = await searchCourseUseCase({
year: 2020,
Expand Down
2 changes: 1 addition & 1 deletion src/usecase/searchCourse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const keywordCodeQuery = (keywords: string[], codes: string[]): string => {
ifstr(codes.length > 0, 'courses.code ~* :codes'),
]
.filter(notNull)
.join('and')
.join(' and ')

// 最後に()で囲んでandを足す
// 出力例 (courses.name ~* :names and courses.code ~* :codes) and
Expand Down

0 comments on commit 9acaa17

Please sign in to comment.