-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresource_serializer.test.js
More file actions
57 lines (57 loc) · 1.63 KB
/
resource_serializer.test.js
File metadata and controls
57 lines (57 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const { expect } = require('chai')
const { ResourceSerializer } = require('../lib/jsonld_serializers')
const esResponse = require('./fixtures/item-filter-aggregations.json')
describe('Resource Serializer', () => {
describe('formatformat', () => {
it('should format properly', () => {
expect(ResourceSerializer.getFormattedFormat('a')).to.deep.equal([{ '@id': 'a', prefLabel: 'Book/Text' }])
})
})
describe('.formatItemFilterAggregations()', () => {
let aggregationsFormatted
before(() => {
const aggs = esResponse.aggregations
aggregationsFormatted = ResourceSerializer.formatItemFilterAggregations(aggs)
})
it('should return an array', () => {
expect(aggregationsFormatted).to.be.an('array')
})
it('should format properly', () => {
expect(aggregationsFormatted).to.deep.equal([
{
'@type': 'nypl:Aggregation',
'@id': 'res:location',
id: 'location',
field: 'location',
values: [
{
value: 'loc:maf92',
count: 1,
label: 'Schwarzman Building M2 - Dorot Jewish Division Room 111'
}
]
},
{
'@type': 'nypl:Aggregation',
'@id': 'res:format',
id: 'format',
field: 'format',
values: []
},
{
'@type': 'nypl:Aggregation',
'@id': 'res:status',
id: 'status',
field: 'status',
values: [
{
value: 'status:a',
count: 1,
label: 'Available'
}
]
}
])
})
})
})