|
1 | 1 | var test = require('tape')
|
| 2 | +var nock = require('nock') |
2 | 3 | var treeBuild = require('../treeBuild')
|
3 | 4 |
|
4 |
| -var shallowMarkdown = |
5 |
| - 'Test string, with [normal link](www.google.com), ' + |
6 |
| - 'a +[hypermarkdown]("http://www.github.com/mixmix/hypermarkdown/master/blob/README.md") transclusion, ' + |
7 |
| - 'and an transclusion with a [reference][] ' + |
8 |
| - '[ ]: http://www.github.com/mixmix/hypermarkdown/master/blob/README.md' |
| 5 | +var mockDomain = 'http://wwww.mock.com' |
| 6 | +var plain = { |
| 7 | + 'path': '/plain.md', |
| 8 | + 'content': 'Test string, with [normal link](www.google.com), nice ' |
| 9 | +} |
| 10 | +var transclude = { |
| 11 | + 'path': '/transclude.md', |
| 12 | + 'content': 'a +[hypermarkdown](http://wwww.mock.com/_target.md) transclusion.' |
| 13 | +} |
| 14 | +var refTransclude = { |
| 15 | + 'path': '/reference_transclude.md', |
| 16 | + 'content': 'and an transclusion which uses [implicit reference][targetPartialUrl] break' + |
| 17 | + '[targetPartialUrl]: http://wwww.mock.com/_target.md' |
| 18 | +} |
| 19 | +var transcludeTarget = { |
| 20 | + 'path': '/_target.md', |
| 21 | + 'content': 'My sweet **transcluded** text!' |
| 22 | +} |
9 | 23 |
|
10 | 24 | module.exports = function() {
|
11 |
| - test('youtubeAutoEmbed', function(t) { |
12 |
| - t.equal( |
13 |
| - ) |
14 |
| - t.equal( |
15 |
| - ) |
16 |
| - t.equal( |
17 |
| - ) |
18 |
| - |
| 25 | + test('treeBuild', function(t) { |
| 26 | + |
| 27 | + var scope = nock(mockDomain) |
| 28 | + .get(plain.path).reply(200, plain.content) |
| 29 | + .get(transclude.path).reply(200, transclude.content) |
| 30 | + .get(refTransclude.path).reply(200, refTransclude.content) |
| 31 | + .get(transcludeTarget.path).reply(200, transcludeTarget.content) |
| 32 | + |
| 33 | + |
| 34 | + treeBuild(mockDomain + plain.path, function(err, res) { |
| 35 | + if (err) throw err |
| 36 | + t.deepEqual( res['children'], [], 'it builds a tree one level deep when there are no transclusion links') |
| 37 | + }) |
19 | 38 |
|
| 39 | + treeBuild(mockDomain + transclude.path, function(err, res) { |
| 40 | + if (err) throw err |
| 41 | + t.notDeepEqual( res['children'], [], 'it is only 2 levels deep') |
| 42 | + t.deepEqual( res['children'][0]['content'], transcludeTarget.content, 'it loads transcluded branch text') |
| 43 | + t.deepEqual( res['children'][0]['url'], mockDomain + transcludeTarget.path, 'it loads transcluded branch url') |
| 44 | + }) |
| 45 | + |
| 46 | + treeBuild(mockDomain + refTransclude.path, function(err, res) { |
| 47 | + if (err) throw err |
| 48 | + t.notDeepEqual( res['children'], [], 'it is only 2 levels deep') |
| 49 | + t.deepEqual( res['children'][0]['content'], transcludeTarget.content, 'it loads transcluded branch text') |
| 50 | + t.deepEqual( res['children'][0]['url'], mockDomain + transcludeTarget.path, 'it loads transcluded branch url') |
| 51 | + }) |
| 52 | + |
| 53 | + //scope.done() |
20 | 54 | t.end()
|
21 | 55 | })
|
22 | 56 | }
|
23 | 57 |
|
| 58 | + |
| 59 | +function returnChildrenCallback( err, response ) { |
| 60 | + if (err) console.log( err ) |
| 61 | + |
| 62 | + console.log(response) |
| 63 | + //console.log(response['content']) |
| 64 | + console.log( response['children'] ) |
| 65 | + return response['children'] |
| 66 | +} |
0 commit comments