mirror of
https://github.com/misskey-dev/summaly.git
synced 2025-07-01 15:49:59 +09:00
[WIP] test
This commit is contained in:
@ -65,6 +65,10 @@ console.log(summary); // will be ... ↓
|
|||||||
*/
|
*/
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Testing
|
||||||
|
-------
|
||||||
|
`npm run test`
|
||||||
|
|
||||||
License
|
License
|
||||||
-------
|
-------
|
||||||
[MIT](LICENSE)
|
[MIT](LICENSE)
|
||||||
|
@ -9,16 +9,19 @@
|
|||||||
"main": "./built/index.js",
|
"main": "./built/index.js",
|
||||||
"types": "./built/index.d.ts",
|
"types": "./built/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "gulp build"
|
"build": "gulp build",
|
||||||
|
"test": "mocha --harmony"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/chai": "3.4.34",
|
"@types/chai": "3.4.34",
|
||||||
"@types/debug": "0.0.29",
|
"@types/debug": "0.0.29",
|
||||||
|
"@types/express": "4.0.35",
|
||||||
"@types/mocha": "2.2.39",
|
"@types/mocha": "2.2.39",
|
||||||
"@types/node": "7.0.5",
|
"@types/node": "7.0.5",
|
||||||
"@types/request": "0.0.39",
|
"@types/request": "0.0.39",
|
||||||
"chai": "3.5.0",
|
"chai": "3.5.0",
|
||||||
"event-stream": "3.3.4",
|
"event-stream": "3.3.4",
|
||||||
|
"express": "4.14.1",
|
||||||
"gulp": "3.9.1",
|
"gulp": "3.9.1",
|
||||||
"gulp-typescript": "3.1.4",
|
"gulp-typescript": "3.1.4",
|
||||||
"mocha": "3.2.0",
|
"mocha": "3.2.0",
|
||||||
|
12
test/htmls/basic.html
Normal file
12
test/htmls/basic.html
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<!doctype html>
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>KISS principle</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>KISS principle</h1>
|
||||||
|
<p>KISS is an acronym for "Keep it simple, stupid" as a design principle noted by the U.S. Navy in 1960.</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
11
test/htmls/no-metas.html
Normal file
11
test/htmls/no-metas.html
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<!doctype html>
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>KISS principle</h1>
|
||||||
|
<p>KISS is an acronym for "Keep it simple, stupid" as a design principle noted by the U.S. Navy in 1960.</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
13
test/htmls/og-description.html
Normal file
13
test/htmls/og-description.html
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<!doctype html>
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta property="og:description" content="KISS is an acronym for 'Keep it simple, stupid' as a design principle noted by the U.S. Navy in 1960.">
|
||||||
|
<title>YEE HAW</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Yo</h1>
|
||||||
|
<p>Hey hey hey syuilo.</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
13
test/htmls/og-title.html
Normal file
13
test/htmls/og-title.html
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<!doctype html>
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta property="og:title" content="KISS principle">
|
||||||
|
<title>YEE HAW</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Yo</h1>
|
||||||
|
<p>Hey hey hey syuilo.</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -2,8 +2,9 @@
|
|||||||
* Tests!
|
* Tests!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import http from 'http';
|
|
||||||
import chai from 'chai';
|
import chai from 'chai';
|
||||||
|
import * as express from 'express';
|
||||||
|
|
||||||
import summaly from '../';
|
import summaly from '../';
|
||||||
|
|
||||||
Error.stackTraceLimit = Infinity;
|
Error.stackTraceLimit = Infinity;
|
||||||
@ -16,6 +17,15 @@ process.on('unhandledRejection', console.dir);
|
|||||||
|
|
||||||
const should = chai.should();
|
const should = chai.should();
|
||||||
|
|
||||||
it('well-defined meta site', async () => {
|
describe('OGP', () => {
|
||||||
should.equal(await summaly('localhost:0'), 'hoge');
|
it('title', () => {
|
||||||
|
const server = express();
|
||||||
|
server.use((req, res) => {
|
||||||
|
res.sendFile('./htmls/og-title.html');
|
||||||
|
});
|
||||||
|
server.listen(0, async () => {
|
||||||
|
const summary = await summaly('localhost:0');
|
||||||
|
should.equal(summary.title, 'KISS principle');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user