]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/npm-registry-client/test/lib/common.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / npm-registry-client / test / lib / common.js
diff --git a/org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/npm-registry-client/test/lib/common.js b/org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/npm-registry-client/test/lib/common.js
new file mode 100644 (file)
index 0000000..ea48d30
--- /dev/null
@@ -0,0 +1,31 @@
+var server = require('./server.js')
+var RC = require('../../')
+var REGISTRY = 'http://localhost:' + server.port
+
+// cheesy hackaround for test deps (read: nock) that rely on setImmediate
+if (!global.setImmediate || !require('timers').setImmediate) {
+  require('timers').setImmediate = global.setImmediate = function () {
+    var args = [arguments[0], 0].concat([].slice.call(arguments, 1))
+    setTimeout.apply(this, args)
+  }
+}
+
+// See https://github.com/npm/npm-registry-client/pull/142 for background.
+// Note: `process.on('warning')` only works with Node >= 6.
+process.on('warning', function (warning) {
+  if (/Possible EventEmitter memory leak detected/.test(warning.message)) {
+    throw new Error('There should not be any EventEmitter memory leaks')
+  }
+})
+
+module.exports = {
+  port: server.port,
+  registry: REGISTRY,
+  freshClient: function freshClient (config) {
+    var client = new RC(config)
+    server.log = client.log
+    client.log.level = 'silent'
+
+    return client
+  }
+}