Path: blob/master/node_modules/@protobufjs/path/tests/index.js
2593 views
var tape = require("tape");12var path = require("..");34tape.test("path", function(test) {56test.ok(path.isAbsolute("X:\\some\\path\\file.js"), "should identify absolute windows paths");7test.ok(path.isAbsolute("/some/path/file.js"), "should identify absolute unix paths");89test.notOk(path.isAbsolute("some\\path\\file.js"), "should identify relative windows paths");10test.notOk(path.isAbsolute("some/path/file.js"), "should identify relative unix paths");1112var paths = [13{14actual: "X:\\some\\..\\.\\path\\\\file.js",15normal: "X:/path/file.js",16resolve: {17origin: "X:/path/origin.js",18expected: "X:/path/file.js"19}20}, {21actual: "some\\..\\.\\path\\\\file.js",22normal: "path/file.js",23resolve: {24origin: "X:/path/origin.js",25expected: "X:/path/path/file.js"26}27}, {28actual: "/some/.././path//file.js",29normal: "/path/file.js",30resolve: {31origin: "/path/origin.js",32expected: "/path/file.js"33}34}, {35actual: "some/.././path//file.js",36normal: "path/file.js",37resolve: {38origin: "",39expected: "path/file.js"40}41}, {42actual: ".././path//file.js",43normal: "../path/file.js"44}, {45actual: "/.././path//file.js",46normal: "/path/file.js"47}48];4950paths.forEach(function(p) {51test.equal(path.normalize(p.actual), p.normal, "should normalize " + p.actual);52if (p.resolve) {53test.equal(path.resolve(p.resolve.origin, p.actual), p.resolve.expected, "should resolve " + p.actual);54test.equal(path.resolve(p.resolve.origin, p.normal, true), p.resolve.expected, "should resolve " + p.normal + " (already normalized)");55}56});5758test.end();59});606162