-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
schema.spec.ts
127 lines (123 loc) · 3.47 KB
/
schema.spec.ts
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import { GemMetadata, GemVersions, MarshalledVersionInfo } from './schema';
describe('modules/datasource/rubygems/schema', () => {
describe('MarshalledVersionInfo', () => {
it('parses valid input', () => {
const input = [
{ number: '1.0.0' },
{ number: '2.0.0' },
{ number: '3.0.0' },
];
const output = MarshalledVersionInfo.parse(input);
expect(output).toEqual([
{ version: '1.0.0' },
{ version: '2.0.0' },
{ version: '3.0.0' },
]);
});
});
describe('GemMetadata', () => {
it('requires only name field', () => {
const input = { name: 'foo' };
const output = GemMetadata.parse(input);
expect(output).toEqual({
packageName: 'foo',
changelogUrl: undefined,
homepage: undefined,
latestVersion: undefined,
sourceUrl: undefined,
});
});
it('parses valid input', () => {
const input = {
name: 'foo',
version: '1.0.0',
changelog_uri: 'https://example.com',
homepage_uri: 'https://example.com',
source_code_uri: 'https://example.com',
};
const output = GemMetadata.parse(input);
expect(output).toEqual({
packageName: 'foo',
latestVersion: '1.0.0',
changelogUrl: 'https://example.com',
homepage: 'https://example.com',
sourceUrl: 'https://example.com',
});
});
});
describe('GemVersions', () => {
it('parses valid input', () => {
const input = [
{
number: '1.0.0',
created_at: '2021-01-01',
platform: 'ruby',
ruby_version: '2.7.0',
rubygems_version: '3.2.0',
metadata: {
changelog_uri: 'https://example.com',
source_code_uri: 'https://example.com',
},
},
{
number: '2.0.0',
created_at: '2022-01-01',
platform: 'ruby',
ruby_version: '2.7.0',
rubygems_version: '3.2.0',
metadata: {
changelog_uri: 'https://example.com',
source_code_uri: 'https://example.com',
},
},
{
number: '3.0.0',
created_at: '2023-01-01',
platform: 'ruby',
ruby_version: '2.7.0',
rubygems_version: '3.2.0',
metadata: {
changelog_uri: 'https://example.com',
source_code_uri: 'https://example.com',
},
},
];
const output = GemVersions.parse(input);
expect(output).toEqual([
{
version: '1.0.0',
releaseTimestamp: '2021-01-01',
changelogUrl: 'https://example.com',
sourceUrl: 'https://example.com',
constraints: {
platform: ['ruby'],
ruby: ['2.7.0'],
rubygems: ['3.2.0'],
},
},
{
version: '2.0.0',
releaseTimestamp: '2022-01-01',
changelogUrl: 'https://example.com',
sourceUrl: 'https://example.com',
constraints: {
platform: ['ruby'],
ruby: ['2.7.0'],
rubygems: ['3.2.0'],
},
},
{
version: '3.0.0',
releaseTimestamp: '2023-01-01',
changelogUrl: 'https://example.com',
sourceUrl: 'https://example.com',
constraints: {
platform: ['ruby'],
ruby: ['2.7.0'],
rubygems: ['3.2.0'],
},
},
]);
});
});
});