Skip to content

test(yaml): Fix code block indents #35211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 67 additions & 67 deletions lib/util/yaml.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ describe('util/yaml', () => {
it('should parse content with single document', () => {
expect(
parseYaml(codeBlock`
myObject:
aString: value
`),
myObject:
aString: value
`),
).toEqual([
{
myObject: {
Expand All @@ -27,9 +27,9 @@ describe('util/yaml', () => {
expect(
parseYaml(
codeBlock`
myObject:
aString: value
`,
myObject:
aString: value
`,
{
customSchema: z.object({
myObject: z.object({
Expand All @@ -50,11 +50,11 @@ describe('util/yaml', () => {
it('should parse content with multiple documents', () => {
expect(
parseYaml(codeBlock`
myObject:
aString: value
---
foo: bar
`),
myObject:
aString: value
---
foo: bar
`),
).toEqual([
{
myObject: {
Expand All @@ -71,12 +71,12 @@ describe('util/yaml', () => {
expect(
parseYaml(
codeBlock`
myObject:
aString: foo
---
myObject:
aString: bar
`,
myObject:
aString: foo
---
myObject:
aString: bar
`,
{
customSchema: z.object({
myObject: z.object({
Expand All @@ -103,11 +103,11 @@ describe('util/yaml', () => {
expect(() =>
parseYaml(
codeBlock`
myObject:
aString: foo
---
aString: bar
`,
myObject:
aString: foo
---
aString: bar
`,
{
customSchema: z.object({
myObject: z.object({
Expand All @@ -123,11 +123,11 @@ describe('util/yaml', () => {
expect(() =>
parseYaml(
codeBlock`
myObject:
aString: foo
---
aString: bar
`,
myObject:
aString: foo
---
aString: bar
`,
{
customSchema: z.object({
myObject: z.object({
Expand All @@ -144,11 +144,11 @@ describe('util/yaml', () => {
expect(
parseYaml(
codeBlock`
myObject:
aString: foo
---
aString: bar
`,
myObject:
aString: foo
---
aString: bar
`,
{
customSchema: z.object({
myObject: z.object({
Expand All @@ -171,11 +171,11 @@ describe('util/yaml', () => {
expect(
parseYaml(
codeBlock`
myObject:
aString: {{ value }}
---
foo: {{ foo.bar }}
`,
myObject:
aString: {{ value }}
---
foo: {{ foo.bar }}
`,
{ removeTemplates: true },
),
).toEqual([
Expand All @@ -199,9 +199,9 @@ describe('util/yaml', () => {
it('should parse content with single document', () => {
expect(
parseSingleYaml(codeBlock`
myObject:
aString: value
`),
myObject:
aString: value
`),
).toEqual({
myObject: {
aString: 'value',
Expand All @@ -212,13 +212,13 @@ describe('util/yaml', () => {
it('should parse invalid content using strict=false', () => {
expect(
parseSingleYaml(codeBlock`
version: '2.1'
version: '2.1'

services:
rtl_433:
image: ubuntu:oracular-20240918
# inserting a space before the hash on the next line makes Renovate work.
command: "echo some text"# a comment
services:
rtl_433:
image: ubuntu:oracular-20240918
# inserting a space before the hash on the next line makes Renovate work.
command: "echo some text"# a comment
`),
).not.toBeNull();
});
Expand All @@ -227,9 +227,9 @@ services:
expect(
parseSingleYaml(
codeBlock`
myObject:
aString: value
`,
myObject:
aString: value
`,
{
customSchema: z.object({
myObject: z.object({
Expand All @@ -249,8 +249,8 @@ services:
expect(() =>
parseSingleYaml(
codeBlock`
myObject: foo
`,
myObject: foo
`,
{
customSchema: z.object({
myObject: z.object({
Expand All @@ -265,25 +265,25 @@ services:
it('should parse content with multiple documents', () => {
expect(() =>
parseSingleYaml(codeBlock`
myObject:
aString: value
---
foo: bar
`),
myObject:
aString: value
---
foo: bar
`),
).toThrow();
});

it('should parse content with template', () => {
expect(
parseSingleYaml(
codeBlock`
myObject:
aString: {{value}}
{% if test.enabled %}
myNestedObject:
aNestedString: {{value}}
{% endif %}
`,
myObject:
aString: {{value}}
{% if test.enabled %}
myNestedObject:
aNestedString: {{value}}
{% endif %}
`,
{ removeTemplates: true },
),
).toEqual({
Expand All @@ -300,10 +300,10 @@ services:
expect(
parseSingleYaml(
codeBlock`
myObject:
aString: value
aStringWithTag: !reset null
`,
myObject:
aString: value
aStringWithTag: !reset null
`,
{ removeTemplates: true },
),
).toEqual({
Expand Down