-
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
41 additions
and
1 deletion.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
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,28 @@ | ||
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 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) => { | ||
console.log(abc); | ||
}) | ||
).toBe(' --myflag=(abc) => { console.log(abc); }'); | ||
expect(formatFlags('', 'myflag', NaN)).toBe(' --myflag=NaN'); | ||
}); | ||
}); |
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