mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-12 03:05:12 +00:00
remove glob and cheerio from dependencies
This commit is contained in:
26
test/unit/clean_html/index.ts
Normal file
26
test/unit/clean_html/index.ts
Normal 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, '')
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
14
test/unit/clean_html/samples/removes-cdata/.actual.html
Normal file
14
test/unit/clean_html/samples/removes-cdata/.actual.html
Normal 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>
|
||||
14
test/unit/clean_html/samples/removes-cdata/input.html
Normal file
14
test/unit/clean_html/samples/removes-cdata/input.html
Normal 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>
|
||||
14
test/unit/clean_html/samples/removes-cdata/output.html
Normal file
14
test/unit/clean_html/samples/removes-cdata/output.html
Normal 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>
|
||||
@@ -0,0 +1,9 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<a href="keep-me">keep me</a>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
9
test/unit/clean_html/samples/removes-comments/input.html
Normal file
9
test/unit/clean_html/samples/removes-comments/input.html
Normal 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>
|
||||
@@ -0,0 +1,9 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<a href="keep-me">keep me</a>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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', () => {
|
||||
Reference in New Issue
Block a user