mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
chore: add test for repeat helper
Several test cleanups and minor test fixes
This commit is contained in:
parent
5f5304ccaa
commit
df76f984a3
10
Gruntfile.js
10
Gruntfile.js
|
@ -144,7 +144,6 @@ module.exports = function (grunt) {
|
|||
}
|
||||
},
|
||||
single: {
|
||||
src: 'test/node/**/*.js',
|
||||
options: {
|
||||
globals: ['should'],
|
||||
timeout: 3000,
|
||||
|
@ -153,7 +152,7 @@ module.exports = function (grunt) {
|
|||
}
|
||||
},
|
||||
cli: {
|
||||
src: 'test/node/testsuite.cli.js',
|
||||
src: 'test/unit/cli.js',
|
||||
options: {
|
||||
globals: ['should'],
|
||||
timeout: 3000,
|
||||
|
@ -208,14 +207,12 @@ module.exports = function (grunt) {
|
|||
/**
|
||||
* Run a single test
|
||||
*/
|
||||
grunt.registerTask('single-test', function (grep) {
|
||||
grunt.registerTask('single-test', function (file) {
|
||||
'use strict';
|
||||
grunt.config.merge({
|
||||
simplemocha: {
|
||||
single: {
|
||||
options: {
|
||||
grep: grep
|
||||
}
|
||||
src: file
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -230,6 +227,7 @@ module.exports = function (grunt) {
|
|||
grunt.registerTask('test-functional', ['concat:test', 'simplemocha:functional', 'clean']);
|
||||
grunt.registerTask('test-unit', ['concat:test', 'simplemocha:unit', 'clean']);
|
||||
grunt.registerTask('test-cli', ['clean', 'lint', 'concat:test', 'simplemocha:cli', 'clean']);
|
||||
|
||||
grunt.registerTask('performance', ['concat:test', 'performancejs', 'clean']);
|
||||
grunt.registerTask('build', ['test', 'concat:dist', 'concat:cli', 'uglify:dist', 'uglify:cli', 'endline']);
|
||||
grunt.registerTask('build-without-test', ['concat:dist', 'uglify', 'endline']);
|
||||
|
|
BIN
dist/showdown.js
vendored
BIN
dist/showdown.js
vendored
Binary file not shown.
BIN
dist/showdown.js.map
vendored
BIN
dist/showdown.js.map
vendored
Binary file not shown.
BIN
dist/showdown.min.js
vendored
BIN
dist/showdown.min.js
vendored
Binary file not shown.
BIN
dist/showdown.min.js.map
vendored
BIN
dist/showdown.min.js.map
vendored
Binary file not shown.
|
@ -363,12 +363,16 @@ showdown.helper.encodeEmailAddress = function (mail) {
|
|||
/**
|
||||
* String.prototype.repeat polyfill
|
||||
*
|
||||
* @param str
|
||||
* @param count
|
||||
* @param {string} str
|
||||
* @param {int} count
|
||||
* @returns {string}
|
||||
*/
|
||||
function repeat (str, count) {
|
||||
showdown.helper.repeat = function (str, count) {
|
||||
'use strict';
|
||||
// use built-in method if it's available
|
||||
if (!showdown.helper.isUndefined(String.prototype.repeat)) {
|
||||
return str.repeat(count);
|
||||
}
|
||||
str = '' + str;
|
||||
if (count < 0) {
|
||||
throw new RangeError('repeat count must be non-negative');
|
||||
|
@ -396,7 +400,7 @@ function repeat (str, count) {
|
|||
}
|
||||
str += str.substring(0, maxCount - str.length);
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* String.prototype.padEnd polyfill
|
||||
|
@ -418,7 +422,7 @@ showdown.helper.padEnd = function padEnd (str, targetLength, padString) {
|
|||
} else {
|
||||
targetLength = targetLength - str.length;
|
||||
if (targetLength > padString.length) {
|
||||
padString += repeat(padString, targetLength / padString.length); //append to original to ensure we are longer than needed
|
||||
padString += showdown.helper.repeat(padString, targetLength / padString.length); //append to original to ensure we are longer than needed
|
||||
}
|
||||
return String(str) + padString.slice(0,targetLength);
|
||||
}
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
/**
|
||||
* Created by Estevao on 15-01-2015.
|
||||
*/
|
||||
require('source-map-support').install();
|
||||
require('chai').should();
|
||||
require('sinon');
|
||||
var showdown = require('../../.build/showdown.js');
|
||||
|
||||
describe('showdown.Converter', function () {
|
||||
'use strict';
|
||||
|
||||
require('source-map-support').install();
|
||||
require('chai').should();
|
||||
|
||||
var showdown = require('../../.build/showdown.js');
|
||||
|
||||
describe('Converter.options extensions', function () {
|
||||
var runCount;
|
||||
showdown.extension('testext', function () {
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
/**
|
||||
* Created by Estevao on 15-01-2015.
|
||||
*/
|
||||
require('source-map-support').install();
|
||||
require('chai').should();
|
||||
require('sinon');
|
||||
var showdown = require('../../.build/showdown.js');
|
||||
|
||||
describe('showdown.Converter', function () {
|
||||
'use strict';
|
||||
|
||||
require('source-map-support').install();
|
||||
require('chai').should();
|
||||
var jsdom = require('jsdom'),
|
||||
document = new jsdom.JSDOM('', {}).window.document, // jshint ignore:line
|
||||
showdown = require('../../.build/showdown.js');
|
||||
|
||||
describe('makeMarkdown()', function () {
|
||||
var converter = new showdown.Converter();
|
||||
|
@ -18,7 +17,7 @@ describe('showdown.Converter', function () {
|
|||
var html = '<a href="/somefoo.html">a link</a>\n';
|
||||
var md = '[a link](</somefoo.html>)';
|
||||
|
||||
converter.makeMarkdown(html, document).should.equal(md);
|
||||
converter.makeMarkdown(html).should.equal(md);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
/**
|
||||
* Created by Estevao on 27/01/2017.
|
||||
* Created by Tivie on 27/01/2017.
|
||||
*/
|
||||
require('source-map-support').install();
|
||||
require('chai').should();
|
||||
require('sinon');
|
||||
var showdown = require('../../.build/showdown.js');
|
||||
/*jshint expr: true*/
|
||||
/*jshint -W053 */
|
||||
/*jshint -W010 */
|
||||
/*jshint -W009 */
|
||||
var showdown = require('../../.build/showdown.js');
|
||||
|
||||
describe('encodeEmailAddress()', function () {
|
||||
'use strict';
|
||||
|
@ -245,3 +248,12 @@ describe('matchRecursiveRegExp()', function () {
|
|||
|
||||
});
|
||||
|
||||
describe('repeat()', function () {
|
||||
'use strict';
|
||||
it('work produce the same output as String.prototype.repeat()', function () {
|
||||
var str = 'foo',
|
||||
expected = str.repeat(100),
|
||||
actual = showdown.helper.repeat(str, 100);
|
||||
expected.should.equal(actual);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
require('source-map-support').install();
|
||||
require('chai').should();
|
||||
require('sinon');
|
||||
var expect = require('chai').expect,
|
||||
showdown = require('../../.build/showdown.js');
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user