File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 11'use strict' ;
22
3+ var assert = require ( 'assert' ) ;
4+ var fs = require ( 'fs/promises' ) ;
5+ var path = require ( 'path' ) ;
6+ var os = require ( 'os' ) ;
7+
38var pdfmake = require ( '../../js/index' ) ;
49
510pdfmake . addFonts ( {
@@ -32,4 +37,28 @@ describe('Node interface', function () {
3237 } ) ;
3338
3439 } ) ;
40+
41+ describe ( 'write' , function ( ) {
42+ it ( 'should write file' , async function ( ) {
43+
44+ var docDefinition = {
45+ content : [
46+ 'First paragraph' ,
47+ 'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines'
48+ ]
49+ } ;
50+
51+ const tmpDir = await fs . mkdtemp ( path . join ( os . tmpdir ( ) , 'pdfmake-' ) ) ;
52+ const pdfFilename = path . join ( tmpDir , 'document.pdf' ) ;
53+
54+ var pdf = pdfmake . createPdf ( docDefinition ) ;
55+ await pdf . write ( pdfFilename ) ;
56+
57+ const stats = await fs . stat ( pdfFilename ) ;
58+ assert . ok ( stats . size > 0 ) ;
59+
60+ await fs . rm ( tmpDir , { recursive : true , force : true } ) ;
61+ } ) ;
62+
63+ } ) ;
3564} ) ;
You can’t perform that action at this time.
0 commit comments