add tests from origin/develop

This commit is contained in:
webzwo0i 2020-08-30 14:19:09 +02:00
parent 6a3e4c69b8
commit 2df2d7d60a
71 changed files with 18931 additions and 4032 deletions

View file

@ -1,10 +1,12 @@
var assert = require('assert')
os = require('os'),
fs = require('fs'),
path = require('path'),
TidyHtml = null,
Settings = null;
var npm = require("../../../../src/node_modules/npm/lib/npm.js");
var nodeify = require('../../../../src/node_modules/nodeify');
describe('tidyHtml', function() {
before(function(done) {
@ -16,6 +18,10 @@ describe('tidyHtml', function() {
});
});
function tidy(file, callback) {
return nodeify(TidyHtml.tidy(file), callback);
}
it('Tidies HTML', function(done) {
// If the user hasn't configured Tidy, we skip this tests as it's required for this test
if (!Settings.tidyHtml) {
@ -23,10 +29,11 @@ describe('tidyHtml', function() {
}
// Try to tidy up a bad HTML file
var tmpDir = process.env.TEMP || "/tmp";
const tmpDir = os.tmpdir();
var tmpFile = path.join(tmpDir, 'tmp_' + (Math.floor(Math.random() * 1000000)) + '.html')
fs.writeFileSync(tmpFile, '<html><body><p>a paragraph</p><li>List without outer UL</li>trailing closing p</p></body></html>');
TidyHtml.tidy(tmpFile, function(err){
tidy(tmpFile, function(err){
assert.ok(!err);
// Read the file again
@ -55,7 +62,7 @@ describe('tidyHtml', function() {
this.skip();
}
TidyHtml.tidy('/some/none/existing/file.html', function(err) {
tidy('/some/none/existing/file.html', function(err) {
assert.ok(err);
return done();
});