const {query} = require('..');
function q (description, args, result) {
it(description, () => {
expect(query(...args)).toEqual(result);
});
}
describe('query()', () => {
q('handles missing query',
[''],
[]
);
q('handles basic query',
['foobar', '//y'],
[
{inner: 'foo', outer: 'foo'},
{inner: 'bar', outer: 'bar'}
]
);
q('handles attribute query',
['foobar', '//*[@foo="bar"]'],
[
{inner: 'foo', outer: 'foo'}
]
);
it('handles invalid query', () => {
expect(() => query('there', '//[]')).toThrowError('Invalid XPath query: //[]');
});
});