|
13 | 13 | //===----------------------------------------------------------------------===//
|
14 | 14 |
|
15 | 15 | import * as path from "path";
|
16 |
| -import { isPathInsidePath, expandFilePathTilde } from "../../../src/utilities/filesystem"; |
| 16 | +import { Uri } from "vscode"; |
| 17 | +import { |
| 18 | + isPathInsidePath, |
| 19 | + expandFilePathTilde, |
| 20 | + isExcluded, |
| 21 | + isIncluded, |
| 22 | +} from "../../../src/utilities/filesystem"; |
17 | 23 | import { expect } from "chai";
|
18 | 24 |
|
19 | 25 | suite("File System Utilities Unit Test Suite", () => {
|
@@ -55,4 +61,58 @@ suite("File System Utilities Unit Test Suite", () => {
|
55 | 61 | expect(expandFilePathTilde("~/Test", "C:\\Users\\John", "win32")).to.equal("~/Test");
|
56 | 62 | });
|
57 | 63 | });
|
| 64 | + |
| 65 | + suite("isExcluded()", () => { |
| 66 | + const uri = Uri.file("path/to/foo/bar/file.swift"); |
| 67 | + |
| 68 | + test("excluded", () => { |
| 69 | + expect(isExcluded(uri, { "/path": true })).to.be.true; |
| 70 | + expect(isExcluded(uri, { "**/foo": true })).to.be.true; |
| 71 | + expect(isExcluded(uri, { "**/foo/**": true })).to.be.true; |
| 72 | + }); |
| 73 | + |
| 74 | + test("excluded, overwriting patterns", () => { |
| 75 | + expect(isExcluded(uri, { "**/foo": false, "**/foo/bar": true })).to.be.true; |
| 76 | + }); |
| 77 | + |
| 78 | + test("NOT excluded", () => { |
| 79 | + expect(isExcluded(uri, { "**/qux/**": false })).to.be.false; |
| 80 | + expect(isExcluded(uri, { "**/foo": false, "**/foo/qux": true })).to.be.false; |
| 81 | + expect( |
| 82 | + isExcluded(uri, { |
| 83 | + "**/foo": false, |
| 84 | + "**/foo/bar": true, |
| 85 | + "**/foo/bar/file.swift": false, |
| 86 | + }) |
| 87 | + ).to.be.false; |
| 88 | + }); |
| 89 | + }); |
| 90 | + |
| 91 | + suite("isIncluded()", () => { |
| 92 | + const uri = Uri.file("path/to/foo/bar/file.swift"); |
| 93 | + |
| 94 | + test("included", () => { |
| 95 | + expect(isIncluded(uri, {})).to.be.true; |
| 96 | + expect(isIncluded(uri, { "/path": false })).to.be.true; |
| 97 | + expect(isIncluded(uri, { "**/foo": false })).to.be.true; |
| 98 | + expect(isIncluded(uri, { "**/foo/**": false })).to.be.true; |
| 99 | + expect(isIncluded(uri, { "**/qux/**": true })).to.be.true; |
| 100 | + }); |
| 101 | + |
| 102 | + test("included, overwriting patterns", () => { |
| 103 | + expect(isIncluded(uri, { "**/foo": true, "**/foo/bar": false })).to.be.true; |
| 104 | + }); |
| 105 | + |
| 106 | + test("NOT included", () => { |
| 107 | + expect(isIncluded(uri, { "**/foo": true })).to.be.false; |
| 108 | + expect(isIncluded(uri, { "**/foo": true, "**/foo/qux": false })).to.be.false; |
| 109 | + expect( |
| 110 | + isIncluded(uri, { |
| 111 | + "**/foo": true, |
| 112 | + "**/foo/bar": false, |
| 113 | + "**/foo/bar/file.swift": true, |
| 114 | + }) |
| 115 | + ).to.be.false; |
| 116 | + }); |
| 117 | + }); |
58 | 118 | });
|
0 commit comments