no-fetch-credentials.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. "use strict";
  2. //------------------------------------------------------------------------------
  3. // Requirements
  4. //------------------------------------------------------------------------------
  5. const rule = require("../../../lib/rules/no-fetch-credentials.js");
  6. const RuleTester = require("eslint").RuleTester;
  7. //------------------------------------------------------------------------------
  8. // Tests
  9. //------------------------------------------------------------------------------
  10. const ruleTester = new RuleTester();
  11. ruleTester.run("no-fetch-default", rule, {
  12. valid: [
  13. "fetch(\"http://foo.com\", {credentials: \"omit\"})",
  14. ],
  15. invalid: [
  16. {
  17. code: "fetch(\"http://foo.com\")",
  18. errors: [{
  19. message: "Please provide options for fetch() call",
  20. type: "CallExpression",
  21. }]
  22. },
  23. {
  24. code: "fetch(bar)",
  25. errors: [{
  26. message: "Please provide options for fetch() call",
  27. type: "CallExpression",
  28. }]
  29. },
  30. {
  31. code: "fetch(bar, {})",
  32. errors: [{
  33. message: "Fetch call does not omit credentials",
  34. type: "CallExpression",
  35. }]
  36. }
  37. ]
  38. });