-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathno-setup-teardown.js
More file actions
97 lines (86 loc) · 3.19 KB
/
no-setup-teardown.js
File metadata and controls
97 lines (86 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/**
* @fileoverview Forbid setup/teardown module hooks
* @author Kevin Partington
* @copyright 2016 Kevin Partington. All rights reserved.
* See LICENSE file in root directory for full license.
*/
"use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const rule = require("../../../lib/rules/no-setup-teardown"),
RuleTester = require("eslint").RuleTester;
//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------
const ruleTester = new RuleTester();
ruleTester.run("no-setup-teardown", rule, {
valid: [
// Modules without hooks are always fine
"QUnit.module('Module');",
// beforeEach
"QUnit.module('Module', { beforeEach: function () {} });",
// afterEach
"QUnit.module('Module', { afterEach: function () {} });",
// before
"QUnit.module('Module', { before: function () {} });",
// after
"QUnit.module('Module', { after: function () {} });",
// all
"QUnit.module('Module', { before: function () {}, beforeEach: function () {}, afterEach: function () {}, after: function () {} });",
// other property names are not reported
"QUnit.module('Module', { foo: function () {} });",
],
invalid: [
{
code: "QUnit.module('module', { setup: function () { } });",
output: "QUnit.module('module', { beforeEach: function () { } });",
errors: [
{
messageId: "noSetupTeardown",
data: {
forbidden: "setup",
preferred: "beforeEach",
},
type: "Property",
},
],
},
{
code: "QUnit.module('module', { teardown: function () { } });",
output: "QUnit.module('module', { afterEach: function () { } });",
errors: [
{
messageId: "noSetupTeardown",
data: {
forbidden: "teardown",
preferred: "afterEach",
},
type: "Property",
},
],
},
{
code: "QUnit.module('module', { setup: function () {}, teardown: function () { } });",
output: "QUnit.module('module', { beforeEach: function () {}, afterEach: function () { } });",
errors: [
{
messageId: "noSetupTeardown",
data: {
forbidden: "setup",
preferred: "beforeEach",
},
type: "Property",
},
{
messageId: "noSetupTeardown",
data: {
forbidden: "teardown",
preferred: "afterEach",
},
type: "Property",
},
],
},
],
});