1
1
import { readableFromArray , streamToString } from '../test-helpers/stream-utils' ;
2
2
import { getDataStreamDcatUs11 } from './' ;
3
3
import * as datasetFromApi from '../test-helpers/mock-dataset.json' ;
4
+ import { HEADER_V3 } from './constants/contexts' ;
4
5
5
6
async function generateDcatFeed ( dataset , template , templateTransforms ) {
6
7
const { stream : dcatStream } = getDataStreamDcatUs11 ( template , templateTransforms ) ;
@@ -10,15 +11,14 @@ async function generateDcatFeed(dataset, template, templateTransforms) {
10
11
return { feed : JSON . parse ( feedString ) } ;
11
12
}
12
13
13
- describe ( 'generating DCAT-US 1.1 feed' , ( ) => {
14
+ describe ( 'generating DCAT-US 3.0 feed' , ( ) => {
14
15
it ( 'formats catalog correctly' , async function ( ) {
15
16
const { feed } = await generateDcatFeed ( [ ] , { } , { } ) ;
16
17
17
- expect ( feed [ '@context' ] ) . toBe ( 'https://project-open-data.cio.gov/v1.1/schema/catalog.jsonld' ) ;
18
+ expect ( feed [ '@context' ] ) . toStrictEqual ( HEADER_V3 [ '@context' ] ) ;
19
+ expect ( feed [ 'conformsTo' ] ) . toBe ( 'https://resource.data.gov/profile/dcat-us#' ) ;
18
20
expect ( feed [ '@type' ] ) . toBe ( 'dcat:Catalog' ) ;
19
- expect ( feed [ 'conformsTo' ] ) . toBe ( 'https://project-open-data.cio.gov/v1.1/schema' ) ;
20
- expect ( feed [ 'describedBy' ] ) . toBe ( 'https://project-open-data.cio.gov/v1.1/schema/catalog.json' ) ;
21
- expect ( Array . isArray ( feed [ 'dataset' ] ) ) . toBeTruthy ( ) ;
21
+ expect ( Array . isArray ( feed [ 'dcat:dataset' ] ) ) . toBeTruthy ( ) ;
22
22
} ) ;
23
23
24
24
it ( 'should interprolate dataset stream to feed based upon template' , async function ( ) {
@@ -35,20 +35,23 @@ describe('generating DCAT-US 1.1 feed', () => {
35
35
'@type' : 'vcard:Contact' ,
36
36
fn : '{{owner}}' ,
37
37
hasEmail : '{{orgContactEmail:optional}}'
38
+ } ,
39
+ header : {
40
+ '@id' : 'hub.arcgis.com'
38
41
}
39
42
} , {
40
43
toISO : ( _key , val ) => {
41
44
return new Date ( val ) . toISOString ( ) ;
42
45
}
43
46
} ) ;
44
47
45
- expect ( feed [ '@context' ] ) . toBe ( 'https://project-open-data.cio.gov/v1.1/schema/catalog.jsonld' ) ;
48
+ expect ( feed [ '@context' ] ) . toStrictEqual ( HEADER_V3 [ '@context' ] ) ;
46
49
expect ( feed [ '@type' ] ) . toBe ( 'dcat:Catalog' ) ;
47
- expect ( feed [ 'conformsTo ' ] ) . toBe ( 'https://project-open-data.cio.gov/v1.1/schema ' ) ;
48
- expect ( feed [ 'describedBy ' ] ) . toBe ( 'https://project-open- data.cio. gov/v1.1/schema/catalog.json ' ) ;
49
- expect ( Array . isArray ( feed [ 'dataset' ] ) ) . toBeTruthy ( ) ;
50
- expect ( feed [ 'dataset' ] . length ) . toBe ( 1 ) ;
51
- const feedResponse = feed [ 'dataset' ] [ 0 ] ;
50
+ expect ( feed [ '@id ' ] ) . toBe ( 'hub.arcgis.com ' ) ;
51
+ expect ( feed [ 'conformsTo ' ] ) . toBe ( 'https://resource. data.gov/profile/dcat-us# ' ) ;
52
+ expect ( Array . isArray ( feed [ 'dcat: dataset' ] ) ) . toBeTruthy ( ) ;
53
+ expect ( feed [ 'dcat: dataset' ] . length ) . toBe ( 1 ) ;
54
+ const feedResponse = feed [ 'dcat: dataset' ] [ 0 ] ;
52
55
expect ( feedResponse . title ) . toBe ( 'Tahoe places of interest' ) ;
53
56
expect ( feedResponse . description ) . toBe ( 'Description. Here be Tahoe things. You can do a lot here. Here are some more words. And a few more.<div><br /></div><div>with more words</div><div><br /></div><div>adding a few more to test how long it takes for our jobs to execute.</div><div><br /></div><div>Tom was here!</div>' ) ;
54
57
expect ( feedResponse . issued ) . toBe ( '2021-01-29T15:34:38.000Z' ) ;
0 commit comments