]> git.proxmox.com Git - pve-eslint.git/blob - eslint/tests/lib/linter/rule-fixer.js
first commit
[pve-eslint.git] / eslint / tests / lib / linter / rule-fixer.js
1 /**
2 * @fileoverview Tests for rule fixer.
3 * @author Nicholas C. Zakas
4 */
5 "use strict";
6
7 //------------------------------------------------------------------------------
8 // Requirements
9 //------------------------------------------------------------------------------
10
11 const assert = require("chai").assert,
12 ruleFixer = require("../../../lib/linter/rule-fixer");
13
14 //------------------------------------------------------------------------------
15 // Tests
16 //------------------------------------------------------------------------------
17
18 describe("RuleFixer", () => {
19
20 describe("insertTextBefore", () => {
21
22 it("should return an object with the correct information when called", () => {
23
24 const result = ruleFixer.insertTextBefore({ range: [0, 1] }, "Hi");
25
26 assert.deepStrictEqual(result, {
27 range: [0, 0],
28 text: "Hi"
29 });
30
31 });
32
33 });
34
35 describe("insertTextBeforeRange", () => {
36
37 it("should return an object with the correct information when called", () => {
38
39 const result = ruleFixer.insertTextBeforeRange([0, 1], "Hi");
40
41 assert.deepStrictEqual(result, {
42 range: [0, 0],
43 text: "Hi"
44 });
45
46 });
47
48 });
49
50 describe("insertTextAfter", () => {
51
52 it("should return an object with the correct information when called", () => {
53
54 const result = ruleFixer.insertTextAfter({ range: [0, 1] }, "Hi");
55
56 assert.deepStrictEqual(result, {
57 range: [1, 1],
58 text: "Hi"
59 });
60
61 });
62
63 });
64
65 describe("insertTextAfterRange", () => {
66
67 it("should return an object with the correct information when called", () => {
68
69 const result = ruleFixer.insertTextAfterRange([0, 1], "Hi");
70
71 assert.deepStrictEqual(result, {
72 range: [1, 1],
73 text: "Hi"
74 });
75
76 });
77
78 });
79
80 describe("removeAfter", () => {
81
82 it("should return an object with the correct information when called", () => {
83
84 const result = ruleFixer.remove({ range: [0, 1] });
85
86 assert.deepStrictEqual(result, {
87 range: [0, 1],
88 text: ""
89 });
90
91 });
92
93 });
94
95 describe("removeAfterRange", () => {
96
97 it("should return an object with the correct information when called", () => {
98
99 const result = ruleFixer.removeRange([0, 1]);
100
101 assert.deepStrictEqual(result, {
102 range: [0, 1],
103 text: ""
104 });
105
106 });
107
108 });
109
110
111 describe("replaceText", () => {
112
113 it("should return an object with the correct information when called", () => {
114
115 const result = ruleFixer.replaceText({ range: [0, 1] }, "Hi");
116
117 assert.deepStrictEqual(result, {
118 range: [0, 1],
119 text: "Hi"
120 });
121
122 });
123
124 });
125
126 describe("replaceTextRange", () => {
127
128 it("should return an object with the correct information when called", () => {
129
130 const result = ruleFixer.replaceTextRange([0, 1], "Hi");
131
132 assert.deepStrictEqual(result, {
133 range: [0, 1],
134 text: "Hi"
135 });
136
137 });
138
139 });
140
141 });