-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: all row events added * chore: event refactor and event factory * chore: add tests and refactor events * chore: fix merge no return * chore: fix linting issues * chore: fixed lint and test issues for events * chore: fixing travis CI build errors * chore: fix App.vue for cypress tests
- Loading branch information
1 parent
7c77a03
commit cffb333
Showing
12 changed files
with
26,283 additions
and
13 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Vue from 'vue'; | ||
import dashify from 'dashify'; | ||
|
||
export default function (this: Vue, events: string[]): Object { | ||
const vm = this; | ||
const obj: {[index:string] : {}} = {}; | ||
events.forEach((event) => { | ||
obj[event] = (...args: any[]) => { | ||
vm.$emit(dashify(event), ...args); | ||
}; | ||
}); | ||
return obj; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const cellEvents: string[] = [ | ||
'cellClick', | ||
'cellDblClick', | ||
'cellContext', | ||
'cellTap', | ||
'cellDblTap', | ||
'cellTapHOld', | ||
'cellMouseEnter', | ||
'cellMouseLeave', | ||
'cellMouseOver', | ||
'cellMouseOut', | ||
'cellMouseMove', | ||
'cellEditing', | ||
'cellEditCancelled', | ||
'cellEdited', | ||
] | ||
|
||
export default cellEvents |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const rowEvents: string[] = [ | ||
'rowClick', | ||
'rowDblClick', | ||
'rowContext', | ||
'rowTap', | ||
'rowDblTap', | ||
'rowTapHold', | ||
'rowMouseEnter', | ||
'rowMouseLeave', | ||
'rowMouseOver', | ||
'rowMouseOut', | ||
'rowMouseMove', | ||
'rowAdded', | ||
'rowUpdated', | ||
'rowDeleted', | ||
'rowMoved', | ||
'rowResized', | ||
] | ||
|
||
export default rowEvents |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// ----------------------------------------// | ||
// Just pick the most appropriate version // | ||
// ----------------------------------------// | ||
// Attribution: https://github.com/Dayjo/joint | ||
/** | ||
* Joint for joining more than 2 functions. | ||
* Joins an array of functions together to return a single function | ||
* @param {array} a An array of functions | ||
* @return {function} Returns a function which is an accumilation of functions in 'a' | ||
*/ | ||
export default function joint(a: Function[]): Function { | ||
// const b: Function; | ||
let C: any; | ||
|
||
const b = a[(a.length - 1)]; | ||
|
||
a.pop(); | ||
|
||
if (a.length > 1) { | ||
C = joint(a); | ||
} else { | ||
[C] = a; | ||
} | ||
|
||
return function joined(...args: any[]) { | ||
b.apply(new C(...args), args); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import joint from './joint'; | ||
|
||
export default function merge(objValue: any, srcValue: any, key: string): any | undefined { | ||
if (typeof objValue === 'function' && typeof srcValue === 'function') { | ||
return joint([objValue, srcValue]); | ||
} | ||
return undefined; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import joint from '@/utilities/joint' | ||
|
||
describe('joint.ts', () => { | ||
test('joins 2 functions with no params', () => { | ||
const mock1 = jest.fn(() => 0) | ||
const mock2 = jest.fn(() => 2) | ||
const fn3 = joint([mock1,mock2]) | ||
fn3() | ||
expect(mock1.mock.calls.length).toEqual(1); | ||
expect(mock2.mock.calls.length).toEqual(1); | ||
}); | ||
test('join 2 functions with same params', () => { | ||
const mock1 = jest.fn((a,b) => a * b) | ||
const mock2 = jest.fn((a,b) => a + b) | ||
const fn3 = joint([mock1,mock2]) | ||
fn3(1,2) | ||
expect(mock1.mock.calls.length).toEqual(1); | ||
expect(mock2.mock.calls.length).toEqual(1); | ||
expect(mock1.mock.calls[0][0]).toEqual(1); | ||
expect(mock1.mock.calls[0][1]).toEqual(2); | ||
expect(mock2.mock.calls[0][0]).toEqual(1); | ||
expect(mock2.mock.calls[0][1]).toEqual(2); | ||
}); | ||
test('joins more than 2 functions', () => { | ||
const mock1 = jest.fn((a,b) => a * b) | ||
const mock2 = jest.fn((a,b) => a + b) | ||
const mock3 = jest.fn((a,b) => a + b) | ||
const fn3 = joint([mock1,mock2,mock3]) | ||
fn3(1,2) | ||
expect(mock1.mock.calls.length).toEqual(1) | ||
expect(mock2.mock.calls.length).toEqual(1) | ||
expect(mock3.mock.calls.length).toEqual(1) | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import merge from '@/utilities/merge' | ||
|
||
describe('merge.ts', () => { | ||
test('merges 2 functions together', () => { | ||
const mock1 = jest.fn(() => 0) | ||
const mock2 = jest.fn(() => 1 + 1) | ||
const merged = merge(mock1, mock2, 'key') | ||
merged() | ||
expect(mock1.mock.calls.length).toEqual(1); | ||
expect(mock2.mock.calls.length).toEqual(1); | ||
}); | ||
test('if params are not functions no return value', () => { | ||
const mock1 = jest.fn(() => 0) | ||
const mock2 = 'should not return function' | ||
const merged = merge(mock1, mock2, 'key') | ||
expect(merged).toEqual(undefined); | ||
}); | ||
}); |