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.

36 lines
1.0KB

  1. //Jasmine Test - https://jasmine.github.io/2.8/introduction.html
  2. const fs = require("fs");
  3. describe("json", function() {
  4. it("simply valid parsable json", function(done) {
  5. fs.readdir('plugins', function(err, files) {
  6. if (err){
  7. fail("unable to read plugins dir");
  8. }
  9. for (let index in files) {
  10. const filePath = `plugins/${files[index]}`;
  11. if(!filePath.toLowerCase().endsWith('.json')){
  12. fail("manifests should have .json extension");
  13. }
  14. fs.readFile(filePath, 'utf8', (err, fileContent) => {
  15. if (err){
  16. fail("unable to read manifest file");
  17. }
  18. let manifestObj;
  19. try {
  20. manifestObj = JSON.parse(fileContent+"FAIL");
  21. done();
  22. } catch(err){
  23. fail(`Invalid JSON: ${filePath}\n${err}`);
  24. }
  25. });
  26. }
  27. });
  28. });
  29. });