1 | const unfurl = require('../index.js') |
||
2 | const chai = require('chai') |
||
3 | const expect = chai.expect |
||
4 | chai.use(require('chai-as-promised')) |
||
5 | |||
6 | let srcs = { |
||
7 | twitter: { |
||
8 | url: 'http://localhost:8080/twitter.html', // https://twitter.com/ocdvids/status/856886314138042368 |
||
9 | expected: require('./expected/twitter') |
||
10 | }, |
||
11 | bbc: { |
||
12 | url: 'http://localhost:8080/bbc.html', // http://www.bbc.co.uk/news/technology-39441825 |
||
13 | expected: require('./expected/bbc') |
||
14 | }, |
||
15 | medium: { |
||
16 | url: 'http://localhost:8080/medium.html', // https://medium.freecodecamp.com/the-domain-name-system-dns-is-the-backbone-of-the-internet-heres-how-it-all-works-5706d0afa0fa |
||
17 | expected: require('./expected/medium') |
||
18 | } |
||
19 | } |
||
20 | |||
21 | console.log('srcs', srcs) |
||
0 ignored issues
–
show
Debugging Code
introduced
by
![]() |
|||
22 | |||
23 | describe('input-output', function () { |
||
24 | before(function (done) { |
||
25 | let serveStatic = require('serve-static') |
||
26 | let connect = require('connect') |
||
27 | |||
28 | connect().use(serveStatic(__dirname + '/html')).listen(8080, function () { |
||
0 ignored issues
–
show
|
|||
29 | console.log('Server running on 8080...') |
||
0 ignored issues
–
show
|
|||
30 | done() |
||
31 | }) |
||
32 | }) |
||
33 | |||
34 | it('should resolve metadata for twitter.com (tweet)', function () { |
||
35 | return expect(unfurl(srcs.twitter.url)).to.be.fulfilled.and.to.eventually.become(srcs.twitter.expected) |
||
36 | }) |
||
37 | |||
38 | it('should resolve metadata for bbc.co.uk (post)', function () { |
||
39 | return expect(unfurl(srcs.bbc.url)).to.be.fulfilled.and.to.eventually.become(srcs.bbc.expected) |
||
40 | }) |
||
41 | |||
42 | it('should resolve metadata for medium.com (post)', function () { |
||
43 | return expect(unfurl(srcs.medium.url)).to.be.fulfilled.and.to.eventually.become(srcs.medium.expected) |
||
44 | }) |
||
45 | }) |
||
46 |