1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- "use strict";
- //------------------------------------------------------------------------------
- // Requirements
- //------------------------------------------------------------------------------
- const rule = require("../../../lib/rules/no-fetch-credentials.js");
- const RuleTester = require("eslint").RuleTester;
- //------------------------------------------------------------------------------
- // Tests
- //------------------------------------------------------------------------------
- const ruleTester = new RuleTester();
- ruleTester.run("no-fetch-default", rule, {
- valid: [
- "fetch(\"http://foo.com\", {credentials: \"omit\"})",
- ],
- invalid: [
- {
- code: "fetch(\"http://foo.com\")",
- errors: [{
- message: "Please provide options for fetch() call",
- type: "CallExpression",
- }]
- },
- {
- code: "fetch(bar)",
- errors: [{
- message: "Please provide options for fetch() call",
- type: "CallExpression",
- }]
- },
- {
- code: "fetch(bar, {})",
- errors: [{
- message: "Fetch call does not omit credentials",
- type: "CallExpression",
- }]
- }
- ]
- });
|