Skip to content

Commit

Permalink
[WIP] test
Browse files Browse the repository at this point in the history
  • Loading branch information
syuilo committed Feb 8, 2017
1 parent 5bfb48a commit e352fa1
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ console.log(summary); // will be ... ↓
*/
```

Testing
-------
`npm run test`

License
-------
[MIT](LICENSE)
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 12 additions & 0 deletions test/htmls/basic.html
Original file line number Diff line number Diff line change
@@ -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 changes: 11 additions & 0 deletions test/htmls/no-metas.html
Original file line number Diff line number Diff line change
@@ -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 changes: 13 additions & 0 deletions test/htmls/og-description.html
Original file line number Diff line number Diff line change
@@ -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 changes: 13 additions & 0 deletions test/htmls/og-title.html
Original file line number Diff line number Diff line change
@@ -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>
16 changes: 13 additions & 3 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
* Tests!
*/

import http from 'http';
import chai from 'chai';
import * as express from 'express';

import summaly from '../';

Error.stackTraceLimit = Infinity;
Expand All @@ -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');
});
});
});

0 comments on commit e352fa1

Please sign in to comment.