]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/init-package-json/node_modules/promzard/test/exports.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / init-package-json / node_modules / promzard / test / exports.js
1 var test = require('tap').test;
2 var promzard = require('../');
3
4 if (process.argv[2] === 'child') {
5   return child()
6 }
7
8 test('exports', function (t) {
9   t.plan(1);
10
11   var spawn = require('child_process').spawn
12   var child = spawn(process.execPath, [__filename, 'child'])
13
14   var output = ''
15   child.stderr.on('data', function (c) {
16     output += c
17   })
18
19   setTimeout(function () {
20     child.stdin.write('\n');
21   }, 100)
22   setTimeout(function () {
23     child.stdin.end('55\n');
24   }, 200)
25
26   child.on('close', function () {
27     console.error('output=%j', output)
28     output = JSON.parse(output)
29     t.same({
30       a : 3,
31       b : '!2b',
32       c : {
33         x : 55,
34         y : '/tmp/y/file.txt',
35       }
36     }, output);
37     t.end()
38   })
39 });
40
41 function child () {
42   var ctx = { tmpdir : '/tmp' }
43   var file = __dirname + '/exports.input';
44
45   promzard(file, ctx, function (err, output) {
46     console.error(JSON.stringify(output))
47   });
48 }