serverless/test/unit/lib/classes/ConfigSchemaHandler/resolveDataPathSize.test.js
Piotr Grzesik d1c656838f
fix(Config Schema): Revert to ajv v6 (#8762)
This reverts commit 036698ca5b46dc27a2844114813812a83f64813e
and 1af73bacdf01e5dc855da59387ab36085b2b78a1.
2021-01-14 19:11:11 +01:00

19 lines
960 B
JavaScript

'use strict';
const { expect } = require('chai');
const resolveDataPathSize = require('../../../../../lib/classes/ConfigSchemaHandler/resolveDataPathSize');
describe('#resolveDataPathSize', () => {
it('should count root property as 1', () => expect(resolveDataPathSize('.foo'), 1));
it('should recognize all deep litera properties', () =>
expect(resolveDataPathSize('.foo.bar.mar'), 3));
it('should recognize string property', () => expect(resolveDataPathSize(".foo['bar']"), 2));
it('should recognize multiple string property', () =>
expect(resolveDataPathSize(".foo['bar']['or']"), 3));
it('should recognize numeric property', () => expect(resolveDataPathSize('.foo[1]'), 2));
it('should recognize multiple numeric properties', () =>
expect(resolveDataPathSize('.foo[1][2]'), 3));
it('should recognize mixed multiple property notations', () =>
expect(resolveDataPathSize(".foo[1]['2'].elo['3'].bar[2].foo['2'][3]"), 10));
});