forked from GetmeUK/ContentTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimage.coffee
More file actions
66 lines (47 loc) · 1.8 KB
/
Copy pathimage.coffee
File metadata and controls
66 lines (47 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# ImageDialog
describe 'ContentTools.ImageDialog', () ->
div = null
editor = null
beforeEach ->
# Create an editable region
div = document.createElement('div')
div.setAttribute('class', 'editable')
document.body.appendChild(div)
# Initialize the editor
editor = ContentTools.EditorApp.get()
editor.init('.editable')
afterEach ->
# Shutdown the editor
editor.destroy()
# Remove the editable region
document.body.removeChild(div)
describe 'ContentTools.ImageDialog()', () ->
it 'should return an instance of a ImageDialog', () ->
dialog = new ContentTools.ImageDialog()
expect(dialog instanceof ContentTools.ImageDialog).toBe true
describe 'ContentTools.ImageDialog.cropRegion()', () ->
it 'should return the crop region set by the user', () ->
dialog = new ContentTools.ImageDialog()
editor.attach(dialog)
dialog.mount()
# By default this should return the entire image [0, 0, 1, 1]
expect(dialog.cropRegion()).toEqual([0, 0, 1, 1])
# Populate the dialog with an image
dialog._domView.style.width = '400px'
dialog._domView.style.height = '400px'
dialog.populate('test.png', [400, 400])
# Add some crop marks for the dialog
dialog.addCropMarks()
dialog._cropMarks._domHandles[1].style.left = '200px'
dialog._cropMarks._domHandles[1].style.top = '200px'
# By default this should return the entire image [0, 0, 1, 1]
expect(dialog.cropRegion()).toEqual([0, 0, 0.5, 0.5])
#addCropMarks
#clear
#mount
#populate
#progress
#removeCropMarks
#save
#state
#unmount