Skip to content

Commit 31608b7

Browse files
authored
Renamed index.ts to getIndex.ts (#557)
* Renamed index.ts to getIndex.ts * Renamed imports to getIndex * Renamed variables with starting underscore
1 parent 6e90b0c commit 31608b7

File tree

10 files changed

+262
-255
lines changed

10 files changed

+262
-255
lines changed

__tests__/api.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ describe('Testing api', () => {
3030
})
3131

3232
test('should have a data-opts object', () => {
33-
expect(typeof sortable.__testing._data(ul, 'opts')).toBe('object')
33+
expect(typeof sortable.__testing.data(ul, 'opts')).toBe('object')
3434
})
3535

3636
test('should have correct options set on options object', () => {
37-
const opts = sortable.__testing._data(ul, 'opts')
37+
const opts = sortable.__testing.data(ul, 'opts')
3838
expect(opts.items).toEqual('li')
3939
expect(opts.placeholderClass).toEqual('test-placeholder')
4040
expect(opts.draggingClass).toEqual('test-dragging')
@@ -45,7 +45,7 @@ describe('Testing api', () => {
4545
})
4646

4747
test('should have a data-items object', () => {
48-
expect(typeof sortable.__testing._data(ul, 'items')).toBe('string')
48+
expect(typeof sortable.__testing.data(ul, 'items')).toBe('string')
4949
})
5050

5151
test('should have aria-grabbed attributes', () => {
@@ -83,15 +83,15 @@ describe('Testing api', () => {
8383
})
8484

8585
test('should not have a data-opts object', () => {
86-
expect(typeof sortable.__testing._data(ul, 'opts')).toBe('undefined')
86+
expect(typeof sortable.__testing.data(ul, 'opts')).toBe('undefined')
8787
})
8888

8989
test('should not have a aria-dropeffect attribute', () => {
9090
expect(ul.getAttribute('aria-dropeffect')).toBeNull()
9191
})
9292

9393
test('should not have a data-items object', () => {
94-
expect(sortable.__testing._data(ul, 'items')).not.toBeDefined()
94+
expect(sortable.__testing.data(ul, 'items')).not.toBeDefined()
9595
})
9696

9797
test('should not have an aria-grabbed attribute', () => {
@@ -117,13 +117,13 @@ describe('Testing api', () => {
117117
})
118118

119119
test('should keep the options of the sortable', () => {
120-
const opts = sortable.__testing._data(ul, 'opts')
120+
const opts = sortable.__testing.data(ul, 'opts')
121121
expect(opts.items).toEqual('li:not(.disabled)')
122122
expect(opts.placeholderClass).toEqual('test-placeholder')
123123
})
124124

125125
test('should keep items attribute of the sortable', () => {
126-
const items = sortable.__testing._data(ul, 'items')
126+
const items = sortable.__testing.data(ul, 'items')
127127
expect(items).toEqual('li:not(.disabled)')
128128
})
129129
})

__tests__/index.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
/* global describe,test,expect */
22
/* eslint-env jest */
33

4-
import index from '../src/index'
4+
import getIndex from '../src/getIndex'
55

66
describe('Testing index', () => {
77
test('element is undefined', () => {
88
// setup
99
const div = window.document.createElement('div')
1010
// assert
11-
expect(() => { index(undefined, div) }).toThrow('You must provide an element and a list of elements.')
11+
expect(() => { getIndex(undefined, div) }).toThrow('You must provide an element and a list of elements.')
1212
})
1313

1414
test('elementList is not a valid list', () => {
1515
// setup
1616
const div = window.document.createElement('div')
1717
const div2 = window.document.createElement('div')
1818
// assert
19-
expect(() => { index(div, div2) }).toThrow('You must provide an element and a list of elements.')
20-
expect(() => { index(div, undefined) }).toThrow('You must provide an element and a list of elements.')
19+
expect(() => { getIndex(div, div2) }).toThrow('You must provide an element and a list of elements.')
20+
expect(() => { getIndex(div, undefined) }).toThrow('You must provide an element and a list of elements.')
2121
})
2222

2323
test('elementList is a nodelist', () => {
@@ -26,21 +26,21 @@ describe('Testing index', () => {
2626
div.innerHTML = '<div></div>'
2727
const nodeList = div.querySelectorAll('div')
2828
// assert
29-
expect(() => { index(div, nodeList) }).not.toThrow('You must provide an element and a list of elements.')
29+
expect(() => { getIndex(div, nodeList) }).not.toThrow('You must provide an element and a list of elements.')
3030
})
3131

3232
test('elementList is a HTMLCollection', () => {
3333
// setup
3434
const div = window.document.createElement('div')
3535
// assert
36-
expect(() => { index(div, document.links) }).not.toThrow('You must provide an element and a list of elements.')
36+
expect(() => { getIndex(div, document.links) }).not.toThrow('You must provide an element and a list of elements.')
3737
})
3838

3939
test('elementList is an Array', () => {
4040
// setup
4141
const div = window.document.createElement('div')
4242
// assert
43-
expect(() => { index(div, []) }).not.toThrow('You must provide an element and a list of elements.')
43+
expect(() => { getIndex(div, []) }).not.toThrow('You must provide an element and a list of elements.')
4444
})
4545

4646
test('element is child of div', () => {
@@ -53,7 +53,7 @@ describe('Testing index', () => {
5353
div.appendChild(span)
5454
div.appendChild(child2)
5555
// assert
56-
expect(index(child1, div.children)).toEqual(0)
57-
expect(index(child2, div.querySelectorAll('div'))).toEqual(1)
56+
expect(getIndex(child1, div.children)).toEqual(0)
57+
expect(getIndex(child2, div.querySelectorAll('div'))).toEqual(1)
5858
})
5959
})

__tests__/sortableMethodsTests/_removeItemData.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('_removeItemData', () => {
2222
sortable(ul, {
2323
items: 'li'
2424
})
25-
sortable.__testing._removeItemData(li)
25+
sortable.__testing.removeItemData(li)
2626
expect(li.getAttribute('role')).toBeNull()
2727
expect(li.getAttribute('draggable')).toBeNull()
2828
expect(li.getAttribute('aria-grabbed')).toBeNull()

__tests__/sortableMethodsTests/_removeItemEvents.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe('_removeItemEvents', () => {
1414
expect(typeof store(li).getData('eventdragover')).toBe('function')
1515
expect(typeof store(li).getData('eventdragenter')).toBe('function')
1616
// remove item events
17-
sortable.__testing._removeItemEvents(li)
17+
sortable.__testing.removeItemEvents(li)
1818
// assert
1919
expect(typeof store(li).getData('eventdragover')).toBe('undefined')
2020
expect(typeof store(li).getData('eventdragenter')).toBe('undefined')

__tests__/throttle.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/* global describe,test,expect */
22
/* eslint-env jest */
3-
import _throttle from '../src/throttle'
3+
import throttle from '../src/throttle'
44

55
describe('Testing throttle', () => {
66
test('throttle should not allow functions to be called multiple times within the timeframe', () => {
77
let value = 0
8-
const fn = _throttle(() => {
8+
const fn = throttle(() => {
99
value++
1010
})
1111
// call function twice immeditatly
@@ -17,7 +17,7 @@ describe('Testing throttle', () => {
1717

1818
test('throttle should allow functions to be called multiple times after the timeframe', () => {
1919
let value = 0
20-
const fn = _throttle(() => {
20+
const fn = throttle(() => {
2121
value++
2222
}, 10)
2323
// call function twice immeditatly
@@ -31,11 +31,11 @@ describe('Testing throttle', () => {
3131

3232
test('throttle should fail if no functin is provided', () => {
3333
// assert
34-
expect(() => { _throttle('test', 10) }).toThrowError('You must provide a function as the first argument for throttle.')
34+
expect(() => { throttle('test', 10) }).toThrowError('You must provide a function as the first argument for throttle.')
3535
})
3636

3737
test('throttle should fail if threshold is not a number', () => {
3838
// assert
39-
expect(() => { _throttle(() => { }, '10') }).toThrowError('You must provide a number as the second argument for throttle.')
39+
expect(() => { throttle(() => { }, '10') }).toThrowError('You must provide a number as the second argument for throttle.')
4040
})
4141
})

0 commit comments

Comments
 (0)