|
|
@@ -152,16 +152,16 @@ describe('getMetadata', () => {
|
|
|
const data = {
|
|
|
'@context': '/api/contexts/Foo',
|
|
|
'@id': '/api/foo',
|
|
|
- '@type': 'hydra:Collection',
|
|
|
- 'hydra:member': ['foo'],
|
|
|
- 'hydra:totalItems': 10,
|
|
|
- 'hydra:view': {
|
|
|
+ '@type': 'Collection',
|
|
|
+ 'member': ['foo'],
|
|
|
+ 'totalItems': 10,
|
|
|
+ 'view': {
|
|
|
'@id': '/api/foo?page=3',
|
|
|
- '@type': 'hydra:PartialCollectionView',
|
|
|
- 'hydra:first': '/api/foo?page=1',
|
|
|
- 'hydra:last': '/api/foo?page=5',
|
|
|
- 'hydra:next': '/api/foo?page=4',
|
|
|
- 'hydra:previous': '/api/foo?page=2',
|
|
|
+ '@type': 'PartialCollectionView',
|
|
|
+ 'first': '/api/foo?page=1',
|
|
|
+ 'last': '/api/foo?page=5',
|
|
|
+ 'next': '/api/foo?page=4',
|
|
|
+ 'previous': '/api/foo?page=2',
|
|
|
},
|
|
|
}
|
|
|
|
|
|
@@ -169,23 +169,23 @@ describe('getMetadata', () => {
|
|
|
const metadata = HydraNormalizer.getMetadata(data)
|
|
|
|
|
|
expect(metadata.totalItems).toEqual(10)
|
|
|
- expect(metadata.firstPage).toEqual(1)
|
|
|
- expect(metadata.lastPage).toEqual(5)
|
|
|
- expect(metadata.nextPage).toEqual(4)
|
|
|
- expect(metadata.previousPage).toEqual(2)
|
|
|
+ expect(metadata.first).toEqual(1)
|
|
|
+ expect(metadata.last).toEqual(5)
|
|
|
+ expect(metadata.next).toEqual(4)
|
|
|
+ expect(metadata.previous).toEqual(2)
|
|
|
expect(metadata.type).toEqual(METADATA_TYPE.COLLECTION)
|
|
|
})
|
|
|
test('With partial collection metadata', () => {
|
|
|
const data = {
|
|
|
'@context': '/api/contexts/Foo',
|
|
|
'@id': '/api/foo',
|
|
|
- '@type': 'hydra:Collection',
|
|
|
- 'hydra:member': ['foo'],
|
|
|
- 'hydra:totalItems': 10,
|
|
|
- 'hydra:view': {
|
|
|
+ '@type': 'Collection',
|
|
|
+ 'member': ['foo'],
|
|
|
+ 'totalItems': 10,
|
|
|
+ 'view': {
|
|
|
'@id': '/api/foo?page=3',
|
|
|
- '@type': 'hydra:PartialCollectionView',
|
|
|
- 'hydra:first': '/api/foo?page=1',
|
|
|
+ '@type': 'PartialCollectionView',
|
|
|
+ 'first': '/api/foo?page=1',
|
|
|
},
|
|
|
}
|
|
|
|
|
|
@@ -193,10 +193,10 @@ describe('getMetadata', () => {
|
|
|
const metadata = HydraNormalizer.getMetadata(data)
|
|
|
|
|
|
expect(metadata.totalItems).toEqual(10)
|
|
|
- expect(metadata.firstPage).toEqual(1)
|
|
|
- expect(metadata.lastPage).toEqual(1)
|
|
|
- expect(metadata.nextPage).toEqual(undefined)
|
|
|
- expect(metadata.previousPage).toEqual(undefined)
|
|
|
+ expect(metadata.first).toEqual(1)
|
|
|
+ expect(metadata.last).toEqual(1)
|
|
|
+ expect(metadata.next).toEqual(undefined)
|
|
|
+ expect(metadata.previous).toEqual(undefined)
|
|
|
})
|
|
|
|
|
|
test('With item metadata', () => {
|