Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
[evaluateXPathToString('@role', variable).substr(1)]: getFile(
(cwd ? cwd + '/' : '') + evaluateXPathToString('@file', variable)
)
}),
{}
);
// Params area also variables. But different
evaluateXPathToNodes('param', environmentNode).forEach(paramNode => {
variables[evaluateXPathToString('@name', paramNode)] = evaluateXPath(
evaluateXPathToString('@select', paramNode)
);
console.log(variables);
});
const namespaces = evaluateXPathToMap(
'(namespace!map:entry(@prefix/string(), @uri/string())) => map:merge()',
environmentNode
);
return {
contextNode: fileName ? getFile((cwd ? cwd + '/' : '') + fileName) : null,
variables,
namespaceResolver: Object.keys(namespaces).length ? prefix => namespaces[prefix] : null
};
}
it('returns all the preceding nodes', () => {
const result = evaluateXPathToMap(
`
let $dom := <element>
</element>
it('returns all the preceding nodes', () => {
const result = evaluateXPathToMap(
`
let $dom := <element>
</element>
it('can parse json objects', () =>
chai.assert.deepEqual(
evaluateXPathToMap('parse-json("{""a"": 1}")', documentNode, domFacade),
{ a: 1 }
));
it('does nothing if the key is not present', () =>
chai.assert.deepEqual(evaluateXPathToMap('map:remove(map{"a":1}, "b")', documentNode), {
a: 1
}));
it('replaces the old value', () =>
chai.assert.deepEqual(
evaluateXPathToMap('map{"a": 1} => map:put("a", 2)', documentNode),
{ a: 2 }
));
() => chai.assert.isOk(evaluateXPathToMap('map {"a": 1, "b":2}', documentNode)), 'It should be able to be parsed');
() => chai.assert.deepEqual(evaluateXPathToMap('map {*: 1}', documentNode), { 'A piece of text': 1 }));
chai.assert.throws(() => evaluateXPathToMap('map{1:(2,3)}'), 'Serialization error');
});
async function getXQueries(directory, testName) {
const testDirectory = path.join(baseDir, directory);
const testFilePath = path.join(testDirectory, testName) + '.xml';
if (!testFs.existsSync(testFilePath)) {
return null;
}
const xml = sync(await testFs.readFile(testFilePath));
const xQueries = evaluateXPathToMap(
'(/descendant::test-case/map:entry(@name, (test/@file/string(), test/string())[1])) => map:merge()',
xml
);
for (const key of Object.keys(xQueries)) {
const value = xQueries[key];
if (value.substring(value.length - 3) === '.xq') {
const xQueryPath = path.join(testDirectory, value);
if (testFs.existsSync(xQueryPath)) {
xQueries[key] = normalizeEndOfLines(await testFs.readFile(xQueryPath));
} else {
xQueries[key] = null;
}
} else {
xQueries[key] = normalizeEndOfLines(value);