dependencies.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. var tap = require("tap")
  2. var normalize = require("../lib/normalize")
  3. var warningMessages = require("../lib/warning_messages.json")
  4. var safeFormat = require("../lib/safe_format")
  5. tap.test("warn if dependency contains anything else but a string", function(t) {
  6. var a
  7. var warnings = []
  8. function warn(w) {
  9. warnings.push(w)
  10. }
  11. normalize(a={
  12. dependencies: { "a": 123},
  13. devDependencies: { "b": 456},
  14. optionalDependencies: { "c": 789}
  15. }, warn)
  16. var wanted1 = safeFormat(warningMessages.nonStringDependency, "a", 123)
  17. var wanted2 = safeFormat(warningMessages.nonStringDependency, "b", 456)
  18. var wanted3 = safeFormat(warningMessages.nonStringDependency, "c", 789)
  19. t.ok(~warnings.indexOf(wanted1), wanted1)
  20. t.ok(~warnings.indexOf(wanted2), wanted2)
  21. t.ok(~warnings.indexOf(wanted3), wanted3)
  22. t.end()
  23. })
  24. tap.test("warn if bundleDependencies array contains anything else but strings", function(t) {
  25. var a
  26. var warnings = []
  27. function warn(w) {
  28. warnings.push(w)
  29. }
  30. normalize(a={
  31. bundleDependencies: ["abc", 123, {foo:"bar"}]
  32. }, warn)
  33. var wanted1 = safeFormat(warningMessages.nonStringBundleDependency, 123)
  34. var wanted2 = safeFormat(warningMessages.nonStringBundleDependency, {foo:"bar"})
  35. var wanted2 = safeFormat(warningMessages.nonDependencyBundleDependency, "abc")
  36. t.ok(~warnings.indexOf(wanted1), wanted1)
  37. t.ok(~warnings.indexOf(wanted2), wanted2)
  38. t.end()
  39. })