Skip to content

Commit

Permalink
tests: improvement of coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Harris Tzovanakis <me@drjova.com>
  • Loading branch information
drjova committed Sep 2, 2016
1 parent f0c65e2 commit 6c3ffdd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
5 changes: 4 additions & 1 deletion test/e2e/invenio-records-js/invenioRecordsActionsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ describe('testing directive invenio-records-actions', function() {
// Complile&Digest here to catch the event
// The directive's template
template = '<invenio-records ' +
'extra-params=\'{"data": {"jessica": "jones"}}\' '+
'action="gotham city://batman/sucess" ' +
'form="/example/static/json/form.json" ' +
'schema="/example/static/json/schema.json"> ' +
Expand All @@ -116,6 +117,8 @@ describe('testing directive invenio-records-actions', function() {
scope.$digest();
// The rendered buttons should be ``2``
expect(template.find('.btn').length).to.be.equal(5);

expect(scope.recordsVM.invenioRecordsArgs.data.jessica).to.be.equal('jones');
});

it('should trigger action event for save', function() {
Expand Down Expand Up @@ -470,7 +473,7 @@ describe('testing directive invenio-records-actions', function() {
template = '<invenio-records ' +
'initialization="jessica jones://herley/quinn" ' +
'form="/example/static/json/form.json" ' +
'record=\'{"a": "", "b": "c"}\' ' +
'record=\'{"a": "", "b": [null]}\' ' +
'schema="/example/static/json/schema.json"> ' +
'<invenio-records-actions ' +
'template="src/invenio-records-js/templates/actions.html"> '+
Expand Down
25 changes: 25 additions & 0 deletions test/e2e/invenio-records-js/invenioRecordsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,29 @@ describe('testing directive invenio-records', function() {
// Digest
scope.$digest();
});

it('should have the links from the directive', function() {
// Spy the broadcast
var spy = sinon.spy($rootScope, '$broadcast');

// Complile&Digest here to catch the event
// The directive's template
template = '<invenio-records ' +
'extra-params="{}" ' +
'record=\'{}\' ' +
'form="/static/json/form.json" ' +
'links=\'{"self": "/jessica jones"}\'' +
'schema="/static/json/records.json"> ' +
'></invenio-records>';
// Compile
template = $compile(template)(scope);
// Digest
scope.$digest();

// Check if the event has been triggered
expect(spy.calledWith('invenio.records.init')).to.be.true;
$httpBackend.flush();
scope.$digest();
expect(spy.calledWith('invenio.records.endpoints.updated')).to.be.true;
});
});

0 comments on commit 6c3ffdd

Please sign in to comment.