-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[INTERNAL] Memory Adapter: Fix directory globbing
- Loading branch information
1 parent
afbcc3f
commit 6e6b70e
Showing
5 changed files
with
448 additions
and
290 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
const {test} = require("ava"); | ||
const {resourceFactory} = require("../../../"); | ||
|
||
test("GLOB resources from application.a w/ virtual base path prefix", async (t) => { | ||
const readerWriter = resourceFactory.createAdapter({ | ||
fsBasePath: "./test/fixtures/application.a/webapp", | ||
virBasePath: "/app/" | ||
}); | ||
|
||
const resources = await readerWriter.byGlob("/app/**/*.html"); | ||
t.deepEqual(resources.length, 1, "Found exactly one resource"); | ||
}); | ||
|
||
test("GLOB resources from application.a w/o virtual base path prefix", async (t) => { | ||
const readerWriter = resourceFactory.createAdapter({ | ||
fsBasePath: "./test/fixtures/application.a/webapp", | ||
virBasePath: "/app/" | ||
}); | ||
|
||
const resources = await readerWriter.byGlob("/**/*.html"); | ||
t.deepEqual(resources.length, 1, "Found exactly one resource"); | ||
}); | ||
|
||
|
||
test("GLOB virtual directory w/o virtual base path prefix", async (t) => { | ||
const readerWriter = resourceFactory.createAdapter({ | ||
fsBasePath: "./test/fixtures/application.a/webapp", | ||
virBasePath: "/app/" | ||
}); | ||
|
||
const resources = await readerWriter.byGlob("/*", {nodir: false}); | ||
t.deepEqual(resources.length, 1, "Found exactly one resource"); | ||
}); | ||
|
||
test("GLOB virtual directory w/ virtual base path prefix", async (t) => { | ||
const readerWriter = resourceFactory.createAdapter({ | ||
fsBasePath: "./test/fixtures/application.a/webapp", | ||
virBasePath: "/app/one/two/" | ||
}); | ||
|
||
const resources = await readerWriter.byGlob("/app/*", {nodir: false}); | ||
t.deepEqual(resources.length, 1, "Found exactly one resource"); | ||
}); | ||
|
||
test("GLOB virtual directory w/o virtual base path prefix and nodir: true", async (t) => { | ||
const readerWriter = resourceFactory.createAdapter({ | ||
fsBasePath: "./test/fixtures/application.a/webapp", | ||
virBasePath: "/app/" | ||
}); | ||
|
||
const resources = await readerWriter.byGlob("/*", {nodir: true}); | ||
t.deepEqual(resources.length, 0, "Found no resources"); | ||
}); | ||
|
||
test("GLOB virtual directory w/ virtual base path prefix and nodir: true", async (t) => { | ||
const readerWriter = resourceFactory.createAdapter({ | ||
fsBasePath: "./test/fixtures/application.a/webapp", | ||
virBasePath: "/app/one/two/" | ||
}); | ||
|
||
const resources = await readerWriter.byGlob("/app/*", {nodir: true}); | ||
t.deepEqual(resources.length, 0, "Found no resources"); | ||
}); |
Oops, something went wrong.