remove glob and cheerio from dependencies

This commit is contained in:
Rich Harris
2018-08-19 15:20:14 -04:00
parent 14e5c8e761
commit dba83641e4
23 changed files with 1471 additions and 1317 deletions

View File

@@ -0,0 +1,26 @@
import * as fs from 'fs';
import * as path from 'path';
import * as assert from 'assert';
import clean_html from '../../../src/api/utils/clean_html';
describe('clean_html', () => {
const samples = path.join(__dirname, 'samples');
fs.readdirSync(samples).forEach(dir => {
if (dir[0] === '.') return;
it(dir, () => {
const input = fs.readFileSync(`${samples}/${dir}/input.html`, 'utf-8');
const expected = fs.readFileSync(`${samples}/${dir}/output.html`, 'utf-8');
const actual = clean_html(input);
fs.writeFileSync(`${samples}/${dir}/.actual.html`, actual);
assert.equal(
actual.replace(/\s+$/gm, ''),
expected.replace(/\s+$/gm, '')
);
});
});
});

View File

@@ -0,0 +1,14 @@
<!doctype html>
<html lang="en">
<head>
</head>
<body>
<math>
<ms></ms>
<mo>+</mo>
<mn>3</mn>
<mo>=</mo>
<ms></ms>
</math>
</body>
</html>

View File

@@ -0,0 +1,14 @@
<!doctype html>
<html lang="en">
<head>
</head>
<body>
<math>
<ms><![CDATA[x<y]]></ms>
<mo>+</mo>
<mn>3</mn>
<mo>=</mo>
<ms><![CDATA[x<y3]]></ms>
</math>
</body>
</html>

View File

@@ -0,0 +1,14 @@
<!doctype html>
<html lang="en">
<head>
</head>
<body>
<math>
<ms></ms>
<mo>+</mo>
<mn>3</mn>
<mo>=</mo>
<ms></ms>
</math>
</body>
</html>

View File

@@ -0,0 +1,9 @@
<!doctype html>
<html lang="en">
<head>
</head>
<body>
<a href="keep-me">keep me</a>
</body>
</html>

View File

@@ -0,0 +1,9 @@
<!doctype html>
<html lang="en">
<head>
</head>
<body>
<a href="keep-me">keep me</a>
<!-- <a href="delete-me">delete me</a> -->
</body>
</html>

View File

@@ -0,0 +1,9 @@
<!doctype html>
<html lang="en">
<head>
</head>
<body>
<a href="keep-me">keep me</a>
</body>
</html>

View File

@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
</head>
<body>
<script></script>
<script></script>
<script src="attributes-are-preserved.js"></script>
</body>
</html>

View File

@@ -0,0 +1,16 @@
<!doctype html>
<html lang="en">
<head>
</head>
<body>
<script>
console.log('this should be deleted');
</script>
<script>
console.log('so should this');
</script>
<script src="attributes-are-preserved.js"></script>
</body>
</html>

View File

@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
</head>
<body>
<script></script>
<script></script>
<script src="attributes-are-preserved.js"></script>
</body>
</html>

View File

@@ -1,6 +1,6 @@
const path = require('path');
const assert = require('assert');
const { create_routes } = require('../../../dist/core.ts.js');
import * as path from 'path';
import * as assert from 'assert';
import create_routes from '../../../src/core/create_routes';
describe('create_routes', () => {
it('creates routes', () => {