| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,50 @@ | |||
| 1 | + var assert = require("assert"); | ||
| 2 | + | ||
| 3 | + describe("Pathspec", function() { | ||
| 4 | + var NodeGit = require("../../"); | ||
| 5 | + var Pathspec = NodeGit.Pathspec; | ||
| 6 | + | ||
| 7 | + it("can accept just about anything against a * pathspec", function() { | ||
| 8 | + return Pathspec.create("*") | ||
| 9 | + .then(function(pathspec) { | ||
| 10 | + assert.equal(pathspec.matchesPath(0, "burritoooo"), 1); | ||
| 11 | + assert.equal(pathspec.matchesPath(0, "bob/ted/yoghurt.mp3"), 1); | ||
| 12 | + }); | ||
| 13 | + }); | ||
| 14 | + | ||
| 15 | + it("can take a * in an array", function() { | ||
| 16 | + return Pathspec.create(["*"]) | ||
| 17 | + .then(function(pathspec) { | ||
| 18 | + assert.equal(pathspec.matchesPath(0, "burritoooo"), 1); | ||
| 19 | + assert.equal(pathspec.matchesPath(0, "bob/ted/yoghurt.mp3"), 1); | ||
| 20 | + }); | ||
| 21 | + }); | ||
| 22 | + | ||
| 23 | + it("can take a single file", function() { | ||
| 24 | + return Pathspec.create(["myDir/burritoSupreme.mp4"]) | ||
| 25 | + .then(function(pathspec) { | ||
| 26 | + assert.equal(pathspec.matchesPath(0, "myDir/burritoSupreme.mp4"), 1); | ||
| 27 | + assert.equal(pathspec.matchesPath(0, "bob/ted/yoghurt.mp3"), 0); | ||
| 28 | + }); | ||
| 29 | + }); | ||
| 30 | + | ||
| 31 | + it("can take files in an array", function() { | ||
| 32 | + return Pathspec.create(["gwendoline.txt", "sausolito.ogg"]) | ||
| 33 | + .then(function(pathspec) { | ||
| 34 | + assert.equal(pathspec.matchesPath(0, "gwendoline.txt"), 1); | ||
| 35 | + assert.equal(pathspec.matchesPath(0, "sausolito.ogg"), 1); | ||
| 36 | + assert.equal(pathspec.matchesPath(0, "sausolito.txt"), 0); | ||
| 37 | + }); | ||
| 38 | + }); | ||
| 39 | + | ||
| 40 | + it("can handle dirs", function() { | ||
| 41 | + return Pathspec.create(["myDir/", "bob.js"]) | ||
| 42 | + .then(function(pathspec) { | ||
| 43 | + assert.equal(pathspec.matchesPath(0, "bob.js"), 1); | ||
| 44 | + assert.equal(pathspec.matchesPath(0, "myDir/bob2.js"), 1); | ||
| 45 | + assert.equal(pathspec.matchesPath(0, "bob2.js"), 0); | ||
| 46 | + assert.equal(pathspec.matchesPath(0, "herDir/bob.js"), 0); | ||
| 47 | + }); | ||
| 48 | + }); | ||
| 49 | + | ||
| 50 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments