aboutsummaryrefslogtreecommitdiff
path: root/node_modules/source-map-resolve/test/read.js
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2019-10-06 21:37:45 +0200
committerDimitri Staessens <dimitri@ouroboros.rocks>2019-10-06 21:37:45 +0200
commit3c51c3be85bb0d1bdb87ea0d6632f1c256912f27 (patch)
treec7ccc8279b12c4f7bdbbb4270d617e48f51722e4 /node_modules/source-map-resolve/test/read.js
parent412c104bebc507bea9c94fd53b5bdc4b64cbfe31 (diff)
downloadwebsite-3c51c3be85bb0d1bdb87ea0d6632f1c256912f27.tar.gz
website-3c51c3be85bb0d1bdb87ea0d6632f1c256912f27.zip
build: Add some required modules for node
Diffstat (limited to 'node_modules/source-map-resolve/test/read.js')
-rw-r--r--node_modules/source-map-resolve/test/read.js105
1 files changed, 105 insertions, 0 deletions
diff --git a/node_modules/source-map-resolve/test/read.js b/node_modules/source-map-resolve/test/read.js
new file mode 100644
index 0000000..6bf2dad
--- /dev/null
+++ b/node_modules/source-map-resolve/test/read.js
@@ -0,0 +1,105 @@
+// Copyright 2017 Simon Lydell
+// X11 (“MIT”) Licensed. (See LICENSE.)
+
+var test = require("tape")
+var asyncify = require("simple-asyncify")
+var common = require("./common")
+var u = common.u
+
+var sourceMapResolve = require("../")
+
+var mapUrl = "operators%20map.json"
+var codeUrl = "./built files/operators:+-<>%25.js"
+var sourceUrl = "../source files/operators:+-<>%25.coffee"
+
+function readTest(t, files) {
+ return function(file, callback) {
+ var fileData = files[file]
+ t.ok(fileData, "decoded file name")
+ if (callback) {
+ callback(null, fileData)
+ } else {
+ return fileData
+ }
+ }
+}
+
+
+
+function testResolveSourceMap(method, sync) {
+ return function(t) {
+ t.plan(2)
+
+ if (sync) {
+ method = asyncify(method)
+ }
+
+ var read = readTest(t, {
+ "built files/operators map.json": "{}"
+ })
+
+ method(u(mapUrl), codeUrl, read, function(error) {
+ t.error(error)
+ })
+
+ }
+}
+
+test(".resolveSourceMap", testResolveSourceMap(sourceMapResolve.resolveSourceMap, false))
+
+test(".resolveSourceMapSync", testResolveSourceMap(sourceMapResolve.resolveSourceMapSync, true))
+
+
+function testResolveSources(method, sync) {
+ return function(t) {
+ t.plan(2)
+
+ if (sync) {
+ method = asyncify(method)
+ }
+
+ var map = {
+ sources: [sourceUrl]
+ }
+ var read = readTest(t, {
+ "../source files/operators:+-<>%.coffee": "source code"
+ })
+
+ method(map, mapUrl, read, function(error) {
+ t.error(error)
+ })
+
+ }
+}
+
+test(".resolveSources", testResolveSources(sourceMapResolve.resolveSources, false))
+
+test(".resolveSourcesSync", testResolveSources(sourceMapResolve.resolveSourcesSync, true))
+
+
+function testResolve(method, sync) {
+ return function(t) {
+ t.plan(3)
+
+ if (sync) {
+ method = asyncify(method)
+ }
+
+ var map = {
+ sources: [sourceUrl]
+ }
+ var read = readTest(t, {
+ "built files/operators map.json": JSON.stringify(map),
+ "source files/operators:+-<>%.coffee": "source code"
+ })
+
+ method(u(mapUrl), codeUrl, read, function(error) {
+ t.error(error)
+ })
+
+ }
+}
+
+test(".resolve", testResolve(sourceMapResolve.resolve, false))
+
+test(".resolveSync", testResolve(sourceMapResolve.resolveSync, true))