fix: fix the getValue of yaml

1. Fix the yaml value dump in the utils
2. Update the unit test

Change-Id: I3c2120593ff533d38fdc7cb026d0d2d3bf1e7132
This commit is contained in:
Jingwei.Zhang 2022-12-19 11:46:02 +08:00
parent a307f457e4
commit f4a24d04ad
2 changed files with 6 additions and 8 deletions

View File

@ -18,8 +18,9 @@ import yaml from 'js-yaml';
export const getValue = (value) => { export const getValue = (value) => {
if (isObject(value)) { if (isObject(value)) {
try { try {
return yaml.safeDump(value, { noRefs: true }); return yaml.dump(value, { noRefs: true });
} catch (err) { } catch (err) {
console.log('yaml-dump-err', err);
return JSON.stringify(value, null, 2); return JSON.stringify(value, null, 2);
} }
} }

View File

@ -24,12 +24,9 @@ describe('test yaml', () => {
}, },
}, },
}) })
).toBe(`{ ).toBe(`level1:
"level1": { level2:
"level2": { key: value
"key": "value" `);
}
}
}`);
}); });
}); });