[WIP] test

This commit is contained in:
syuilo
2017-02-08 15:17:28 +09:00
parent 5bfb48a38e
commit e352fa13ad
7 changed files with 70 additions and 4 deletions

View File

@ -65,6 +65,10 @@ console.log(summary); // will be ... ↓
*/
```
Testing
-------
`npm run test`
License
-------
[MIT](LICENSE)

View File

@ -9,16 +9,19 @@
"main": "./built/index.js",
"types": "./built/index.d.ts",
"scripts": {
"build": "gulp build"
"build": "gulp build",
"test": "mocha --harmony"
},
"devDependencies": {
"@types/chai": "3.4.34",
"@types/debug": "0.0.29",
"@types/express": "4.0.35",
"@types/mocha": "2.2.39",
"@types/node": "7.0.5",
"@types/request": "0.0.39",
"chai": "3.5.0",
"event-stream": "3.3.4",
"express": "4.14.1",
"gulp": "3.9.1",
"gulp-typescript": "3.1.4",
"mocha": "3.2.0",

12
test/htmls/basic.html Normal file
View 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
View 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>

View 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
View 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>

View File

@ -2,8 +2,9 @@
* Tests!
*/
import http from 'http';
import chai from 'chai';
import * as express from 'express';
import summaly from '../';
Error.stackTraceLimit = Infinity;
@ -16,6 +17,15 @@ process.on('unhandledRejection', console.dir);
const should = chai.should();
it('well-defined meta site', async () => {
should.equal(await summaly('localhost:0'), 'hoge');
describe('OGP', () => {
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');
});
});
});