renovate/lib/manager/maven/extract.spec.ts
2020-11-12 21:46:08 +01:00

34 lines
1 KiB
TypeScript

/* eslint-disable no-template-curly-in-string */
import { readFileSync } from 'fs';
import { resolve } from 'upath';
import { extractPackage } from './extract';
const minimumContent = readFileSync(
resolve(__dirname, `./__fixtures__/minimum.pom.xml`),
'utf8'
);
const simpleContent = readFileSync(
resolve(__dirname, `./__fixtures__/simple.pom.xml`),
'utf8'
);
describe('manager/maven/extract', () => {
describe('extractDependencies', () => {
it('returns null for invalid XML', () => {
expect(extractPackage(undefined)).toBeNull();
expect(extractPackage('invalid xml content')).toBeNull();
expect(extractPackage('<foobar></foobar>')).toBeNull();
expect(extractPackage('<project></project>')).toBeNull();
});
it('extract dependencies from any XML position', () => {
const res = extractPackage(simpleContent);
expect(res).toMatchSnapshot();
});
it('tries minimum manifests', () => {
const res = extractPackage(minimumContent);
expect(res).toMatchSnapshot();
});
});
});