scripts.js 768 B

123456789101112131415161718192021222324
  1. var tap = require("tap")
  2. var normalize = require("../lib/normalize")
  3. var path = require("path")
  4. var fs = require("fs")
  5. tap.test("bad scripts", function (t) {
  6. var p = path.resolve(__dirname, "./fixtures/badscripts.json")
  7. fs.readFile (p, function (err, contents) {
  8. if (err) throw err
  9. var originalData = JSON.parse(contents.toString())
  10. var data = JSON.parse(contents.toString())
  11. normalize(data)
  12. t.ok(data)
  13. verifyFields(t, data, originalData)
  14. t.end()
  15. })
  16. })
  17. function verifyFields (t, normalized, original) {
  18. t.equal(normalized.version, original.version, "Version field stays same")
  19. t.equal(normalized.name, original.name, "Name stays the same.")
  20. // scripts is not an object, so it should be deleted
  21. t.notOk(normalized.scripts)
  22. }