0
0
Fork 0
mirror of https://github.com/renovatebot/renovate.git synced 2025-03-15 08:34:54 +00:00
renovatebot_renovate/lib/util/toml.spec.ts
Sergei Zharinov d2eb48d1a4
fix(poetry): Template keys handling (#34460)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2025-03-03 17:35:16 +00:00

47 lines
1,016 B
TypeScript

import { codeBlock } from 'common-tags';
import { massage, parse as parseToml } from './toml';
describe('util/toml', () => {
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('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);
});
});