Skip to content

Commit

Permalink
Test delegation to another type installed in the child expect via thi…
Browse files Browse the repository at this point in the history
…s.baseType
  • Loading branch information
papandreou committed Mar 6, 2017
1 parent 9f25af4 commit c4fd18a
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/api/child.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,5 +219,34 @@ describe('#child', function () {
});
childExpect('abc', 'foo', 'to equal', 'abcfoo');
});

it('#inspect should be able to delegate to another private type', function () {
childExpect.addType({
name: 'yadda',
identify: function (obj) {
return /^yadda/.test(obj);
},
inspect: function (value, depth, output) {
output.fancyQuotes(value);
}
});
childExpect.addType({
name: 'yaddayadda',
base: 'yadda',
identify: function (obj) {
return /^yaddayadda/.test(obj);
},
inspect: function (value, depth, output, inspect) {
this.baseType.inspect(value, depth, output);
output.fancyQuotes(value);
}
});

childExpect.addStyle('fancyQuotes', function (text) {
this.text('>>').text(text).text('<<');
});

expect(childExpect.createOutput('text').appendInspected('yaddayaddafoo').toString(), 'to equal', '>>yaddayaddafoo<<>>yaddayaddafoo<<');
});
});

0 comments on commit c4fd18a

Please sign in to comment.