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 pathparseExampleObject-test.js
71 lines (52 loc) · 2.13 KB
/
parseExampleObject-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
67
68
69
70
71
const { Fury } = require('fury');
const { expect } = require('../../chai');
const parse = require('../../../../lib/parser/oas/parseExampleObject');
const Context = require('../../../../lib/context');
const { minim: namespace } = new Fury();
describe('Example Object', () => {
let context;
beforeEach(() => {
context = new Context(namespace);
});
it('provides a warning when example is non-object', () => {
const example = new namespace.elements.String('my example');
const parseResult = parse(context, example);
expect(parseResult.length).to.equal(1);
expect(parseResult).to.contain.warning("'Example Object' is not an object");
});
it('returns an object with value', () => {
const example = new namespace.elements.Object({
value: { message: 'hello world' },
});
const parseResult = parse(context, example);
expect(parseResult.length).to.equal(1);
const object = parseResult.get(0);
expect(object).to.be.instanceof(namespace.elements.Object);
expect(object.get('value').toValue()).to.deep.equal({
message: 'hello world',
});
});
describe('warnings for unsupported properties', () => {
it('provides warning for unsupported summary key', () => {
const example = new namespace.elements.Object({
summary: 'summary',
});
const parseResult = parse(context, example);
expect(parseResult).to.contain.warning("'Example Object' contains unsupported key 'summary'");
});
it('provides warning for unsupported description key', () => {
const example = new namespace.elements.Object({
description: 'description',
});
const parseResult = parse(context, example);
expect(parseResult).to.contain.warning("'Example Object' contains unsupported key 'description'");
});
it('provides warning for unsupported externalValue key', () => {
const example = new namespace.elements.Object({
externalValue: 'externalValue',
});
const parseResult = parse(context, example);
expect(parseResult).to.contain.warning("'Example Object' contains unsupported key 'externalValue'");
});
});
});