-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #417 from NYPL/NOREF-item-status-aggregation-bug
Fix bug incorporating offsites in item status agg
- Loading branch information
Showing
4 changed files
with
69 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const { expect } = require('chai') | ||
const sinon = require('sinon') | ||
|
||
const esClient = require('../lib/elasticsearch/client') | ||
|
||
describe('Elasticsearch Client', () => { | ||
describe('nonRecapItemStatusAggregation', () => { | ||
beforeEach(() => { | ||
// We expect these tests to trigger an ES query to retrieve aggregated | ||
// non-reap-statuses for the bib: | ||
sinon.stub(esClient, 'search') | ||
.callsFake(() => { | ||
return Promise.resolve(require('./fixtures/es-response-b1234-just-non-recap-statuses.json')) | ||
}) | ||
}) | ||
|
||
afterEach(() => esClient.search.restore()) | ||
|
||
it('retrieves item status aggregation', async () => { | ||
const resp = await esClient.nonRecapItemStatusAggregation('b1234') | ||
|
||
expect(resp).to.be.a('array') | ||
expect(resp).to.deep.equal([ | ||
{ key: 'status:a||Available', doc_count: 2 } | ||
]) | ||
}) | ||
}) | ||
}) |
54 changes: 26 additions & 28 deletions
54
test/fixtures/es-response-b1234-just-non-recap-statuses.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters