|
| 1 | +const {test} = require("ava"); |
| 2 | +const {resourceFactory} = require("../../../"); |
| 3 | + |
| 4 | +test("GLOB resources from application.a w/ virtual base path prefix", async (t) => { |
| 5 | + const readerWriter = resourceFactory.createAdapter({ |
| 6 | + fsBasePath: "./test/fixtures/application.a/webapp", |
| 7 | + virBasePath: "/app/" |
| 8 | + }); |
| 9 | + |
| 10 | + const resources = await readerWriter.byGlob("/app/**/*.html"); |
| 11 | + t.deepEqual(resources.length, 1, "Found exactly one resource"); |
| 12 | +}); |
| 13 | + |
| 14 | +test("GLOB resources from application.a w/o virtual base path prefix", async (t) => { |
| 15 | + const readerWriter = resourceFactory.createAdapter({ |
| 16 | + fsBasePath: "./test/fixtures/application.a/webapp", |
| 17 | + virBasePath: "/app/" |
| 18 | + }); |
| 19 | + |
| 20 | + const resources = await readerWriter.byGlob("/**/*.html"); |
| 21 | + t.deepEqual(resources.length, 1, "Found exactly one resource"); |
| 22 | +}); |
| 23 | + |
| 24 | + |
| 25 | +test("GLOB virtual directory w/o virtual base path prefix", async (t) => { |
| 26 | + const readerWriter = resourceFactory.createAdapter({ |
| 27 | + fsBasePath: "./test/fixtures/application.a/webapp", |
| 28 | + virBasePath: "/app/" |
| 29 | + }); |
| 30 | + |
| 31 | + const resources = await readerWriter.byGlob("/*", {nodir: false}); |
| 32 | + t.deepEqual(resources.length, 1, "Found exactly one resource"); |
| 33 | +}); |
| 34 | + |
| 35 | +test("GLOB virtual directory w/ virtual base path prefix", async (t) => { |
| 36 | + const readerWriter = resourceFactory.createAdapter({ |
| 37 | + fsBasePath: "./test/fixtures/application.a/webapp", |
| 38 | + virBasePath: "/app/one/two/" |
| 39 | + }); |
| 40 | + |
| 41 | + const resources = await readerWriter.byGlob("/app/*", {nodir: false}); |
| 42 | + t.deepEqual(resources.length, 1, "Found exactly one resource"); |
| 43 | +}); |
| 44 | + |
| 45 | +test("GLOB virtual directory w/o virtual base path prefix and nodir: true", async (t) => { |
| 46 | + const readerWriter = resourceFactory.createAdapter({ |
| 47 | + fsBasePath: "./test/fixtures/application.a/webapp", |
| 48 | + virBasePath: "/app/" |
| 49 | + }); |
| 50 | + |
| 51 | + const resources = await readerWriter.byGlob("/*", {nodir: true}); |
| 52 | + t.deepEqual(resources.length, 0, "Found no resources"); |
| 53 | +}); |
| 54 | + |
| 55 | +test("GLOB virtual directory w/ virtual base path prefix and nodir: true", async (t) => { |
| 56 | + const readerWriter = resourceFactory.createAdapter({ |
| 57 | + fsBasePath: "./test/fixtures/application.a/webapp", |
| 58 | + virBasePath: "/app/one/two/" |
| 59 | + }); |
| 60 | + |
| 61 | + const resources = await readerWriter.byGlob("/app/*", {nodir: true}); |
| 62 | + t.deepEqual(resources.length, 0, "Found no resources"); |
| 63 | +}); |
0 commit comments