Skip to content

Commit 800255c

Browse files
committed
style: fix linter issues from tests
1 parent 562a542 commit 800255c

File tree

18 files changed

+111
-139
lines changed

18 files changed

+111
-139
lines changed

spec/helpers/helper.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
/* eslint-disable no-undef */
2-
/* eslint-disable no-unused-vars */
3-
41
const KEYMAP = {
52
'27': 'Escape',
63
'32': 'Space',
@@ -121,28 +118,27 @@ const KEYMAP = {
121118
'105': '9'
122119
};
123120

121+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
124122
function XloadHtml(html, options) {
125123
options = options ? options : {};
126124
const defaultOptions = { insertionType: 'append' };
127125
options = {
128126
...defaultOptions,
129127
...options
130128
};
131-
132129
const div = document.createElement('div');
133130
div.classList.add('please-delete-me');
134131
div.innerHTML = html;
135-
136132
if (options.insertionType === 'append') {
137133
document.body.appendChild(div);
138134
} else if (options.insertionType === 'prepend') {
139135
document.body.prepend(div);
140136
}
141137
}
142138

139+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
143140
function XunloadFixtures() {
144141
document.querySelectorAll('.please-delete-me').forEach((el) => el.remove());
145-
//
146142
document.querySelectorAll('.material-tooltip').forEach((el) => el.remove());
147143
document.querySelectorAll('.dropdown-content').forEach((el) => el.remove());
148144
}
@@ -152,7 +148,7 @@ beforeEach(() => {
152148
toExist: (util, customEqualityTesters) => {
153149
return {
154150
compare: (actual) => {
155-
let result = {};
151+
const result = {};
156152
result.pass = util.equals(!!actual, true, customEqualityTesters);
157153
return result;
158154
}
@@ -190,7 +186,7 @@ beforeEach(() => {
190186
return {
191187
compare: (actual) => {
192188
const style = getComputedStyle(actual);
193-
let result = {};
189+
const result = {};
194190
result.pass = util.equals(
195191
style.getPropertyValue('display'),
196192
'none',
@@ -204,7 +200,7 @@ beforeEach(() => {
204200
return {
205201
compare: (actual) => {
206202
const style = getComputedStyle(actual);
207-
let result = {};
203+
const result = {};
208204
result.pass = !util.equals(
209205
style.getPropertyValue('display'),
210206
'none',
@@ -224,7 +220,7 @@ beforeEach(() => {
224220
toHaveClass: (util, customEqualityTesters) => {
225221
return {
226222
compare: (actual, expected) => {
227-
let result = {};
223+
const result = {};
228224
result.pass = util.equals(
229225
actual.classList.contains(expected),
230226
true,
@@ -237,7 +233,7 @@ beforeEach(() => {
237233
toNotHaveClass: (util, customEqualityTesters) => {
238234
return {
239235
compare: function (actual, expected) {
240-
let result = {};
236+
const result = {};
241237
result.pass = util.equals(
242238
actual.classList.contains(expected),
243239
false,

spec/tests/autocomplete/autocompleteSpec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ describe('Autocomplete Plugin', () => {
9696
}
9797
const limitedInstance = M.Autocomplete.getInstance(limited);
9898
const limit = 20;
99-
limitedInstance.options.onSearch = (text) => {
99+
limitedInstance.options.onSearch = () => {
100100
const filteredItems = data.slice(0, limit);
101101
limitedInstance.setMenuItems(filteredItems);
102102
};
@@ -114,8 +114,8 @@ describe('Autocomplete Plugin', () => {
114114
});
115115

116116
it('should open correctly from typing', (done) => {
117-
let normal = document.querySelector('#normal-autocomplete');
118-
let autocompleteEl = normal.parentNode.querySelector('.autocomplete-content');
117+
const normal = document.querySelector('#normal-autocomplete');
118+
const autocompleteEl = normal.parentNode.querySelector('.autocomplete-content');
119119
focus(normal);
120120
normal.value = 'e';
121121
keyup(normal, 69);
@@ -129,8 +129,8 @@ describe('Autocomplete Plugin', () => {
129129
});
130130

131131
it('should open correctly from keyboard focus', (done) => {
132-
let normal = document.querySelector('#normal-autocomplete');
133-
let autocompleteEl = normal.parentNode.querySelector('.autocomplete-content');
132+
const normal = document.querySelector('#normal-autocomplete');
133+
const autocompleteEl = normal.parentNode.querySelector('.autocomplete-content');
134134
normal.value = 'e';
135135
keyup(normal, 9);
136136
focus(normal);

spec/tests/cards/cardsSpec.js

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable no-undef */
2-
31
describe('Cards', () => {
42
const fixture = `<div class="row">
53
<div class="col s12 m6">
@@ -150,13 +148,13 @@ describe('Cards', () => {
150148
});
151149

152150
it('should have small card dimensions', () => {
153-
let cardImage = small.querySelector('.card-image');
154-
let cardContent = small.querySelector('.card-content');
155-
let cardAction = small.querySelector('.card-action');
156-
let smallRect = small.getBoundingClientRect();
157-
let cardImageRect = cardImage.getBoundingClientRect();
158-
let cardContentRect = cardContent.getBoundingClientRect();
159-
let cardActionRect = cardAction.getBoundingClientRect();
151+
const cardImage = small.querySelector('.card-image');
152+
const cardContent = small.querySelector('.card-content');
153+
const cardAction = small.querySelector('.card-action');
154+
const smallRect = small.getBoundingClientRect();
155+
const cardImageRect = cardImage.getBoundingClientRect();
156+
const cardContentRect = cardContent.getBoundingClientRect();
157+
const cardActionRect = cardAction.getBoundingClientRect();
160158

161159
expect(smallRect.height).toEqual(300, 'small card should be 300px high');
162160
expect(cardImageRect.height).toBeLessThan(181, 'small image should be <= 180px or 60% high');
@@ -171,13 +169,13 @@ describe('Cards', () => {
171169
});
172170

173171
it('should have medium card dimensions', () => {
174-
let cardImage = medium.querySelector('.card-image');
175-
let cardContent = medium.querySelector('.card-content');
176-
let cardAction = medium.querySelector('.card-action');
177-
let mediumRect = medium.getBoundingClientRect();
178-
let cardImageRect = cardImage.getBoundingClientRect();
179-
let cardContentRect = cardContent.getBoundingClientRect();
180-
let cardActionRect = cardAction.getBoundingClientRect();
172+
const cardImage = medium.querySelector('.card-image');
173+
const cardContent = medium.querySelector('.card-content');
174+
const cardAction = medium.querySelector('.card-action');
175+
const mediumRect = medium.getBoundingClientRect();
176+
const cardImageRect = cardImage.getBoundingClientRect();
177+
const cardContentRect = cardContent.getBoundingClientRect();
178+
const cardActionRect = cardAction.getBoundingClientRect();
181179

182180
expect(mediumRect.height).toEqual(400, 'medium card should be 400px high');
183181
expect(cardImageRect.height).toBeLessThan(241, 'medium image should be <= 240 or 60% high');
@@ -192,13 +190,13 @@ describe('Cards', () => {
192190
});
193191

194192
it('should have large card dimensions', () => {
195-
let cardImage = large.querySelector('.card-image');
196-
let cardContent = large.querySelector('.card-content');
197-
let cardAction = large.querySelector('.card-action');
198-
let largeRect = large.getBoundingClientRect();
199-
let cardImageRect = cardImage.getBoundingClientRect();
200-
let cardContentRect = cardContent.getBoundingClientRect();
201-
let cardActionRect = cardAction.getBoundingClientRect();
193+
const cardImage = large.querySelector('.card-image');
194+
const cardContent = large.querySelector('.card-content');
195+
const cardAction = large.querySelector('.card-action');
196+
const largeRect = large.getBoundingClientRect();
197+
const cardImageRect = cardImage.getBoundingClientRect();
198+
const cardContentRect = cardContent.getBoundingClientRect();
199+
const cardActionRect = cardAction.getBoundingClientRect();
202200

203201
expect(largeRect.height).toEqual(500, 'large card should be 500px high');
204202
expect(cardImageRect.height).toBeLessThan(301, 'large image should be <= 300 or 60% high');

spec/tests/carousel/carouselSpec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable no-undef */
2-
31
describe('Carousel', () => {
42
const fixture = `<div class="carousel carousel-slider" id="slider-no-wrap">
53
<div class="carousel-item">
@@ -52,10 +50,12 @@ describe('Carousel', () => {
5250

5351
document.querySelectorAll('.indicator-item')[1].click();
5452
setTimeout(() => {
55-
expect(carousel.center).toEqual(1, 'carousel item was not visible after indicator interaction');
53+
expect(carousel.center).toEqual(
54+
1,
55+
'carousel item was not visible after indicator interaction'
56+
);
5657
done();
5758
}, 30);
5859
});
59-
6060
});
6161
});

spec/tests/chips/chipsSpec.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable no-undef */
2-
31
describe('Chips', () => {
42
const fixture = `<div class="chips"></div>
53
<div class="chips chips-initial"></div>
@@ -66,7 +64,7 @@ describe('Chips', () => {
6664
M.Chips.init(chips);
6765
M.Chips.init(chips);
6866
chipsUserInput = document.querySelector('.chips.input-field');
69-
M.Chips.init(chips, {allowUserInput: true});
67+
M.Chips.init(chips, { allowUserInput: true });
7068
input = chipsUserInput.querySelectorAll('input');
7169
expect(input.length).toEqual(1, 'Should dynamically generate chips structure.');
7270
});
@@ -77,8 +75,8 @@ describe('Chips', () => {
7775
input.value = 'one';
7876
keydown(input, 13);
7977
setTimeout(() => {
80-
let numChips = chips.querySelectorAll('.chip').length;
81-
let oneChip = chips.querySelector('.chip');
78+
const numChips = chips.querySelectorAll('.chip').length;
79+
const oneChip = chips.querySelector('.chip');
8280
expect(numChips).toEqual(1, 'one chip should have been added');
8381
for (let i = oneChip.children.length - 1; i >= 0; i--) {
8482
oneChip.children[i].remove();
@@ -92,7 +90,7 @@ describe('Chips', () => {
9290
chips = document.querySelector('.chips.chips-initial.input-field');
9391
let numChips = chips.querySelectorAll('.chip').length;
9492
expect(numChips).toEqual(3, '3 initial chips should have been added');
95-
let chipCloseButton = chips.querySelectorAll('.chip .close');
93+
const chipCloseButton = chips.querySelectorAll('.chip .close');
9694
expect(chipCloseButton.length).toEqual(3, 'expected all chips to have close button');
9795
click(chipCloseButton[0]);
9896
setTimeout(() => {

spec/tests/collapsible/collapsibleSpec.js

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable no-undef */
2-
31
describe('Collapsible Plugin:', () => {
42
let collapsible, accordion, popout, expandable, expandablePreselect;
53

@@ -80,8 +78,8 @@ describe('Collapsible Plugin:', () => {
8078
describe('collapsible', () => {
8179
it('should open all items, keeping all open', (done) => {
8280
// Collapsible body height should be 0 on start when hidden.
83-
let headers = expandable.querySelectorAll('.collapsible-header');
84-
let bodies = expandable.querySelectorAll('.collapsible-body');
81+
const headers = expandable.querySelectorAll('.collapsible-header');
82+
const bodies = expandable.querySelectorAll('.collapsible-body');
8583
for (let i = 0; i < bodies.length; i++) {
8684
expect(bodies[i]).hasMaxHeightZero(
8785
'because collapsible bodies should be hidden initially.'
@@ -103,9 +101,9 @@ describe('Collapsible Plugin:', () => {
103101
});
104102

105103
it('should allow preopened sections', () => {
106-
let bodies = expandablePreselect.querySelectorAll('.collapsible-body');
104+
const bodies = expandablePreselect.querySelectorAll('.collapsible-body');
107105
for (let i = 0; i < bodies.length; i++) {
108-
let headerLi = bodies[i].parentNode;
106+
const headerLi = bodies[i].parentNode;
109107
if (i === 1) {
110108
expect(headerLi).toHaveClass(
111109
'active',
@@ -136,15 +134,15 @@ describe('Collapsible Plugin:', () => {
136134
inDuration: 0,
137135
outDuration: 0
138136
});
139-
let bodies = expandable.querySelectorAll('.collapsible-body');
137+
const bodies = expandable.querySelectorAll('.collapsible-body');
140138
expect(openCallback).toEqual(false, 'because open callback not yet fired');
141139
expect(closeCallback).toEqual(false, 'because close callback not yet fired');
142140
for (let i = 0; i < bodies.length; i++) {
143141
//TODO replace with alternative for deprecated jasmine-jquery
144142
expect(bodies[i]).hasMaxHeightZero(
145143
'because collapsible bodies should be hidden initially.'
146144
);
147-
let collapsibleInstance = M.Collapsible.getInstance(bodies[i].parentNode.parentNode);
145+
const collapsibleInstance = M.Collapsible.getInstance(bodies[i].parentNode.parentNode);
148146
collapsibleInstance.open(i);
149147
}
150148
expect(openCallback).toEqual(true, 'because open callback fired');
@@ -171,10 +169,10 @@ describe('Collapsible Plugin:', () => {
171169
describe('accordion', () => {
172170
it('should open first and second items, keeping only second open', (done) => {
173171
// Collapsible body height should be 0 on start when hidden.
174-
let firstHeader = accordion.querySelector('.collapsible-header');
175-
let firstBody = accordion.querySelector('.collapsible-body');
176-
let secondHeader = accordion.querySelectorAll('.collapsible-header')[1];
177-
let secondBody = accordion.querySelectorAll('.collapsible-body')[1];
172+
const firstHeader = accordion.querySelector('.collapsible-header');
173+
const firstBody = accordion.querySelector('.collapsible-body');
174+
const secondHeader = accordion.querySelectorAll('.collapsible-header')[1];
175+
const secondBody = accordion.querySelectorAll('.collapsible-body')[1];
178176
expect(firstBody).hasMaxHeightZero('because accordion bodies should be hidden initially.');
179177
expect(secondBody).hasMaxHeightZero('because accordion bodies should be hidden initially.');
180178
// Collapsible body height should be > 0 after being opened.
@@ -200,15 +198,15 @@ describe('Collapsible Plugin:', () => {
200198
describe('popout', () => {
201199
it('should open first and popout', (done) => {
202200
// Collapsible body height should be 0 on start when hidden.
203-
let listItems = popout.querySelectorAll('li');
204-
let firstHeader = popout.querySelector('.collapsible-header');
205-
let firstBody = popout.querySelector('.collapsible-body');
201+
const listItems = popout.querySelectorAll('li');
202+
const firstHeader = popout.querySelector('.collapsible-header');
203+
const firstBody = popout.querySelector('.collapsible-body');
206204
expect(firstBody).hasMaxHeightZero('because accordion bodies should be hidden initially.');
207205
// Expect margin to be > 0 because not popped out.
208206
for (let i = 0; i < listItems.length; i++) {
209-
let listItemStyles = getComputedStyle(listItems[i]);
210-
let marginLeft = parseInt(listItemStyles.getPropertyValue('margin-left'));
211-
let marginRight = parseInt(listItemStyles.getPropertyValue('margin-right'));
207+
const listItemStyles = getComputedStyle(listItems[i]);
208+
const marginLeft = parseInt(listItemStyles.getPropertyValue('margin-left'));
209+
const marginRight = parseInt(listItemStyles.getPropertyValue('margin-right'));
212210
expect(marginLeft).toBeGreaterThan(
213211
0,
214212
'because closed popout items should have horizontal margins.'

spec/tests/datepicker/datepickerSpec.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable no-undef */
2-
31
describe('Datepicker Plugin', () => {
42
const fixture = `<div class="row">
53
<div class="input-field col s12">

spec/tests/dropdown/dropdownSpec.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable no-undef */
2-
31
describe('Dropdown Plugin:', () => {
42
const fixture = `<div class="row">
53
<div class="input-field col s12">

spec/tests/fab/fabSpec.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable no-undef */
2-
31
describe('Fab Plugin:', () => {
42
const fixture = `<div class="fixed-action-btn">
53
<a class="btn-floating btn-large red">

spec/tests/forms/formsSpec.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable no-undef */
2-
31
const MULTILINE_TEXT =
42
'This is line 1.\nThis is line 2.\nThis is line 3.\nThis is line 4.\nThis is line 5.\nAnd this is line 6.';
53

0 commit comments

Comments
 (0)