A small command-line utility for inspecting the contents of package.json files.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test.js 701B

12345678910111213141516171819202122232425262728293031
  1. const assert = require('assert');
  2. const traversePath = require('./lib').traversePath;
  3. const ESCAPE_CODES = {
  4. RESET_COLOR: '\x1b[0m',
  5. FG_GREEN: '\x1b[32m',
  6. };
  7. const testCases = [
  8. {
  9. expected: 1,
  10. actual: traversePath({ a: 1 }, ['a']),
  11. },
  12. {
  13. expected: 3,
  14. actual: traversePath({ a: { b: { c: 3 } } }, ['a', 'b', 'c']),
  15. },
  16. {
  17. expected: 2,
  18. actual: traversePath({ a: [1, 2, 3] }, ['a', 1]),
  19. },
  20. ];
  21. testCases.forEach((testCase, i) => {
  22. assert.deepEqual(testCase.actual, testCase.expected);
  23. [ESCAPE_CODES.FG_GREEN, '.', ESCAPE_CODES.RESET_COLOR].forEach(el =>
  24. process.stdout.write(el)
  25. );
  26. });
  27. console.log(ESCAPE_CODES.FG_GREEN, 'OK', ESCAPE_CODES.RESET_COLOR);