Files
renovate/lib/util/toml.spec.ts
Gregor Zeitlinger 2e951d2254 feat(mise): support selector lockfile updates (#44615)
* mise: support selector lockfile updates

* fix(mise): handle empty lockfile AST

* test(mise): use valid empty TOML AST fixture

* fix(mise): support current regex utility

* fix: clarify lockfile-only lookup handling

* fix(mise): handle selector lockfile updates correctly

* test(mise): cover selector lockfile review fixes

* fix(mise): scope selector artifact refresh

* chore: retrigger CI

* fix(mise): remove unreachable lockfile guard

* refactor(lookup): clarify lockfile-only value handling

* refactor(mise): use shared TOML utilities

* fix(mise): handle selector lockfile edge cases

* fix(mise): satisfy selector CI coverage

* fix(mise): require dependency names

* fix(mise): preserve configured dependency names

* fix(mise): address selector lockfile review feedback

* test(mise): cover major selector lockfile updates

* chore(static-data): auto-update Java LTS versions

So we don't have a hardcoded set of data in the mise manager.

Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>

* fix(mise): address selector lockfile feedback

* test(manager/mise): cover nonnumeric current version prefix

formatLockedVersion()'s currentPrefix fallback to '' only runs when
the current version has no leading numeric match, which no existing
test reached.

Co-Authored-By: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>

---------

Co-authored-by: Jamie Tanna <jamie.tanna@mend.io>
Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>
2026-09-14 15:57:22 +00:00

81 lines
1.8 KiB
TypeScript

import { codeBlock } from 'common-tags';
import { massage, parseTOMLDocument, parse as parseToml } from './toml.ts';
describe('util/toml', () => {
it('exposes source ranges from the TOML AST', () => {
const document = parseTOMLDocument('[[tools.node]]\nversion = "20.11.0"\n');
expect(document.body[0].body[0]).toMatchObject({
range: [0, 34],
});
});
it('parses TOML 1.1 syntax with source ranges', () => {
const document = parseTOMLDocument(
'[[tools.node]]\nplatforms = { linux = { checksum = "abc", }, }\n',
);
expect(document.body[0].body[0]).toMatchObject({
type: 'TOMLTable',
});
});
it('works', () => {
const input = codeBlock`
[tool.poetry]
## Hello world
include = [
"README.md",
{ path = "tests", format = "sdist" }
]
`;
expect(parseToml(input)).toStrictEqual({
tool: {
poetry: {
include: ['README.md', { path: 'tests', format: 'sdist' }],
},
},
});
});
it('parses toml 1.1 syntax', () => {
const input = codeBlock`
[tool.poetry]
include = { path = "README.md", }
`;
expect(parseToml(input)).toStrictEqual({
tool: {
poetry: {
include: { path: 'README.md' },
},
},
});
});
it('handles invalid toml', () => {
const input = codeBlock`
!@#$%^&*()
`;
expect(() => parseToml(input)).toThrow(SyntaxError);
});
it('handles templates', () => {
const input = codeBlock`
[tool.poetry]
name = "{{ name }}"
{# comment #}
[tool.poetry.dependencies]
python = "^3.9"
{{ foo }} = "{{ bar }}"
{% if foo %}
dep1 = "^1.0.0"
{% endif %}
`;
expect(() => parseToml(massage(input))).not.toThrow(SyntaxError);
});
});