build(aio): truncate API overview parameters at one line
This commit is contained in:

committed by
Igor Minar

parent
a7ea0086ee
commit
998049ec9b
13
aio/tools/transforms/angular-base-package/rendering/truncateFirstLine.js
vendored
Normal file
13
aio/tools/transforms/angular-base-package/rendering/truncateFirstLine.js
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
module.exports = function() {
|
||||
return {
|
||||
name: 'truncateFirstLine',
|
||||
process: function(str) {
|
||||
const parts = str && str.split && str.split(/\r?\n/);
|
||||
if (parts && parts.length > 1) {
|
||||
return parts[0] + '...';
|
||||
} else {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
@ -0,0 +1,19 @@
|
||||
var factory = require('./truncateFirstLine');
|
||||
|
||||
describe('truncateFirstLine filter', function() {
|
||||
var filter;
|
||||
|
||||
beforeEach(function() { filter = factory(); });
|
||||
|
||||
it('should be called "truncateFirstLine"',
|
||||
function() { expect(filter.name).toEqual('truncateFirstLine'); });
|
||||
|
||||
it('should return the whole string if only one line', function() {
|
||||
expect(filter.process('this is a pretty long string that only exists on one line'))
|
||||
.toEqual('this is a pretty long string that only exists on one line');
|
||||
});
|
||||
|
||||
it('should return the first line and an ellipsis if there is more than one line', function() {
|
||||
expect(filter.process('some text\n \nmore text\n \n')).toEqual('some text...');
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user