2019-07-25 06:17:19 +00:00
|
|
|
import { readFileSync } from 'fs';
|
|
|
|
import { updateDependency } from '../../../lib/manager/nuget/update';
|
2018-06-14 09:15:52 +00:00
|
|
|
|
2019-07-25 06:17:19 +00:00
|
|
|
const csProj = readFileSync(
|
2019-03-11 15:50:10 +00:00
|
|
|
'test/datasource/nuget/_fixtures/sample.csproj',
|
|
|
|
'utf8'
|
|
|
|
);
|
2018-06-14 09:15:52 +00:00
|
|
|
|
|
|
|
describe('manager/nuget/update', () => {
|
|
|
|
describe('updateDependency', () => {
|
|
|
|
it('replaces existing value', () => {
|
|
|
|
const upgrade = {
|
2019-07-22 07:40:22 +00:00
|
|
|
managerData: { lineNumber: 13 },
|
2018-06-14 09:15:52 +00:00
|
|
|
newVersion: '5.0.0',
|
|
|
|
};
|
2019-07-25 06:17:19 +00:00
|
|
|
const res = updateDependency(csProj, upgrade);
|
2018-06-14 09:15:52 +00:00
|
|
|
expect(res).not.toEqual(csProj);
|
|
|
|
});
|
|
|
|
it('keeps intact when same version', () => {
|
|
|
|
const upgrade = {
|
2019-07-22 07:40:22 +00:00
|
|
|
managerData: { lineNumber: 13 },
|
2018-06-14 09:15:52 +00:00
|
|
|
newVersion: '4.1.0',
|
|
|
|
};
|
2019-07-25 06:17:19 +00:00
|
|
|
const res = updateDependency(csProj, upgrade);
|
2018-06-14 09:15:52 +00:00
|
|
|
expect(res).toEqual(csProj);
|
|
|
|
});
|
|
|
|
it('returns null on errors', () => {
|
2019-07-25 06:17:19 +00:00
|
|
|
const res = updateDependency(csProj, null);
|
2019-04-02 14:59:27 +00:00
|
|
|
expect(res).toBeNull();
|
2018-06-14 09:15:52 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|