github-urls.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. var tap = require("tap")
  2. var normalize = require("../lib/normalize")
  3. var fs = require("fs")
  4. var async = require("async")
  5. var data
  6. var warn
  7. tap.test("consistent normalization", function(t) {
  8. var entries = [
  9. 'read-package-json.json',
  10. 'http-server.json',
  11. "movefile.json",
  12. "node-module_exist.json"
  13. ]
  14. var verifyConsistency = function(entryName, next) {
  15. warn = function(msg) {
  16. // t.equal("",msg) // uncomment to have some kind of logging of warnings
  17. }
  18. var filename = __dirname + "/fixtures/" + entryName
  19. fs.readFile(filename, function(err, contents) {
  20. if (err) return next(err)
  21. data = JSON.parse(contents.toString())
  22. normalize(data, warn)
  23. if(data.name == "node-module_exist") {
  24. t.same(data.bugs.url, "https://gist.github.com/3135914")
  25. }
  26. if(data.name == "read-package-json") {
  27. t.same(data.bugs.url, "https://github.com/isaacs/read-package-json/issues")
  28. }
  29. if(data.name == "http-server") {
  30. t.same(data.bugs.url, "https://github.com/nodejitsu/http-server/issues")
  31. }
  32. if(data.name == "movefile") {
  33. t.same(data.bugs.url, "https://github.com/yazgazan/movefile/issues")
  34. }
  35. next(null)
  36. }) // fs.readFile
  37. } // verifyConsistency
  38. async.forEach(entries, verifyConsistency, function(err) {
  39. if (err) throw err
  40. t.end()
  41. })
  42. }) // tap.test