-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): format additional flags values for logging
- Loading branch information
Showing
2 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
packages/nx/src/tasks-runner/life-cycles/formatting-utils.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { formatFlags } from './formatting-utils'; | ||
|
||
describe('formatFlags', () => { | ||
it('should properly show string values', () => { | ||
expect(formatFlags('', 'myflag', 'myvalue')).toBe(' --myflag=myvalue'); | ||
}); | ||
it('should properly show number values', () => { | ||
expect(formatFlags('', 'myflag', 123)).toBe(' --myflag=123'); | ||
}); | ||
it('should properly show boolean values', () => { | ||
expect(formatFlags('', 'myflag', true)).toBe(' --myflag=true'); | ||
}); | ||
it('should properly show array values', () => { | ||
expect(formatFlags('', 'myflag', [1, 23, 'abc'])).toBe( | ||
' --myflag=[1,23,abc]' | ||
); | ||
}); | ||
it('should properly show object values', () => { | ||
expect(formatFlags('', 'myflag', { abc: 'def', ghi: { jkl: 42 } })).toBe( | ||
' --myflag={"abc":"def","ghi":{"jkl":42}}' | ||
); | ||
}); | ||
it('should not break on invalid inputs', () => { | ||
expect(formatFlags('', 'myflag', (abc) => abc)).toBe( | ||
' --myflag=(abc) => abc' | ||
); | ||
expect(formatFlags('', 'myflag', NaN)).toBe(' --myflag=NaN'); | ||
}); | ||
it('should decompose positional values', () => { | ||
expect(formatFlags('', '_', ['foo', 'bar', 42, 'baz'])).toBe( | ||
' foo bar 42 baz' | ||
); | ||
}); | ||
it('should handle indentation', () => { | ||
expect(formatFlags('_____', 'myflag', 'myvalue')).toBe( | ||
'_____ --myflag=myvalue' | ||
); | ||
}); | ||
it('should handle indentation with positionals', () => { | ||
expect(formatFlags('_____', '_', ['foo', 'bar', 42, 'baz'])).toBe( | ||
'_____ foo bar 42 baz' | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters