Commit 2cd4c09c by Edgar Hipp

better tests for qrcode module

parent 57c3254c
...@@ -124,37 +124,38 @@ describe 'image adding with {% image} syntax', ()-> ...@@ -124,37 +124,38 @@ describe 'image adding with {% image} syntax', ()->
describe 'qrcode replacing',-> describe 'qrcode replacing',->
before (done)-> describe 'shoud work without loops',->
name='qrExample.docx' zip=null
before (done)->
name='qrExample.docx'
imageModule=new ImageModule({qrCode:true}) imageModule=new ImageModule({qrCode:true})
imageModule.getImageFromData=(imgData)-> imageModule.getImageFromData=(imgData)->
d=fs.readFileSync('examples/'+imgData,'binary') d=fs.readFileSync('examples/'+imgData,'binary')
d d
imageModule.finished=()-> imageModule.finished=()->
zip=doc.getZip() zip=doc.getZip()
buffer=zip.generate({type:"nodebuffer"}) buffer=zip.generate({type:"nodebuffer"})
fs.writeFile("test_qr.docx",buffer); fs.writeFile("test_qr.docx",buffer);
done() done()
doc=docX[name] doc=docX[name]
.load(docX[name].loadedContent) .load(docX[name].loadedContent)
.setData({image:'image'}) .setData({image:'image'})
doc.attachModule(imageModule)
doc
.render()
it 'shoud work with simple',->
it 'should be 1',-> doc.attachModule(imageModule)
expect(1).to.equal(1)
doc
.render()
it 'should work with simple',->
images=zip.file(/media\/.*.png/)
expect(images.length).to.equal(2)
expect(images[0].asText().length).to.equal(826)
expect(images[1].asText().length).to.equal(17417)
# imageFile=zip.files['word/media/image_generated_1.png'] # imageFile=zip.files['word/media/image_generated_1.png']
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment