-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathDataverseInfoRepository.test.ts
More file actions
75 lines (63 loc) · 2.54 KB
/
Copy pathDataverseInfoRepository.test.ts
File metadata and controls
75 lines (63 loc) · 2.54 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { DataverseInfoRepository } from '../../../src/info/infra/repositories/DataverseInfoRepository'
import {
ApiConfig,
DataverseApiAuthMechanism
} from '../../../src/core/infra/repositories/ApiConfig'
import { TestConstants } from '../../testHelpers/TestConstants'
import {
deleteApplicationTermsOfUseViaApi,
setApplicationTermsOfUseViaApi,
setMaxEmbargoDurationInMonthsViaApi
} from '../../testHelpers/info/infoHelper'
import { ReadError } from '../../../src/core/domain/repositories/ReadError'
describe('DataverseInfoRepository', () => {
const sut: DataverseInfoRepository = new DataverseInfoRepository()
beforeAll(async () => {
ApiConfig.init(
TestConstants.TEST_API_URL,
DataverseApiAuthMechanism.API_KEY,
process.env.TEST_API_KEY
)
})
describe('getDataverseVersion', () => {
test('should return Dataverse version', async () => {
const actual = await sut.getDataverseVersion()
expect(typeof actual.number).toBe('string')
})
})
describe('getZipDownloadLimit', () => {
test('should return zip download limit', async () => {
const actual = await sut.getZipDownloadLimit()
expect(typeof actual).toBe('number')
})
})
describe('getMaxEmbargoDurationInMonths', () => {
test('should return error when the setting does not exist', async () => {
const errorExpected: ReadError = new ReadError(
'[404] Setting :MaxEmbargoDurationInMonths not found'
)
await expect(sut.getMaxEmbargoDurationInMonths()).rejects.toThrow(errorExpected)
})
test('should return duration when the setting exists', async () => {
const testMaxEmbargoDurationInMonths = 12
await setMaxEmbargoDurationInMonthsViaApi(testMaxEmbargoDurationInMonths)
const actual = await sut.getMaxEmbargoDurationInMonths()
expect(actual).toBe(testMaxEmbargoDurationInMonths)
})
})
describe('getApplicationTermsOfUse', () => {
test('should return no terms message when terms are not set', async () => {
const defaultNoTermsOfUseMessage =
'There are no Terms of Use for this Dataverse installation.'
const actual = await sut.getApplicationTermsOfUse()
expect(actual).toBe(defaultNoTermsOfUseMessage)
})
test('should return terms when terms are set', async () => {
const testTermsOfUse = 'Be excellent to each other.'
await setApplicationTermsOfUseViaApi(testTermsOfUse)
const actual = await sut.getApplicationTermsOfUse()
expect(actual).toBe(testTermsOfUse)
await deleteApplicationTermsOfUseViaApi()
})
})
})