Skip to content

Commit f2affcd

Browse files
committed
update tests
1 parent 2bbecc4 commit f2affcd

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

test/src/Factory.spec.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
'use strict'
2+
3+
const expect = require('chai').expect
4+
5+
const Factory = require('../../src/Factory')
6+
7+
const simpleSchema = require('../schemas/simple-one')
8+
const complexAllOfSchema = require('../schemas/complex-allOf')
9+
10+
describe('Factory', () => {
11+
beforeEach(function() {
12+
delete require.cache[require.resolve('../schemas/simple-one')];
13+
delete require.cache[require.resolve('../schemas/complex-allOf')];
14+
delete require.cache[require.resolve('../schemas/complex-anyOf')];
15+
delete require.cache[require.resolve('../schemas/complex-anyOfInline')];
16+
delete require.cache[require.resolve('../schemas/complex-items')];
17+
delete require.cache[require.resolve('../schemas/complex-not')];
18+
delete require.cache[require.resolve('../schemas/complex-notInline')];
19+
delete require.cache[require.resolve('../schemas/complex-oneOf')];
20+
delete require.cache[require.resolve('../schemas/morecomplex-oneOf')];
21+
delete require.cache[require.resolve('../schemas/complex-property')];
22+
delete require.cache[require.resolve('../schemas/complex-propertyDefinition')];
23+
});
24+
25+
describe('convert', () => {
26+
it('should produce a converted schema', function() {
27+
let expected = Factory.convert(simpleSchema)
28+
expect(expected).to.be.an('object')
29+
expect(expected).to.have.property('schemas')
30+
expect(expected.schemas).to.have.property('main')
31+
expect(expected.schemas.main).to.not.have.property('$schema')
32+
33+
expected = Factory.convert(complexAllOfSchema)
34+
expect(expected).to.be.an('object')
35+
expect(expected).to.have.property('schemas')
36+
expect(expected.schemas).to.have.property('main')
37+
expect(expected.schemas.main).to.not.have.property('$schema')
38+
expect(expected.schemas).to.have.property('message')
39+
});
40+
});
41+
});

test/src/index.spec.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
'use strict'
2+
3+
const expect = require('chai').expect
4+
5+
const Factory = require('../../index')
6+
7+
const simpleSchema = require('../schemas/simple-one')
8+
const complexAllOfSchema = require('../schemas/complex-allOf')
9+
10+
describe('Factory', () => {
11+
beforeEach(function() {
12+
delete require.cache[require.resolve('../schemas/simple-one')];
13+
delete require.cache[require.resolve('../schemas/complex-allOf')];
14+
});
15+
16+
describe('convert', () => {
17+
it('should produce a converted schema', function() {
18+
let expected = Factory.convert(simpleSchema)
19+
expect(expected).to.be.an('object')
20+
expect(expected).to.have.property('schemas')
21+
expect(expected.schemas).to.have.property('main')
22+
expect(expected.schemas.main).to.not.have.property('$schema')
23+
24+
expected = Factory.convert(complexAllOfSchema)
25+
expect(expected).to.be.an('object')
26+
expect(expected).to.have.property('schemas')
27+
expect(expected.schemas).to.have.property('main')
28+
expect(expected.schemas.main).to.not.have.property('$schema')
29+
expect(expected.schemas).to.have.property('message')
30+
});
31+
});
32+
});

0 commit comments

Comments
 (0)