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
Show 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*/
/*jslint nomen: true*/
/*global console, RSVP, renderJS, QUnit, window, document*/
/*global console, RSVP, renderJS, QUnit, window, document,
__RenderJSGadget, URL*/
(
function
(
document
,
renderJS
,
QUnit
)
{
(
function
(
document
,
renderJS
,
QUnit
)
{
"
use strict
"
;
"
use strict
"
;
var
test
=
QUnit
.
test
,
var
test
=
QUnit
.
test
,
module
=
QUnit
.
module
,
module
=
QUnit
.
module
,
root_gadget_defer
=
RSVP
.
defer
(),
RenderJSGadget
=
__RenderJSGadget
,
// root_gadget_defer = RSVP.defer(),
jsonform_url
=
'
../jsonform.gadget.html
'
;
jsonform_url
=
'
../jsonform.gadget.html
'
;
// Keep track of the root gadget
function
create_gadget
(
__aq_parent
)
{
renderJS
(
window
)
var
gadget
=
new
RenderJSGadget
();
.
ready
(
function
()
{
gadget
.
__sub_gadget_dict
=
{};
root_gadget_defer
.
resolve
(
this
);
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
"
,
{
module
(
"
jsonform.general
"
);
beforeEach
:
function
()
{
test
(
'
JSON Form render
'
,
function
(
assert
)
{
renderJS
.
clearGadgetKlassList
();
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
"
});
})
.
push
(
function
(
element
)
{
assert
.
ok
(
element
,
"
gadget rendered
"
);
})
.
push
(
undefined
,
function
(
error
)
{
assert
.
notOk
(
error
,
"
issue in gadget
"
);
})
.
push
(
function
()
{
done
();
});
});
test
(
'
JSON Form gadget can be loaded
'
,
function
(
assert
)
{
});
var
done
=
assert
.
async
();
assert
.
expect
(
1
);
test
(
'
JSON Form getContent
'
,
function
(
assert
)
{
root_gadget_defer
.
promise
var
done
=
assert
.
async
(),
.
then
(
function
(
root_gadget
)
{
gadget
,
return
root_gadget
.
declareGadget
(
key
=
"
foo_key
"
,
jsonform_url
,
schema
=
{
{
"
properties
"
:
{
scope
:
"
iframe
"
,
"
foo
"
:
{
"
type
"
:
"
integer
"
},
element
:
document
.
querySelector
(
'
#qunit-fixture
'
)
"
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
();
})
})
.
then
(
function
(
gadget
)
{
.
push
(
function
(
json_document
)
{
assert
.
ok
(
true
,
gadget
);
assert
.
deepEqual
(
schema
,
schema_orig
,
"
schema not change (side effect absent)
"
);
assert
.
deepEqual
(
JSON
.
parse
(
json_document
[
key
]),
value
,
"
returned value equal
"
);
})
})
.
fail
(
function
(
error
)
{
.
push
(
undefined
,
function
(
error
)
{
assert
.
ok
(
false
,
error
);
assert
.
notOk
(
error
,
"
issue in gadget
"
);
console
.
warn
(
error
);
throw
error
;
})
})
.
always
(
function
()
{
.
push
(
function
()
{
done
();
done
();
});
});
});
});
}(
document
,
renderJS
,
QUnit
));
}(
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