Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
646c8799
Commit
646c8799
authored
Nov 25, 2014
by
Jérome Perrin
Committed by
Ioannis Papagiannopoulos
Dec 18, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test for drag & drop
parent
c3e0f75b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
45 deletions
+52
-45
dream/platform/src/jsplumb/test.js
dream/platform/src/jsplumb/test.js
+52
-45
No files found.
dream/platform/src/jsplumb/test.js
View file @
646c8799
...
...
@@ -114,70 +114,77 @@
}
},
sample_data_graph
=
JSON
.
stringify
(
{
class_definition
:
sample_class_definition
,
graph
:
sample_graph
}),
{
class_definition
:
sample_class_definition
,
graph
:
sample_graph
}
),
sample_data_empty_graph
=
JSON
.
stringify
(
{
class_definition
:
sample_class_definition
,
graph
:
{
node
:
{},
edge
:
{}}
});
{
class_definition
:
sample_class_definition
,
graph
:
{
node
:
{},
edge
:
{}}
}
);
QUnit
.
config
.
testTimeout
=
5000
;
rJS
(
window
).
ready
(
function
(
g
)
{
test
(
"
Sample graph can be loaded and output is equal to input
"
,
function
()
{
var
jsplumb_gadget
;
stop
();
g
.
declareGadget
(
"
./index.html
"
,
{
element
:
document
.
querySelector
(
"
#qunit-fixture
"
)
})
.
then
(
function
(
new_gadget
)
{
jsplumb_gadget
=
new_gadget
;
return
jsplumb_gadget
.
render
(
sample_data_graph
);
test
(
"
Sample graph can be loaded and output is equal to input
"
,
function
()
{
var
jsplumb_gadget
;
stop
();
g
.
declareGadget
(
"
./index.html
"
,
{
element
:
document
.
querySelector
(
"
#qunit-fixture
"
)
})
.
then
(
function
()
{
return
jsplumb_gadget
.
getContent
();
})
.
then
(
function
(
content
)
{
equal
(
content
,
sample_data_graph
);
})
.
fail
(
console
.
error
.
bind
(
this
))
.
always
(
start
);
.
then
(
function
(
new_gadget
)
{
jsplumb_gadget
=
new_gadget
;
return
jsplumb_gadget
.
render
(
sample_data_graph
);
})
.
then
(
function
()
{
return
jsplumb_gadget
.
getContent
();
})
.
then
(
function
(
content
)
{
equal
(
content
,
sample_data_graph
);
})
.
fail
(
console
.
error
.
bind
(
this
))
.
always
(
start
);
});
test
(
"
New node can be drag & dropped
"
,
function
()
{
var
jsplumb_gadget
;
stop
();
function
runTest
()
{
return
jsplumb_gadget
.
getContent
().
then
(
function
()
{
// fake a drop event
var
e
=
new
Event
(
'
drop
'
);
e
.
dataTransfer
=
{
getData
:
function
(
type
){
// make sure we are called properly
equal
(
type
,
'
application/json
'
);
return
JSON
.
stringify
(
"
Example.Node
"
);
}
};
jsplumb_gadget
.
props
.
main
.
dispatchEvent
(
e
);
})
.
then
(
function
()
{
return
jsplumb_gadget
.
getContent
();
})
.
then
(
function
(
content
)
{
var
node
,
graph
=
JSON
.
parse
(
content
).
graph
;
equal
(
1
,
Object
.
keys
(
graph
.
node
).
length
);
node
=
graph
.
node
[
Object
.
keys
(
graph
.
node
)[
0
]];
equal
(
'
Example.Node
'
,
node
.
_class
);
});
}
g
.
declareGadget
(
"
./index.html
"
,
{
element
:
document
.
querySelector
(
"
#qunit-fixture
"
)
})
.
then
(
function
(
new_gadget
)
{
jsplumb_gadget
=
new_gadget
;
return
jsplumb_gadget
.
render
(
sample_data_empty_graph
);
})
/* XXX if we start service then we wait for ever
.then(function () {
return jsplumb_gadget.startService();
}) */
.
then
(
function
()
{
// fake a drop event
var
event
=
new
CustomEvent
(
'
drop
'
,{
stopPropagation
:
function
()
{
return
;},
dataTransfer
:{
getData
:
function
(
type
){
// make sure we are called properly
equal
(
type
,
'
application/json
'
);
return
'
Example.Node
'
;
}
}
});
jsplumb_gadget
.
props
.
element
.
dispatchEvent
(
event
);
jsplumb_gadget
.
render
(
sample_data_empty_graph
);
})
.
then
(
function
()
{
return
jsplumb_gadget
.
getContent
();
})
.
then
(
function
(
content
)
{
var
node
,
graph
=
JSON
.
parse
(
content
).
graph
;
equal
(
1
,
Object
.
keys
(
graph
.
node
).
length
);
node
=
graph
.
node
[
Object
.
keys
(
graph
.
node
)[
0
]];
equal
(
'
Example.Node
'
,
node
.
_class
);
return
RSVP
.
any
([
jsplumb_gadget
.
startService
(),
runTest
()
]);
})
.
fail
(
console
.
error
.
bind
(
this
))
.
always
(
start
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment