renovate/lib/manager/nuget/update.spec.ts

47 lines
1.3 KiB
TypeScript
Raw Normal View History

import { readFileSync } from 'fs';
import { updateDependency } from './update';
const csProj = readFileSync(
'lib/manager/nuget/__fixtures__/sample.csproj',
'utf8'
);
describe('manager/nuget/update', () => {
describe('updateDependency', () => {
2019-12-18 07:38:20 +00:00
it('replaces simple value', () => {
const upgrade = {
2019-07-22 07:40:22 +00:00
managerData: { lineNumber: 13 },
newVersion: '5.0.0',
};
const res = updateDependency({ fileContent: csProj, upgrade });
expect(res).not.toEqual(csProj);
});
2019-12-18 07:38:20 +00:00
it('replaces left boundary value', () => {
let res = csProj;
for (let i = 24; i <= 26; i += 1) {
const upgrade = {
managerData: { lineNumber: i },
newVersion: i + '.2.1',
};
res = updateDependency({ fileContent: res, upgrade });
2019-12-18 07:38:20 +00:00
}
expect(res).toMatchSnapshot();
});
it('keeps intact when same version', () => {
const upgrade = {
2019-07-22 07:40:22 +00:00
managerData: { lineNumber: 13 },
newVersion: '4.1.0',
};
const res = updateDependency({ fileContent: csProj, upgrade });
expect(res).toEqual(csProj);
});
it('returns null on errors', () => {
const res = updateDependency({
fileContent: csProj,
upgrade: null,
});
expect(res).toBeNull();
});
});
});