Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
rjs_json_form
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
rjs_json_form
Commits
e61f1354
Commit
e61f1354
authored
Aug 02, 2018
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: add getContent test fix render() test
parent
d1f6bc3a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
32 deletions
+80
-32
test/jsonform_test.js
test/jsonform_test.js
+80
-32
No files found.
test/jsonform_test.js
View file @
e61f1354
/*jslint nomen: true*/
/*global console, RSVP, renderJS, QUnit, window, document*/
/*global console, RSVP, renderJS, QUnit, window, document,
__RenderJSGadget, URL*/
(
function
(
document
,
renderJS
,
QUnit
)
{
"
use strict
"
;
var
test
=
QUnit
.
test
,
module
=
QUnit
.
module
,
root_gadget_defer
=
RSVP
.
defer
(),
RenderJSGadget
=
__RenderJSGadget
,
// root_gadget_defer = RSVP.defer(),
jsonform_url
=
'
../jsonform.gadget.html
'
;
// Keep track of the root gadget
renderJS
(
window
)
.
ready
(
function
()
{
root_gadget_defer
.
resolve
(
this
);
function
create_gadget
(
__aq_parent
)
{
var
gadget
=
new
RenderJSGadget
();
gadget
.
__sub_gadget_dict
=
{};
gadget
.
__aq_parent
=
__aq_parent
;
// return gadget.declareGadget(jsonform_url, {
return
gadget
.
declareGadget
((
new
URL
(
jsonform_url
,
window
.
location
)),
{
// sandbox: "iframe",
element
:
document
.
querySelector
(
'
#qunit-fixture
'
),
scope
:
'
foobar
'
});
}
/////////////////////////////////////////////////////////////////
//
declareGadget
//
render
/////////////////////////////////////////////////////////////////
module
(
"
jsonform.declareGadget
"
,
{
beforeEach
:
function
()
{
renderJS
.
clearGadgetKlassList
();
}
});
test
(
'
JSON Form gadget can be loaded
'
,
function
(
assert
)
{
var
done
=
assert
.
async
();
assert
.
expect
(
1
);
root_gadget_defer
.
promise
.
then
(
function
(
root_gadget
)
{
return
root_gadget
.
declareGadget
(
jsonform_url
,
{
scope
:
"
iframe
"
,
element
:
document
.
querySelector
(
'
#qunit-fixture
'
)
}
);
module
(
"
jsonform.general
"
);
test
(
'
JSON Form render
'
,
function
(
assert
)
{
var
done
=
assert
.
async
(),
gadget
;
create_gadget
(
function
(
method_name
,
argument_list
)
{
if
(
method_name
===
"
notifyValid
"
)
{
assert
.
ok
(
argument_list
,
"
form correctly filled
"
);
return
"
result correctly fetched from parent
"
;
}
throw
new
renderJS
.
AcquisitionError
(
"
Can not handle
"
+
method_name
);
})
.
push
(
function
(
g
)
{
gadget
=
g
;
return
gadget
.
render
({
key
:
"
foo
"
});
})
.
then
(
function
(
gadge
t
)
{
assert
.
ok
(
true
,
gadget
);
.
push
(
function
(
elemen
t
)
{
assert
.
ok
(
element
,
"
gadget rendered
"
);
})
.
fail
(
function
(
error
)
{
assert
.
ok
(
false
,
error
);
console
.
warn
(
error
);
throw
error
;
.
push
(
undefined
,
function
(
error
)
{
assert
.
notOk
(
error
,
"
issue in gadget
"
);
})
.
always
(
function
()
{
.
push
(
function
()
{
done
();
});
});
}(
document
,
renderJS
,
QUnit
));
test
(
'
JSON Form getContent
'
,
function
(
assert
)
{
var
done
=
assert
.
async
(),
gadget
,
key
=
"
foo_key
"
,
schema
=
{
"
properties
"
:
{
"
foo
"
:
{
"
type
"
:
"
integer
"
},
"
bar
"
:
{
"
type
"
:
"
string
"
}
},
required
:
[
"
foo
"
]
},
value
=
{
foo
:
1
,
bar
:
"
fsdfs
"
},
schema_orig
=
JSON
.
parse
(
JSON
.
stringify
(
schema
));
create_gadget
(
function
(
method_name
,
argument_list
)
{
if
(
method_name
===
"
notifyValid
"
)
{
assert
.
ok
(
argument_list
,
"
form correctly filled
"
);
return
"
result correctly fetched from parent
"
;
}
throw
new
renderJS
.
AcquisitionError
(
"
Can not handle
"
+
method_name
);
})
.
push
(
function
(
g
)
{
gadget
=
g
;
return
gadget
.
render
({
key
:
key
,
schema
:
schema
,
value
:
value
});
})
.
push
(
function
(
element
)
{
assert
.
ok
(
element
,
"
gadget rendered
"
);
return
gadget
.
getContent
();
})
.
push
(
function
(
json_document
)
{
assert
.
deepEqual
(
schema
,
schema_orig
,
"
schema not change (side effect absent)
"
);
assert
.
deepEqual
(
JSON
.
parse
(
json_document
[
key
]),
value
,
"
returned value equal
"
);
})
.
push
(
undefined
,
function
(
error
)
{
assert
.
notOk
(
error
,
"
issue in gadget
"
);
})
.
push
(
function
()
{
done
();
});
});
}(
document
,
renderJS
,
QUnit
));
\ No newline at end of file
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