Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
ae62cb39
Commit
ae62cb39
authored
Mar 15, 2021
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a more comprehensive test of `search_after` query param
parent
c336a814
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
4 deletions
+40
-4
search-client-test.js
src/sidebar/test/search-client-test.js
+40
-4
No files found.
src/sidebar/test/search-client-test.js
View file @
ae62cb39
...
@@ -11,10 +11,12 @@ function delay(ms) {
...
@@ -11,10 +11,12 @@ function delay(ms) {
}
}
const
RESULTS
=
[
const
RESULTS
=
[
{
id
:
'one'
,
created
:
'2020-01-01'
,
updated
:
'2020-01-01'
},
// nb. `created` and `updated` dates are in opposite order and different months
{
id
:
'two'
,
created
:
'2020-01-02'
,
updated
:
'2020-01-02'
},
// to make it easy to check in tests that correct field was used for searching/sorting.
{
id
:
'three'
,
created
:
'2020-01-03'
,
updated
:
'2020-01-03'
},
{
id
:
'one'
,
created
:
'2020-01-01'
,
updated
:
'2020-02-04'
},
{
id
:
'four'
,
created
:
'2020-01-04'
,
updated
:
'2020-01-04'
},
{
id
:
'two'
,
created
:
'2020-01-02'
,
updated
:
'2020-02-03'
},
{
id
:
'three'
,
created
:
'2020-01-03'
,
updated
:
'2020-02-02'
},
{
id
:
'four'
,
created
:
'2020-01-04'
,
updated
:
'2020-02-01'
},
];
];
/**
/**
...
@@ -258,4 +260,38 @@ describe('SearchClient', () => {
...
@@ -258,4 +260,38 @@ describe('SearchClient', () => {
assert
.
equal
(
params
.
sort
,
'updated'
);
assert
.
equal
(
params
.
sort
,
'updated'
);
assert
.
equal
(
params
.
order
,
'desc'
);
assert
.
equal
(
params
.
order
,
'desc'
);
});
});
[
{
sortBy
:
'updated'
,
sortOrder
:
'desc'
,
expectedSearchAfter
:
[
undefined
,
'2020-02-03'
,
'2020-02-01'
],
},
{
sortBy
:
'updated'
,
sortOrder
:
'asc'
,
expectedSearchAfter
:
[
undefined
,
'2020-02-02'
,
'2020-02-04'
],
},
{
sortBy
:
'created'
,
sortOrder
:
'desc'
,
expectedSearchAfter
:
[
undefined
,
'2020-01-03'
,
'2020-01-01'
],
},
].
forEach
(({
sortBy
,
sortOrder
,
expectedSearchAfter
})
=>
{
it
(
'sets correct "search_after" query parameter depending on `sortBy` and `sortOrder`'
,
async
()
=>
{
const
client
=
new
SearchClient
(
fakeSearchFn
,
{
chunkSize
:
2
,
sortBy
,
sortOrder
,
});
client
.
get
({
uri
:
'http://example.com'
});
await
awaitEvent
(
client
,
'end'
);
const
searchAfterParams
=
fakeSearchFn
.
getCalls
()
.
map
(
call
=>
call
.
args
[
0
].
search_after
);
assert
.
deepEqual
(
searchAfterParams
,
expectedSearchAfter
);
});
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment