This repository was archived by the owner on Nov 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathparseHeaderObject-test.js
66 lines (49 loc) · 1.79 KB
/
parseHeaderObject-test.js
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
const { Fury } = require('fury');
const { expect } = require('../../chai');
const parse = require('../../../../lib/parser/oas/parseHeaderObject');
const Context = require('../../../../lib/context');
const { minim: namespace } = new Fury();
describe('Header Object', () => {
let context;
beforeEach(() => {
context = new Context(namespace);
});
it('is parsed into StringElement', () => {
const header = new namespace.elements.Object({});
const result = parse(context, header);
expect(result).to.not.contain.annotations;
expect(result.length).to.equal(1);
expect(result.get(0)).to.be.instanceof(namespace.elements.String);
});
it('provides warning when header is non-object', () => {
const header = new namespace.elements.String();
const result = parse(context, header);
expect(result.length).to.equal(1);
expect(result).to.contain.warning("'Header Object' is not an object");
});
describe('disallow specific keys', () => {
it('#name', () => {
const header = new namespace.elements.Object({
name: 'dummy',
});
const result = parse(context, header);
expect(result).to.contain.warning("'Header Object' contains invalid key 'name'");
});
it('#in', () => {
const header = new namespace.elements.Object({
in: 'dummy',
});
const result = parse(context, header);
expect(result).to.contain.warning("'Header Object' contains invalid key 'in'");
});
});
describe('report unsupported keys', () => {
it('#description', () => {
const header = new namespace.elements.Object({
description: 'dummy',
});
const result = parse(context, header);
expect(result).to.contain.warning("'Header Object' contains unsupported key 'description'");
});
});
});