2019-07-25 06:17:19 +00:00
|
|
|
import { readFileSync } from 'fs';
|
2020-02-05 00:14:31 +00:00
|
|
|
import { updateDependency } from './update';
|
2018-06-14 09:15:52 +00:00
|
|
|
|
2019-07-25 06:17:19 +00:00
|
|
|
const csProj = readFileSync(
|
2020-02-11 05:08:10 +00:00
|
|
|
'lib/manager/nuget/__fixtures__/sample.csproj',
|
2019-03-11 15:50:10 +00:00
|
|
|
'utf8'
|
|
|
|
);
|
2018-06-14 09:15:52 +00:00
|
|
|
|
|
|
|
describe('manager/nuget/update', () => {
|
|
|
|
describe('updateDependency', () => {
|
2019-12-18 07:38:20 +00:00
|
|
|
it('replaces simple value', () => {
|
2018-06-14 09:15:52 +00:00
|
|
|
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',
|
|
|
|
};
|
2020-02-06 13:01:21 +00:00
|
|
|
const res = updateDependency({ fileContent: csProj, upgrade });
|
2018-06-14 09:15:52 +00:00
|
|
|
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',
|
|
|
|
};
|
2020-02-06 13:01:21 +00:00
|
|
|
res = updateDependency({ fileContent: res, upgrade });
|
2019-12-18 07:38:20 +00:00
|
|
|
}
|
|
|
|
expect(res).toMatchSnapshot();
|
|
|
|
});
|
2018-06-14 09:15:52 +00:00
|
|
|
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',
|
|
|
|
};
|
2020-02-06 13:01:21 +00:00
|
|
|
const res = updateDependency({ fileContent: csProj, upgrade });
|
2018-06-14 09:15:52 +00:00
|
|
|
expect(res).toEqual(csProj);
|
|
|
|
});
|
|
|
|
it('returns null on errors', () => {
|
2020-02-06 13:01:21 +00:00
|
|
|
const res = updateDependency({
|
|
|
|
fileContent: csProj,
|
|
|
|
upgrade: null,
|
|
|
|
});
|
2019-04-02 14:59:27 +00:00
|
|
|
expect(res).toBeNull();
|
2018-06-14 09:15:52 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|