File tree Expand file tree Collapse file tree 4 files changed +8679
-4
lines changed Expand file tree Collapse file tree 4 files changed +8679
-4
lines changed Original file line number Diff line number Diff line change @@ -111,10 +111,10 @@ module.exports = class Flatten
111
111
blocks .push b
112
112
113
113
blockIdx = item .content .indexOf block
114
- return callback () if blockIdx is - 1
114
+ # return callback() if blockIdx is -1
115
115
unless blocks .length
116
116
# Empty block, remove
117
- item .content = item . content .splice blockIdx, 1
117
+ item .content .splice blockIdx, 1
118
118
return callback ()
119
119
if blocks .length is 1
120
120
# Block returned only one block, update values
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " html-flatten" ,
3
- "version" : " 0.1.9 " ,
3
+ "version" : " 0.1.10 " ,
4
4
"description" : " flattens arbitrary html into a sane structure" ,
5
5
"main" : " index.coffee" ,
6
6
"scripts" : {
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ describe 'Cleanup', ->
29
29
done ()
30
30
31
31
describe ' cleaning a dirty HTML structure' , ->
32
- it ' produce clean blocks' , (done ) ->
32
+ it ' should produce clean blocks' , (done ) ->
33
33
item =
34
34
content : [
35
35
id : ' foo'
@@ -58,3 +58,18 @@ describe 'Cleanup', ->
58
58
html : ' <p>Foobar</p>'
59
59
chai .expect (item .content [2 ]).to .eql orig .content [1 ]
60
60
done ()
61
+
62
+ describe ' cleaning up a full item' , ->
63
+ it ' should produce clean blocks' , (done ) ->
64
+ fs = require ' fs'
65
+ path = require ' path'
66
+ item = JSON .parse fs .readFileSync __dirname + ' /fixtures/put.json' , ' utf-8'
67
+ orig = JSON .parse JSON .stringify item
68
+ f .flattenItem item, ->
69
+ types = item .content .map (b) -> b .type
70
+ chai .expect (types).to .eql [
71
+ ' image'
72
+ ' image'
73
+ ' image'
74
+ ]
75
+ done ()
You can’t perform that action at this time.
0 commit comments