-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: shortcuts-call test spec; test: drag-node-spec
- Loading branch information
1 parent
2bb4b27
commit 7260c2f
Showing
3 changed files
with
133 additions
and
1 deletion.
There are no files selected for viewing
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,66 @@ | ||
import '../../../src/behavior'; | ||
import '../../../src/shape'; | ||
import Graph from '../../../src/graph/graph'; | ||
|
||
const div = document.createElement('div'); | ||
div.id = 'shortcuts-spec'; | ||
document.body.appendChild(div); | ||
|
||
describe('shortcuts-call', () => { | ||
it('default shortcuts-call', () => { | ||
const graph = new Graph({ | ||
container: div, | ||
width: 500, | ||
height: 500, | ||
modes: { | ||
default: ['shortcuts-call'], | ||
}, | ||
}); | ||
const node = graph.addItem('node', { | ||
color: '#666', | ||
x: 50, | ||
y: 50, | ||
size: 20, | ||
style: { lineWidth: 2, fill: '#666' }, | ||
}); | ||
|
||
graph.emit('keydown', { key: 'ctrl' }); | ||
graph.emit('keydown', { key: '1' }); | ||
graph.emit('keyup'); | ||
const matrix = graph.getGroup().getMatrix(); | ||
expect(matrix[6]).toBe(200); | ||
expect(matrix[7]).toBe(200); | ||
|
||
graph.destroy(); | ||
}); | ||
it('Zoom 2', () => { | ||
const graph = new Graph({ | ||
container: div, | ||
width: 500, | ||
height: 500, | ||
modes: { | ||
default: [{ | ||
type: 'shortcuts-call', | ||
functionName: 'zoom', | ||
functionParams: [2] | ||
}], | ||
}, | ||
}); | ||
const node = graph.addItem('node', { | ||
color: '#666', | ||
x: 50, | ||
y: 50, | ||
size: 20, | ||
style: { lineWidth: 2, fill: '#666' }, | ||
}); | ||
|
||
graph.emit('keydown', { key: 'ctrl' }); | ||
graph.emit('keydown', { key: '1' }); | ||
graph.emit('keyup'); | ||
const matrix = graph.getGroup().getMatrix(); | ||
expect(matrix[0]).toBe(2); | ||
expect(matrix[4]).toBe(2); | ||
|
||
graph.destroy(); | ||
}); | ||
}); |