'use strict';

var _Table = require('./Table.component');

describe('Table.getHeaders', function () {
	it('should transform json path to key', function () {
		var headers = (0, _Table.getHeaders)(['$[\'attr\'][0][\'foo\']'], true);
		expect(headers[0]).toBe('attr[0].foo');
		expect(headers.length).toBe(1);
		expect((0, _Table.getHeaders)(['attr.foo'], true)[0]).toBe('attr.foo');
	});
});

describe('Table.getKeys', function () {
	it('should return keys of obj', function () {
		var keys = (0, _Table.getKeys)({ attr: ['foo'] });
		expect(keys[0]).toBe('attr');
		expect(keys.length).toBe(1);
	});

	it('should return flatten keys of obj', function () {
		var keys = (0, _Table.getKeys)({ attr: ['foo'] }, true);
		expect(keys[0]).toBe('$[\'attr\'][0]');
		expect(keys.length).toBe(1);
	});
});

describe('Table.getAbsolutePath', function () {
	it('should return path of obj from key', function () {
		var keys = (0, _Table.getKeys)({ attr: ['foo'] });
		var path = (0, _Table.getAbsolutePath)(0, keys[0]);
		expect(path).toBe('$[0][\'attr\']');
	});

	it('should return path of obj from key [flat]', function () {
		var keys = (0, _Table.getKeys)({ attr: ['foo'] }, true);
		var path = (0, _Table.getAbsolutePath)(0, keys[0], true);
		expect(path).toBe('$[0][\'attr\'][0]');
	});
});