Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRebecca Turner <me@re-becca.org>2015-07-20 09:49:29 +0300
committerRebecca Turner <me@re-becca.org>2015-07-25 05:45:19 +0300
commit28ebc6c227c0347ac429ac01bbf01ce33f2eda5c (patch)
tree4e3efa6f10b7350e177546f7c625f3df282d7950 /test
parentb181fa39a009f1ca3584c9e4fbc5d0aff3686107 (diff)
install: Update fs.access to allow io.js versions w/ fixed windows ver
This also pushes them off to their own file, so we can stop doing the copy-pasta dance. It also makes explaining the rational of the check cleaner I think. PR-URL: https://github.com/npm/npm/pull/9038
Diffstat (limited to 'test')
-rw-r--r--test/tap/is-fs-access-available.js54
1 files changed, 54 insertions, 0 deletions
diff --git a/test/tap/is-fs-access-available.js b/test/tap/is-fs-access-available.js
new file mode 100644
index 000000000..7374e4022
--- /dev/null
+++ b/test/tap/is-fs-access-available.js
@@ -0,0 +1,54 @@
+'use strict'
+var test = require('tap').test
+var requireInject = require('require-inject')
+var semver = require('semver')
+
+var globalProcess = global.process
+
+function loadIsFsAccessAvailable (newProcess, fs) {
+ global.process = newProcess
+ var mocks = {fs: fs}
+ var isFsAccessAvailable = requireInject('../../lib/install/is-fs-access-available.js', mocks)
+ global.process = globalProcess
+ return isFsAccessAvailable
+}
+
+var fsWithAccess = {access: function () {}}
+var fsWithoutAccess = {}
+
+if (semver.lt(process.version, '0.12.0')) {
+ test('skipping', function (t) {
+ t.pass('skipping all tests on < 0.12.0 due to process not being injectable')
+ t.end()
+ })
+} else {
+ test('mac + !fs.access', function (t) {
+ var isFsAccessAvailable = loadIsFsAccessAvailable({platform: 'darwin'}, fsWithoutAccess)
+ t.is(isFsAccessAvailable, false, 'not available')
+ t.end()
+ })
+
+ test('mac + fs.access', function (t) {
+ var isFsAccessAvailable = loadIsFsAccessAvailable({platform: 'darwin'}, fsWithAccess)
+ t.is(isFsAccessAvailable, true, 'available')
+ t.end()
+ })
+
+ test('windows + !fs.access', function (t) {
+ var isFsAccessAvailable = loadIsFsAccessAvailable({platform: 'win32'}, fsWithoutAccess)
+ t.is(isFsAccessAvailable, false, 'not available')
+ t.end()
+ })
+
+ test('windows + fs.access + node 0.12.7', function (t) {
+ var isFsAccessAvailable = loadIsFsAccessAvailable({platform: 'win32', version: '0.12.7'}, fsWithAccess)
+ t.is(isFsAccessAvailable, false, 'not available')
+ t.end()
+ })
+
+ test('windows + fs.access + node 2.4.0', function (t) {
+ var isFsAccessAvailable = loadIsFsAccessAvailable({platform: 'win32', version: '2.4.0'}, fsWithAccess)
+ t.is(isFsAccessAvailable, true, 'available')
+ t.end()
+ })
+}