-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathLinkDatasetTypeWithMetadataBlocks.test.ts
More file actions
47 lines (43 loc) · 1.44 KB
/
LinkDatasetTypeWithMetadataBlocks.test.ts
File metadata and controls
47 lines (43 loc) · 1.44 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
import { randomUUID } from 'node:crypto'
import {
ApiConfig,
DatasetType,
addDatasetType,
deleteDatasetType,
linkDatasetTypeWithMetadataBlocks
} from '../../../src'
import { DataverseApiAuthMechanism } from '../../../src/core/infra/repositories/ApiConfig'
import { TestConstants } from '../../testHelpers/TestConstants'
describe('LinkDatasetTypeWithMetadataBlocks', () => {
describe('execute', () => {
beforeAll(async () => {
ApiConfig.init(
TestConstants.TEST_API_URL,
DataverseApiAuthMechanism.API_KEY,
process.env.TEST_API_KEY
)
})
test('should allow for linking a dataset type to metadata blocks', async () => {
const randomName = `datasetType-${randomUUID().slice(0, 6)}`
const actual: DatasetType = await addDatasetType.execute({
name: randomName,
linkedMetadataBlocks: [],
availableLicenses: [],
displayName: randomName,
description: 'A dataset type created for testing purposes'
})
expect(actual.name).toEqual(randomName)
const linked: void = await linkDatasetTypeWithMetadataBlocks.execute(actual.id as number, [
'geospatial'
])
expect(linked).toEqual({
linkedMetadataBlocks: {
before: [],
after: ['geospatial']
}
})
const deleted: void = await deleteDatasetType.execute(actual.id as number)
expect(deleted).toEqual({ message: 'deleted' })
})
})
})