Skip to content

Commit 6e5768e

Browse files
authored
perf: Merge pull request #31 from DP6/schema-parse
Schema parse
2 parents b42bf16 + caaba7b commit 6e5768e

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

test/unit/schema-parser.test.js

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,42 @@ afterEach(): It’s a hook to run after each it() or describe();
1010
const { assert } = require('chai');
1111
const chai = require('chai');
1212
const expect = chai.expect;
13-
const sinon = require('sinon');
14-
15-
const parse = require('./../../schema-parser');
13+
const fs = require('fs');
1614

15+
let parse;
16+
const schemaGlobal = JSON.parse(fs.readFileSync('test/unit/schema-global.json').toString());
1717
describe('schema-parser', () => {
18+
beforeEach(() => {
19+
parse = require('./../../schema-parser');
20+
});
21+
1822
describe('#parseEvent()', () => {
1923
it('Deve ser uma function', () => {
2024
assert.isFunction(parse.parseEvent);
2125
});
26+
it('Deve transformar uma regra de validação em um evento da camada de dados', () => {
27+
let result = parse.parseEvent(schemaGlobal.array.items[0]);
28+
29+
expect(result).to.be.an('Object').that.not.null;
30+
expect(result).to.haveOwnProperty('event');
31+
expect(result.event).to.be.equal('update');
32+
expect(result.aplicacao.ambiente).to.be.equal('producao');
33+
});
2234
});
2335

2436
describe('#parseToDataLayer()', () => {
2537
it('Deve ser uma function', () => {
2638
assert.isFunction(parse.parseToDataLayer);
2739
});
40+
it('Deve transformar o schema de validação código de modelo da camada de dados', () => {
41+
let result = [];
42+
result = result.concat(parse.parseToDataLayer(schemaGlobal.array.items));
43+
44+
expect(result).to.be.an('array').that.not.empty;
45+
expect(result).to.be.an('array').that.have.lengthOf(4);
46+
expect(result[0].event).to.be.equal('update');
47+
expect(result[3].usuario.idUsuario).to.be.equal('N/A');
48+
expect(result[0].aplicacao).instanceOf(Object);
49+
});
2850
});
2951
});

0 commit comments

Comments
 (0)