@tomgiee/tsdp 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -39
- package/dist/src/builder/media-builder.d.ts.map +1 -1
- package/dist/src/builder/media-builder.js +5 -12
- package/dist/src/builder/session-builder.d.ts.map +1 -1
- package/dist/src/builder/session-builder.js +4 -14
- package/dist/src/index.d.ts +6 -10
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +37 -49
- package/dist/src/parser/core.d.ts +366 -0
- package/dist/src/parser/core.d.ts.map +1 -0
- package/dist/src/parser/core.js +802 -0
- package/dist/src/parser/field-parser.d.ts +51 -8
- package/dist/src/parser/field-parser.d.ts.map +1 -1
- package/dist/src/parser/field-parser.js +91 -23
- package/dist/src/parser/media-parser.d.ts +1 -1
- package/dist/src/parser/media-parser.d.ts.map +1 -1
- package/dist/src/parser/media-parser.js +9 -15
- package/dist/src/parser/session-parser.d.ts.map +1 -1
- package/dist/src/parser/session-parser.js +16 -17
- package/dist/src/parser/time-parser.d.ts +1 -1
- package/dist/src/parser/time-parser.d.ts.map +1 -1
- package/dist/src/parser/time-parser.js +8 -8
- package/dist/src/serializer/fields.d.ts +167 -0
- package/dist/src/serializer/fields.d.ts.map +1 -0
- package/dist/src/serializer/fields.js +320 -0
- package/dist/src/serializer/media-serializer.js +6 -7
- package/dist/src/serializer/session-serializer.js +13 -15
- package/dist/src/types/attributes.d.ts.map +1 -1
- package/dist/src/types/fields.d.ts +5 -5
- package/dist/src/types/fields.d.ts.map +1 -1
- package/dist/src/types/fields.js +4 -4
- package/dist/src/types/media.d.ts +9 -10
- package/dist/src/types/media.d.ts.map +1 -1
- package/dist/src/types/media.js +2 -4
- package/dist/src/types/network.d.ts +15 -56
- package/dist/src/types/network.d.ts.map +1 -1
- package/dist/src/types/network.js +3 -34
- package/dist/src/types/primitives.d.ts +3 -147
- package/dist/src/types/primitives.d.ts.map +1 -1
- package/dist/src/types/primitives.js +2 -171
- package/dist/src/types/session.d.ts +14 -14
- package/dist/src/types/session.d.ts.map +1 -1
- package/dist/src/types/time.d.ts +4 -4
- package/dist/src/types/time.d.ts.map +1 -1
- package/dist/src/types/time.js +8 -6
- package/dist/src/utils/address-parser.d.ts +4 -4
- package/dist/src/utils/address-parser.d.ts.map +1 -1
- package/dist/src/utils/address-parser.js +9 -16
- package/dist/src/validator/validator.d.ts +94 -0
- package/dist/src/validator/validator.d.ts.map +1 -0
- package/dist/src/validator/validator.js +573 -0
- package/dist/tests/unit/parser/attribute-parser.test.js +106 -107
- package/dist/tests/unit/parser/field-parser.test.js +66 -66
- package/dist/tests/unit/parser/media-parser.test.js +38 -38
- package/dist/tests/unit/parser/primitive-parser.test.js +89 -90
- package/dist/tests/unit/parser/scanner.test.js +32 -32
- package/dist/tests/unit/parser/time-parser.test.js +22 -22
- package/dist/tests/unit/serializer/attribute-serializer.test.js +22 -22
- package/dist/tests/unit/serializer/field-serializer.test.js +57 -57
- package/dist/tests/unit/serializer/media-serializer.test.js +5 -6
- package/dist/tests/unit/serializer/session-serializer.test.js +24 -24
- package/dist/tests/unit/serializer/time-serializer.test.js +16 -16
- package/dist/tests/unit/types/network.test.js +21 -56
- package/dist/tests/unit/types/primitives.test.js +0 -39
- package/dist/tests/unit/validator/media-validator.test.js +34 -35
- package/dist/tests/unit/validator/semantic-validator.test.js +36 -37
- package/dist/tests/unit/validator/session-validator.test.js +54 -54
- package/package.json +1 -1
|
@@ -3,317 +3,316 @@
|
|
|
3
3
|
* Tests for attribute-parser.ts
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
7
|
-
const attribute_parser_1 = require("../../../src/parser/attribute-parser");
|
|
6
|
+
const core_1 = require("../../../src/parser/core");
|
|
8
7
|
const errors_1 = require("../../../src/types/errors");
|
|
9
8
|
describe('attribute-parser', () => {
|
|
10
9
|
describe('parseAttributeField', () => {
|
|
11
10
|
describe('property attributes', () => {
|
|
12
11
|
it('should parse recvonly attribute', () => {
|
|
13
|
-
const scanner = new
|
|
14
|
-
const attr = (0,
|
|
12
|
+
const scanner = new core_1.Scanner('recvonly');
|
|
13
|
+
const attr = (0, core_1.parseAttributeField)(scanner);
|
|
15
14
|
expect(attr.kind).toBe('property');
|
|
16
15
|
expect(attr.name).toBe('recvonly');
|
|
17
16
|
});
|
|
18
17
|
it('should parse sendrecv attribute', () => {
|
|
19
|
-
const scanner = new
|
|
20
|
-
const attr = (0,
|
|
18
|
+
const scanner = new core_1.Scanner('sendrecv');
|
|
19
|
+
const attr = (0, core_1.parseAttributeField)(scanner);
|
|
21
20
|
expect(attr.kind).toBe('property');
|
|
22
21
|
expect(attr.name).toBe('sendrecv');
|
|
23
22
|
});
|
|
24
23
|
it('should parse sendonly attribute', () => {
|
|
25
|
-
const scanner = new
|
|
26
|
-
const attr = (0,
|
|
24
|
+
const scanner = new core_1.Scanner('sendonly');
|
|
25
|
+
const attr = (0, core_1.parseAttributeField)(scanner);
|
|
27
26
|
expect(attr.kind).toBe('property');
|
|
28
27
|
expect(attr.name).toBe('sendonly');
|
|
29
28
|
});
|
|
30
29
|
it('should parse inactive attribute', () => {
|
|
31
|
-
const scanner = new
|
|
32
|
-
const attr = (0,
|
|
30
|
+
const scanner = new core_1.Scanner('inactive');
|
|
31
|
+
const attr = (0, core_1.parseAttributeField)(scanner);
|
|
33
32
|
expect(attr.kind).toBe('property');
|
|
34
33
|
expect(attr.name).toBe('inactive');
|
|
35
34
|
});
|
|
36
35
|
it('should parse custom property attribute', () => {
|
|
37
|
-
const scanner = new
|
|
38
|
-
const attr = (0,
|
|
36
|
+
const scanner = new core_1.Scanner('myattr');
|
|
37
|
+
const attr = (0, core_1.parseAttributeField)(scanner);
|
|
39
38
|
expect(attr.kind).toBe('property');
|
|
40
39
|
expect(attr.name).toBe('myattr');
|
|
41
40
|
});
|
|
42
41
|
});
|
|
43
42
|
describe('value attributes', () => {
|
|
44
43
|
it('should parse rtpmap attribute', () => {
|
|
45
|
-
const scanner = new
|
|
46
|
-
const attr = (0,
|
|
44
|
+
const scanner = new core_1.Scanner('rtpmap:0 PCMU/8000');
|
|
45
|
+
const attr = (0, core_1.parseAttributeField)(scanner);
|
|
47
46
|
expect(attr.kind).toBe('value');
|
|
48
47
|
expect(attr.name).toBe('rtpmap');
|
|
49
48
|
expect(attr.value).toBe('0 PCMU/8000');
|
|
50
49
|
});
|
|
51
50
|
it('should parse fmtp attribute', () => {
|
|
52
|
-
const scanner = new
|
|
53
|
-
const attr = (0,
|
|
51
|
+
const scanner = new core_1.Scanner('fmtp:96 profile-level-id=42e01f');
|
|
52
|
+
const attr = (0, core_1.parseAttributeField)(scanner);
|
|
54
53
|
expect(attr.kind).toBe('value');
|
|
55
54
|
expect(attr.name).toBe('fmtp');
|
|
56
55
|
expect(attr.value).toBe('96 profile-level-id=42e01f');
|
|
57
56
|
});
|
|
58
57
|
it('should parse ptime attribute', () => {
|
|
59
|
-
const scanner = new
|
|
60
|
-
const attr = (0,
|
|
58
|
+
const scanner = new core_1.Scanner('ptime:20');
|
|
59
|
+
const attr = (0, core_1.parseAttributeField)(scanner);
|
|
61
60
|
expect(attr.kind).toBe('value');
|
|
62
61
|
expect(attr.name).toBe('ptime');
|
|
63
62
|
expect(attr.value).toBe('20');
|
|
64
63
|
});
|
|
65
64
|
it('should parse maxptime attribute', () => {
|
|
66
|
-
const scanner = new
|
|
67
|
-
const attr = (0,
|
|
65
|
+
const scanner = new core_1.Scanner('maxptime:150');
|
|
66
|
+
const attr = (0, core_1.parseAttributeField)(scanner);
|
|
68
67
|
expect(attr.kind).toBe('value');
|
|
69
68
|
expect(attr.name).toBe('maxptime');
|
|
70
69
|
expect(attr.value).toBe('150');
|
|
71
70
|
});
|
|
72
71
|
it('should parse cat attribute', () => {
|
|
73
|
-
const scanner = new
|
|
74
|
-
const attr = (0,
|
|
72
|
+
const scanner = new core_1.Scanner('cat:conference');
|
|
73
|
+
const attr = (0, core_1.parseAttributeField)(scanner);
|
|
75
74
|
expect(attr.kind).toBe('value');
|
|
76
75
|
expect(attr.name).toBe('cat');
|
|
77
76
|
expect(attr.value).toBe('conference');
|
|
78
77
|
});
|
|
79
78
|
it('should parse keywds attribute', () => {
|
|
80
|
-
const scanner = new
|
|
81
|
-
const attr = (0,
|
|
79
|
+
const scanner = new core_1.Scanner('keywds:audio,video,meeting');
|
|
80
|
+
const attr = (0, core_1.parseAttributeField)(scanner);
|
|
82
81
|
expect(attr.kind).toBe('value');
|
|
83
82
|
expect(attr.name).toBe('keywds');
|
|
84
83
|
expect(attr.value).toBe('audio,video,meeting');
|
|
85
84
|
});
|
|
86
85
|
it('should parse tool attribute', () => {
|
|
87
|
-
const scanner = new
|
|
88
|
-
const attr = (0,
|
|
86
|
+
const scanner = new core_1.Scanner('tool:my-sdp-tool v1.0');
|
|
87
|
+
const attr = (0, core_1.parseAttributeField)(scanner);
|
|
89
88
|
expect(attr.kind).toBe('value');
|
|
90
89
|
expect(attr.name).toBe('tool');
|
|
91
90
|
expect(attr.value).toBe('my-sdp-tool v1.0');
|
|
92
91
|
});
|
|
93
92
|
it('should parse orient attribute', () => {
|
|
94
|
-
const scanner = new
|
|
95
|
-
const attr = (0,
|
|
93
|
+
const scanner = new core_1.Scanner('orient:landscape');
|
|
94
|
+
const attr = (0, core_1.parseAttributeField)(scanner);
|
|
96
95
|
expect(attr.kind).toBe('value');
|
|
97
96
|
expect(attr.name).toBe('orient');
|
|
98
97
|
expect(attr.value).toBe('landscape');
|
|
99
98
|
});
|
|
100
99
|
it('should parse type attribute', () => {
|
|
101
|
-
const scanner = new
|
|
102
|
-
const attr = (0,
|
|
100
|
+
const scanner = new core_1.Scanner('type:broadcast');
|
|
101
|
+
const attr = (0, core_1.parseAttributeField)(scanner);
|
|
103
102
|
expect(attr.kind).toBe('value');
|
|
104
103
|
expect(attr.name).toBe('type');
|
|
105
104
|
expect(attr.value).toBe('broadcast');
|
|
106
105
|
});
|
|
107
106
|
it('should parse charset attribute', () => {
|
|
108
|
-
const scanner = new
|
|
109
|
-
const attr = (0,
|
|
107
|
+
const scanner = new core_1.Scanner('charset:UTF-8');
|
|
108
|
+
const attr = (0, core_1.parseAttributeField)(scanner);
|
|
110
109
|
expect(attr.kind).toBe('value');
|
|
111
110
|
expect(attr.name).toBe('charset');
|
|
112
111
|
expect(attr.value).toBe('UTF-8');
|
|
113
112
|
});
|
|
114
113
|
it('should parse sdplang attribute', () => {
|
|
115
|
-
const scanner = new
|
|
116
|
-
const attr = (0,
|
|
114
|
+
const scanner = new core_1.Scanner('sdplang:en-US');
|
|
115
|
+
const attr = (0, core_1.parseAttributeField)(scanner);
|
|
117
116
|
expect(attr.kind).toBe('value');
|
|
118
117
|
expect(attr.name).toBe('sdplang');
|
|
119
118
|
expect(attr.value).toBe('en-US');
|
|
120
119
|
});
|
|
121
120
|
it('should parse lang attribute', () => {
|
|
122
|
-
const scanner = new
|
|
123
|
-
const attr = (0,
|
|
121
|
+
const scanner = new core_1.Scanner('lang:fr');
|
|
122
|
+
const attr = (0, core_1.parseAttributeField)(scanner);
|
|
124
123
|
expect(attr.kind).toBe('value');
|
|
125
124
|
expect(attr.name).toBe('lang');
|
|
126
125
|
expect(attr.value).toBe('fr');
|
|
127
126
|
});
|
|
128
127
|
it('should parse framerate attribute', () => {
|
|
129
|
-
const scanner = new
|
|
130
|
-
const attr = (0,
|
|
128
|
+
const scanner = new core_1.Scanner('framerate:29.97');
|
|
129
|
+
const attr = (0, core_1.parseAttributeField)(scanner);
|
|
131
130
|
expect(attr.kind).toBe('value');
|
|
132
131
|
expect(attr.name).toBe('framerate');
|
|
133
132
|
expect(attr.value).toBe('29.97');
|
|
134
133
|
});
|
|
135
134
|
it('should parse quality attribute', () => {
|
|
136
|
-
const scanner = new
|
|
137
|
-
const attr = (0,
|
|
135
|
+
const scanner = new core_1.Scanner('quality:8');
|
|
136
|
+
const attr = (0, core_1.parseAttributeField)(scanner);
|
|
138
137
|
expect(attr.kind).toBe('value');
|
|
139
138
|
expect(attr.name).toBe('quality');
|
|
140
139
|
expect(attr.value).toBe('8');
|
|
141
140
|
});
|
|
142
141
|
it('should parse custom value attribute', () => {
|
|
143
|
-
const scanner = new
|
|
144
|
-
const attr = (0,
|
|
142
|
+
const scanner = new core_1.Scanner('customattr:customvalue');
|
|
143
|
+
const attr = (0, core_1.parseAttributeField)(scanner);
|
|
145
144
|
expect(attr.kind).toBe('value');
|
|
146
145
|
expect(attr.name).toBe('customattr');
|
|
147
146
|
expect(attr.value).toBe('customvalue');
|
|
148
147
|
});
|
|
149
148
|
it('should parse value with colons', () => {
|
|
150
|
-
const scanner = new
|
|
151
|
-
const attr = (0,
|
|
149
|
+
const scanner = new core_1.Scanner('candidate:1 1 UDP 2130706431 192.168.1.1 8998 typ host');
|
|
150
|
+
const attr = (0, core_1.parseAttributeField)(scanner);
|
|
152
151
|
expect(attr.kind).toBe('value');
|
|
153
152
|
expect(attr.name).toBe('candidate');
|
|
154
153
|
expect(attr.value).toBe('1 1 UDP 2130706431 192.168.1.1 8998 typ host');
|
|
155
154
|
});
|
|
156
155
|
it('should stop at newline', () => {
|
|
157
|
-
const scanner = new
|
|
158
|
-
const attr = (0,
|
|
156
|
+
const scanner = new core_1.Scanner('rtpmap:0 PCMU/8000\r\n');
|
|
157
|
+
const attr = (0, core_1.parseAttributeField)(scanner);
|
|
159
158
|
expect(attr.value).toBe('0 PCMU/8000');
|
|
160
159
|
});
|
|
161
160
|
});
|
|
162
161
|
});
|
|
163
162
|
describe('parseRtpmapValue', () => {
|
|
164
163
|
it('should parse basic rtpmap', () => {
|
|
165
|
-
const rtpmap = (0,
|
|
164
|
+
const rtpmap = (0, core_1.parseRtpmapValue)('0 PCMU/8000');
|
|
166
165
|
expect(rtpmap.payloadType).toBe(0);
|
|
167
166
|
expect(rtpmap.encodingName).toBe('PCMU');
|
|
168
167
|
expect(rtpmap.clockRate).toBe(8000);
|
|
169
168
|
expect(rtpmap.encodingParams).toBeUndefined();
|
|
170
169
|
});
|
|
171
170
|
it('should parse rtpmap with encoding params', () => {
|
|
172
|
-
const rtpmap = (0,
|
|
171
|
+
const rtpmap = (0, core_1.parseRtpmapValue)('97 L16/8000/2');
|
|
173
172
|
expect(rtpmap.payloadType).toBe(97);
|
|
174
173
|
expect(rtpmap.encodingName).toBe('L16');
|
|
175
174
|
expect(rtpmap.clockRate).toBe(8000);
|
|
176
175
|
expect(rtpmap.encodingParams).toBe(2);
|
|
177
176
|
});
|
|
178
177
|
it('should parse video rtpmap', () => {
|
|
179
|
-
const rtpmap = (0,
|
|
178
|
+
const rtpmap = (0, core_1.parseRtpmapValue)('96 H264/90000');
|
|
180
179
|
expect(rtpmap.payloadType).toBe(96);
|
|
181
180
|
expect(rtpmap.encodingName).toBe('H264');
|
|
182
181
|
expect(rtpmap.clockRate).toBe(90000);
|
|
183
182
|
});
|
|
184
183
|
it('should parse PCMA rtpmap', () => {
|
|
185
|
-
const rtpmap = (0,
|
|
184
|
+
const rtpmap = (0, core_1.parseRtpmapValue)('8 PCMA/8000');
|
|
186
185
|
expect(rtpmap.payloadType).toBe(8);
|
|
187
186
|
expect(rtpmap.encodingName).toBe('PCMA');
|
|
188
187
|
expect(rtpmap.clockRate).toBe(8000);
|
|
189
188
|
});
|
|
190
189
|
it('should parse telephone-event rtpmap', () => {
|
|
191
|
-
const rtpmap = (0,
|
|
190
|
+
const rtpmap = (0, core_1.parseRtpmapValue)('101 telephone-event/8000');
|
|
192
191
|
expect(rtpmap.payloadType).toBe(101);
|
|
193
192
|
expect(rtpmap.encodingName).toBe('telephone-event');
|
|
194
193
|
expect(rtpmap.clockRate).toBe(8000);
|
|
195
194
|
});
|
|
196
195
|
it('should throw for invalid payload type', () => {
|
|
197
|
-
expect(() => (0,
|
|
198
|
-
expect(() => (0,
|
|
196
|
+
expect(() => (0, core_1.parseRtpmapValue)('abc PCMU/8000')).toThrow(errors_1.ParseError);
|
|
197
|
+
expect(() => (0, core_1.parseRtpmapValue)('abc PCMU/8000')).toThrow('Invalid payload type');
|
|
199
198
|
});
|
|
200
199
|
it('should throw for payload type out of range', () => {
|
|
201
|
-
expect(() => (0,
|
|
202
|
-
expect(() => (0,
|
|
200
|
+
expect(() => (0, core_1.parseRtpmapValue)('128 PCMU/8000')).toThrow(errors_1.ParseError);
|
|
201
|
+
expect(() => (0, core_1.parseRtpmapValue)('-1 PCMU/8000')).toThrow(errors_1.ParseError);
|
|
203
202
|
});
|
|
204
203
|
it('should throw for missing encoding spec', () => {
|
|
205
|
-
expect(() => (0,
|
|
206
|
-
expect(() => (0,
|
|
204
|
+
expect(() => (0, core_1.parseRtpmapValue)('96')).toThrow(errors_1.ParseError);
|
|
205
|
+
expect(() => (0, core_1.parseRtpmapValue)('96')).toThrow('Invalid rtpmap format');
|
|
207
206
|
});
|
|
208
207
|
it('should throw for invalid encoding spec', () => {
|
|
209
|
-
expect(() => (0,
|
|
210
|
-
expect(() => (0,
|
|
208
|
+
expect(() => (0, core_1.parseRtpmapValue)('96 H264')).toThrow(errors_1.ParseError);
|
|
209
|
+
expect(() => (0, core_1.parseRtpmapValue)('96 H264')).toThrow('Invalid encoding spec');
|
|
211
210
|
});
|
|
212
211
|
it('should throw for invalid clock rate', () => {
|
|
213
|
-
expect(() => (0,
|
|
214
|
-
expect(() => (0,
|
|
212
|
+
expect(() => (0, core_1.parseRtpmapValue)('96 H264/abc')).toThrow(errors_1.ParseError);
|
|
213
|
+
expect(() => (0, core_1.parseRtpmapValue)('96 H264/0')).toThrow('Invalid clock rate');
|
|
215
214
|
});
|
|
216
215
|
it('should throw for invalid encoding params', () => {
|
|
217
|
-
expect(() => (0,
|
|
218
|
-
expect(() => (0,
|
|
216
|
+
expect(() => (0, core_1.parseRtpmapValue)('97 L16/8000/abc')).toThrow(errors_1.ParseError);
|
|
217
|
+
expect(() => (0, core_1.parseRtpmapValue)('97 L16/8000/0')).toThrow('Invalid encoding parameters');
|
|
219
218
|
});
|
|
220
219
|
});
|
|
221
220
|
describe('parseFmtpValue', () => {
|
|
222
221
|
it('should parse fmtp with profile', () => {
|
|
223
|
-
const fmtp = (0,
|
|
222
|
+
const fmtp = (0, core_1.parseFmtpValue)('96 profile-level-id=42e01f');
|
|
224
223
|
expect(fmtp.format).toBe('96');
|
|
225
224
|
expect(fmtp.parameters).toBe('profile-level-id=42e01f');
|
|
226
225
|
});
|
|
227
226
|
it('should parse fmtp with multiple parameters', () => {
|
|
228
|
-
const fmtp = (0,
|
|
227
|
+
const fmtp = (0, core_1.parseFmtpValue)('96 profile-level-id=42e01f;packetization-mode=1');
|
|
229
228
|
expect(fmtp.format).toBe('96');
|
|
230
229
|
expect(fmtp.parameters).toBe('profile-level-id=42e01f;packetization-mode=1');
|
|
231
230
|
});
|
|
232
231
|
it('should parse fmtp with apt', () => {
|
|
233
|
-
const fmtp = (0,
|
|
232
|
+
const fmtp = (0, core_1.parseFmtpValue)('97 apt=96');
|
|
234
233
|
expect(fmtp.format).toBe('97');
|
|
235
234
|
expect(fmtp.parameters).toBe('apt=96');
|
|
236
235
|
});
|
|
237
236
|
it('should parse telephone-event fmtp', () => {
|
|
238
|
-
const fmtp = (0,
|
|
237
|
+
const fmtp = (0, core_1.parseFmtpValue)('101 0-15');
|
|
239
238
|
expect(fmtp.format).toBe('101');
|
|
240
239
|
expect(fmtp.parameters).toBe('0-15');
|
|
241
240
|
});
|
|
242
241
|
it('should throw for missing parameters', () => {
|
|
243
|
-
expect(() => (0,
|
|
244
|
-
expect(() => (0,
|
|
242
|
+
expect(() => (0, core_1.parseFmtpValue)('96')).toThrow(errors_1.ParseError);
|
|
243
|
+
expect(() => (0, core_1.parseFmtpValue)('96')).toThrow('Invalid fmtp format');
|
|
245
244
|
});
|
|
246
245
|
it('should throw for empty parameters', () => {
|
|
247
|
-
expect(() => (0,
|
|
248
|
-
expect(() => (0,
|
|
246
|
+
expect(() => (0, core_1.parseFmtpValue)('96 ')).toThrow(errors_1.ParseError);
|
|
247
|
+
expect(() => (0, core_1.parseFmtpValue)('96 ')).toThrow('parameters cannot be empty');
|
|
249
248
|
});
|
|
250
249
|
});
|
|
251
250
|
describe('parsePtimeValue', () => {
|
|
252
251
|
it('should parse valid integer ptime', () => {
|
|
253
|
-
expect((0,
|
|
254
|
-
expect((0,
|
|
255
|
-
expect((0,
|
|
252
|
+
expect((0, core_1.parsePtimeValue)('20')).toBe(20);
|
|
253
|
+
expect((0, core_1.parsePtimeValue)('30')).toBe(30);
|
|
254
|
+
expect((0, core_1.parsePtimeValue)('60')).toBe(60);
|
|
256
255
|
});
|
|
257
256
|
it('should parse valid decimal ptime (RFC 8866 non-zero-int-or-real)', () => {
|
|
258
|
-
expect((0,
|
|
259
|
-
expect((0,
|
|
260
|
-
expect((0,
|
|
261
|
-
expect((0,
|
|
257
|
+
expect((0, core_1.parsePtimeValue)('20.5')).toBeCloseTo(20.5, 2);
|
|
258
|
+
expect((0, core_1.parsePtimeValue)('30.0')).toBeCloseTo(30.0, 2);
|
|
259
|
+
expect((0, core_1.parsePtimeValue)('0.5')).toBeCloseTo(0.5, 2);
|
|
260
|
+
expect((0, core_1.parsePtimeValue)('100.125')).toBeCloseTo(100.125, 3);
|
|
262
261
|
});
|
|
263
262
|
it('should throw for invalid ptime', () => {
|
|
264
|
-
expect(() => (0,
|
|
265
|
-
expect(() => (0,
|
|
266
|
-
expect(() => (0,
|
|
267
|
-
expect(() => (0,
|
|
263
|
+
expect(() => (0, core_1.parsePtimeValue)('abc')).toThrow(errors_1.ParseError);
|
|
264
|
+
expect(() => (0, core_1.parsePtimeValue)('0')).toThrow('must be positive');
|
|
265
|
+
expect(() => (0, core_1.parsePtimeValue)('-10')).toThrow('must be positive');
|
|
266
|
+
expect(() => (0, core_1.parsePtimeValue)('-0.5')).toThrow('must be positive');
|
|
268
267
|
});
|
|
269
268
|
});
|
|
270
269
|
describe('parseMaxptimeValue', () => {
|
|
271
270
|
it('should parse valid integer maxptime', () => {
|
|
272
|
-
expect((0,
|
|
273
|
-
expect((0,
|
|
271
|
+
expect((0, core_1.parseMaxptimeValue)('150')).toBe(150);
|
|
272
|
+
expect((0, core_1.parseMaxptimeValue)('200')).toBe(200);
|
|
274
273
|
});
|
|
275
274
|
it('should parse valid decimal maxptime (RFC 8866 non-zero-int-or-real)', () => {
|
|
276
|
-
expect((0,
|
|
277
|
-
expect((0,
|
|
278
|
-
expect((0,
|
|
279
|
-
expect((0,
|
|
275
|
+
expect((0, core_1.parseMaxptimeValue)('150.5')).toBeCloseTo(150.5, 2);
|
|
276
|
+
expect((0, core_1.parseMaxptimeValue)('200.0')).toBeCloseTo(200.0, 2);
|
|
277
|
+
expect((0, core_1.parseMaxptimeValue)('0.5')).toBeCloseTo(0.5, 2);
|
|
278
|
+
expect((0, core_1.parseMaxptimeValue)('100.125')).toBeCloseTo(100.125, 3);
|
|
280
279
|
});
|
|
281
280
|
it('should throw for invalid maxptime', () => {
|
|
282
|
-
expect(() => (0,
|
|
283
|
-
expect(() => (0,
|
|
284
|
-
expect(() => (0,
|
|
285
|
-
expect(() => (0,
|
|
281
|
+
expect(() => (0, core_1.parseMaxptimeValue)('abc')).toThrow(errors_1.ParseError);
|
|
282
|
+
expect(() => (0, core_1.parseMaxptimeValue)('0')).toThrow('must be positive');
|
|
283
|
+
expect(() => (0, core_1.parseMaxptimeValue)('-10')).toThrow('must be positive');
|
|
284
|
+
expect(() => (0, core_1.parseMaxptimeValue)('-0.5')).toThrow('must be positive');
|
|
286
285
|
});
|
|
287
286
|
});
|
|
288
287
|
describe('parseFramerateValue', () => {
|
|
289
288
|
it('should parse integer framerate', () => {
|
|
290
|
-
expect((0,
|
|
291
|
-
expect((0,
|
|
289
|
+
expect((0, core_1.parseFramerateValue)('30')).toBe(30);
|
|
290
|
+
expect((0, core_1.parseFramerateValue)('60')).toBe(60);
|
|
292
291
|
});
|
|
293
292
|
it('should parse decimal framerate', () => {
|
|
294
|
-
expect((0,
|
|
295
|
-
expect((0,
|
|
293
|
+
expect((0, core_1.parseFramerateValue)('29.97')).toBeCloseTo(29.97, 2);
|
|
294
|
+
expect((0, core_1.parseFramerateValue)('23.976')).toBeCloseTo(23.976, 3);
|
|
296
295
|
});
|
|
297
296
|
it('should throw for invalid framerate', () => {
|
|
298
|
-
expect(() => (0,
|
|
299
|
-
expect(() => (0,
|
|
300
|
-
expect(() => (0,
|
|
297
|
+
expect(() => (0, core_1.parseFramerateValue)('abc')).toThrow(errors_1.ParseError);
|
|
298
|
+
expect(() => (0, core_1.parseFramerateValue)('0')).toThrow('must be positive');
|
|
299
|
+
expect(() => (0, core_1.parseFramerateValue)('-30')).toThrow('must be positive');
|
|
301
300
|
});
|
|
302
301
|
});
|
|
303
302
|
describe('parseQualityValue', () => {
|
|
304
303
|
it('should parse valid quality values', () => {
|
|
305
|
-
expect((0,
|
|
306
|
-
expect((0,
|
|
307
|
-
expect((0,
|
|
304
|
+
expect((0, core_1.parseQualityValue)('0')).toBe(0);
|
|
305
|
+
expect((0, core_1.parseQualityValue)('5')).toBe(5);
|
|
306
|
+
expect((0, core_1.parseQualityValue)('10')).toBe(10);
|
|
308
307
|
});
|
|
309
308
|
it('should throw for quality out of range', () => {
|
|
310
|
-
expect(() => (0,
|
|
311
|
-
expect(() => (0,
|
|
312
|
-
expect(() => (0,
|
|
313
|
-
expect(() => (0,
|
|
309
|
+
expect(() => (0, core_1.parseQualityValue)('-1')).toThrow(errors_1.ParseError);
|
|
310
|
+
expect(() => (0, core_1.parseQualityValue)('-1')).toThrow('must be 0-10');
|
|
311
|
+
expect(() => (0, core_1.parseQualityValue)('11')).toThrow(errors_1.ParseError);
|
|
312
|
+
expect(() => (0, core_1.parseQualityValue)('11')).toThrow('must be 0-10');
|
|
314
313
|
});
|
|
315
314
|
it('should throw for invalid quality', () => {
|
|
316
|
-
expect(() => (0,
|
|
315
|
+
expect(() => (0, core_1.parseQualityValue)('abc')).toThrow(errors_1.ParseError);
|
|
317
316
|
});
|
|
318
317
|
});
|
|
319
318
|
});
|