]> 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/basic.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 / basic.js
1 var tap = require('tap')
2 var pz = require('../promzard.js')
3 var spawn = require('child_process').spawn
4
5 tap.test('run the example', function (t) {
6
7   var example = require.resolve('../example/index.js')
8   var node = process.execPath
9
10   var expect =  {
11     "name": "example",
12     "version": "0.0.0",
13     "description": "testing description",
14     "main": "test-entry.js",
15     "directories": {
16       "example": "example",
17       "test": "test"
18     },
19     "dependencies": {},
20     "devDependencies": {
21       "tap": "~0.2.5"
22     },
23     "scripts": {
24       "test": "tap test/*.js"
25     },
26     "repository": {
27       "type": "git",
28       "url": "git://github.com/substack/example.git"
29     },
30     "homepage": "https://github.com/substack/example",
31     "keywords": [
32       "fugazi",
33       "function",
34       "waiting",
35       "room"
36     ],
37     "author": {
38       "name": "James Halliday",
39       "email": "mail@substack.net",
40       "url": "http://substack.net"
41     },
42     "license": "MIT",
43     "engine": {
44       "node": ">=0.6"
45     }
46   }
47
48   console.error('%s %s', node, example)
49   var c = spawn(node, [example], { customFds: [-1,-1,-1] })
50   var output = ''
51   c.stdout.on('data', function (d) {
52     output += d
53     respond()
54   })
55
56   var actual = ''
57   c.stderr.on('data', function (d) {
58     actual += d
59   })
60
61   function respond () {
62     console.error('respond', output)
63     if (output.match(/description: $/)) {
64       c.stdin.write('testing description\n')
65       return
66     }
67     if (output.match(/entry point: \(index\.js\) $/)) {
68       c.stdin.write('test-entry.js\n')
69       return
70     }
71     if (output.match(/keywords: $/)) {
72       c.stdin.write('fugazi function waiting room\n')
73       // "read" module is weird on node >= 0.10 when not a TTY
74       // requires explicit ending for reasons.
75       // could dig in, but really just wanna make tests pass, whatever.
76       c.stdin.end()
77       return
78     }
79   }
80
81   c.on('exit', function () {
82     console.error('exit event')
83   })
84
85   c.on('close', function () {
86     console.error('actual', actual)
87     actual = JSON.parse(actual)
88     t.deepEqual(actual, expect)
89     t.end()
90   })
91 })