From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../tests/no-addtask-setup.js | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 tools/lint/eslint/eslint-plugin-mozilla/tests/no-addtask-setup.js (limited to 'tools/lint/eslint/eslint-plugin-mozilla/tests/no-addtask-setup.js') diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/no-addtask-setup.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/no-addtask-setup.js new file mode 100644 index 0000000000..cd036d7d91 --- /dev/null +++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/no-addtask-setup.js @@ -0,0 +1,69 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// ------------------------------------------------------------------------------ +// Requirements +// ------------------------------------------------------------------------------ + +var rule = require("../lib/rules/no-addtask-setup"); +var RuleTester = require("eslint").RuleTester; + +const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: "latest" } }); + +// ------------------------------------------------------------------------------ +// Tests +// ------------------------------------------------------------------------------ + +function callError() { + return [{ messageId: "useAddSetup", type: "CallExpression" }]; +} + +ruleTester.run("no-addtask-setup", rule, { + valid: [ + "add_task(function() {});", + "add_task(function () {});", + "add_task(function foo() {});", + "add_task(async function() {});", + "add_task(async function () {});", + "add_task(async function foo() {});", + "something(function setup() {});", + "something(async function setup() {});", + "add_task(setup);", + "add_task(setup => {});", + "add_task(async setup => {});", + ], + invalid: [ + { + code: "add_task(function setup() {});", + output: "add_setup(function() {});", + errors: callError(), + }, + { + code: "add_task(function setup () {});", + output: "add_setup(function () {});", + errors: callError(), + }, + { + code: "add_task(async function setup() {});", + output: "add_setup(async function() {});", + errors: callError(), + }, + { + code: "add_task(async function setup () {});", + output: "add_setup(async function () {});", + errors: callError(), + }, + { + code: "add_task(async function setUp() {});", + output: "add_setup(async function() {});", + errors: callError(), + }, + { + code: "add_task(async function init() {});", + output: "add_setup(async function() {});", + errors: callError(), + }, + ], +}); -- cgit v1.2.3