0
0
mirror of https://github.com/renovatebot/renovate.git synced 2024-12-22 13:38:32 +00:00
renovatebot_renovate/lib/util/json-writer/json-writer.spec.ts
RahulGautamSingh c93154bd24
refactor: enums to unions (#18747)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2022-11-05 09:12:03 +00:00

40 lines
988 B
TypeScript

import { JSONWriter } from './json-writer';
describe('util/json-writer/json-writer', () => {
const DATA = {
value: 1,
};
it('should apply 2 spaces indentation by default', () => {
const jsonWriter = new JSONWriter();
expect(jsonWriter.write(DATA)).toBe('{\n "value": 1\n}\n');
});
it('should apply indentation size', () => {
const jsonWriter = new JSONWriter({
indentationType: 'space',
indentationSize: 10,
});
expect(jsonWriter.write(DATA)).toBe('{\n "value": 1\n}\n');
});
it('should apply indentation type', () => {
const jsonWriter = new JSONWriter({
indentationType: 'tab',
});
expect(jsonWriter.write(DATA)).toBe('{\n\t"value": 1\n}\n');
});
it('new line at the end should be optional', () => {
const jsonWriter = new JSONWriter({
indentationType: 'space',
indentationSize: 10,
});
expect(jsonWriter.write(DATA, false)).toBe('{\n "value": 1\n}');
});
});