Skip to content

Commit 008fb47

Browse files
address comments from first round of spec review
1 parent 6053e83 commit 008fb47

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

test/manual/search-index-management.prose.test.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,23 @@ describe('Index Management Prose Tests', function () {
3838
let timeoutController: TimeoutController;
3939
let collection: Collection;
4040

41-
/** creates a readable stream that emits every \<interval\> ms */
42-
const interval = (interval: number, signal: AbortSignal) =>
43-
Readable.from(setInterval(interval, undefined, { signal, ref: false }));
44-
4541
/**
4642
* waits until the search indexes for `collection` satisfy `predicate`, optionally pre-filtering
4743
* for indexes with name = `indexName`
4844
*/
49-
const waitForIndexes = ({
45+
function waitForIndexes({
5046
predicate,
5147
indexName
5248
}: {
5349
predicate: (arg0: Array<Document>) => boolean;
5450
indexName?: string;
55-
}): Promise<Array<Document>> =>
56-
interval(5000, timeoutController.signal)
51+
}): Promise<Array<Document>> {
52+
return Readable.from(
53+
setInterval(5000, undefined, { signal: timeoutController.signal, ref: false })
54+
)
5755
.map(() => collection.listSearchIndexes(indexName).toArray())
5856
.find(predicate);
57+
}
5958

6059
before(function () {
6160
this.configuration = this.configuration.makeAtlasTestConfiguration();
@@ -87,13 +86,15 @@ describe('Index Management Prose Tests', function () {
8786
'Case 1: Driver can successfully create and list search indexes',
8887
metadata,
8988
async function () {
90-
await collection.createSearchIndex({
89+
const name = await collection.createSearchIndex({
9190
name: 'test-search-index',
9291
definition: {
9392
mappings: { dynamic: false }
9493
}
9594
});
9695

96+
expect(name).to.equal('test-search-index');
97+
9798
const [index] = await waitForIndexes({
9899
predicate: indexes => indexes.every(index => index.queryable),
99100
indexName: 'test-search-index'
@@ -125,7 +126,8 @@ describe('Index Management Prose Tests', function () {
125126
}
126127
];
127128

128-
await collection.createSearchIndexes(indexDefinitions);
129+
const names = await collection.createSearchIndexes(indexDefinitions);
130+
expect(names).to.deep.equal(['test-search-index-1', 'test-search-index-2']);
129131

130132
const indexes = await waitForIndexes({
131133
predicate: indexes => indexes.every(index => index.queryable)
@@ -143,13 +145,15 @@ describe('Index Management Prose Tests', function () {
143145
);
144146

145147
it('Case 3: Driver can successfully drop search indexes', metadata, async function () {
146-
await collection.createSearchIndex({
148+
const name = await collection.createSearchIndex({
147149
name: 'test-search-index',
148150
definition: {
149151
mappings: { dynamic: false }
150152
}
151153
});
152154

155+
expect(name).to.equal('test-search-index');
156+
153157
await waitForIndexes({
154158
predicate: indexes => indexes.every(index => index.queryable),
155159
indexName: 'test-search-index'
@@ -166,13 +170,15 @@ describe('Index Management Prose Tests', function () {
166170
});
167171

168172
it('Case 4: Driver can update a search index', metadata, async function () {
169-
await collection.createSearchIndex({
173+
const name = await collection.createSearchIndex({
170174
name: 'test-search-index',
171175
definition: {
172176
mappings: { dynamic: false }
173177
}
174178
});
175179

180+
expect(name).to.equal('test-search-index');
181+
176182
await waitForIndexes({
177183
predicate: indexes => indexes.every(index => index.queryable),
178184
indexName: 'test-search-index'

0 commit comments

Comments
 (0)