-
-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9bc5416
commit db53937
Showing
6 changed files
with
245 additions
and
21 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
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
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,110 @@ | ||
import { run, runEmit } from "./helpers/run"; | ||
|
||
describe("info option", () => { | ||
it('should work without "info" option', (done) => { | ||
runEmit({ | ||
expectedAssetKeys: ["file.txt"], | ||
patterns: [ | ||
{ | ||
from: "file.txt", | ||
}, | ||
], | ||
}) | ||
.then(done) | ||
.catch(done); | ||
}); | ||
|
||
it('should work when "info" option is a object', (done) => { | ||
run({ | ||
expectedAssetKeys: ["file.txt"], | ||
patterns: [ | ||
{ | ||
from: "file.txt", | ||
info: { test: true }, | ||
}, | ||
], | ||
}) | ||
.then(({ compilation }) => { | ||
expect(compilation.assetsInfo.get("file.txt").test).toBe(true); | ||
}) | ||
.then(done) | ||
.catch(done); | ||
}); | ||
|
||
it('should work when "info" option is a object and "force" option is true', (done) => { | ||
const expectedAssetKeys = ["file.txt"]; | ||
|
||
run({ | ||
preCopy: { | ||
additionalAssets: [ | ||
{ name: "file.txt", data: "Content", info: { custom: true } }, | ||
], | ||
}, | ||
expectedAssetKeys, | ||
patterns: [ | ||
{ | ||
from: "file.txt", | ||
force: true, | ||
info: { test: true }, | ||
}, | ||
], | ||
}) | ||
.then(({ compilation }) => { | ||
expect(compilation.assetsInfo.get("file.txt").test).toBe(true); | ||
}) | ||
.then(done) | ||
.catch(done); | ||
}); | ||
|
||
it('should work when "info" option is a function', (done) => { | ||
run({ | ||
expectedAssetKeys: ["file.txt"], | ||
patterns: [ | ||
{ | ||
from: "file.txt", | ||
info: (file) => { | ||
expect.assertions(4); | ||
|
||
const fileKeys = ["absoluteFilename", "sourceFilename", "filename"]; | ||
|
||
for (const key of fileKeys) { | ||
expect(key in file).toBe(true); | ||
} | ||
|
||
return { test: true }; | ||
}, | ||
}, | ||
], | ||
}) | ||
.then(({ compilation }) => { | ||
expect(compilation.assetsInfo.get("file.txt").test).toBe(true); | ||
}) | ||
.then(done) | ||
.catch(done); | ||
}); | ||
|
||
it('should work when "info" option is a function and "force" option is true', (done) => { | ||
const expectedAssetKeys = ["file.txt"]; | ||
|
||
run({ | ||
preCopy: { | ||
additionalAssets: [ | ||
{ name: "file.txt", data: "Content", info: { custom: true } }, | ||
], | ||
}, | ||
expectedAssetKeys, | ||
patterns: [ | ||
{ | ||
from: "file.txt", | ||
force: true, | ||
info: () => ({ test: true }), | ||
}, | ||
], | ||
}) | ||
.then(({ compilation }) => { | ||
expect(compilation.assetsInfo.get("file.txt").test).toBe(true); | ||
}) | ||
.then(done) | ||
.catch(done); | ||
}); | ||
}); |
Oops, something went wrong.