-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve and test remappings parsing logic
- Loading branch information
Showing
3 changed files
with
66 additions
and
16 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 was deleted.
Oops, something went wrong.
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,36 @@ | ||
import { expect } from "chai"; | ||
import { HardhatFoundryError, parseRemappings } from "../src/foundry"; | ||
|
||
describe("foundry module", function () { | ||
describe("parseRemappings", function () { | ||
it("should parse simple remappings", async function () { | ||
const remappings = parseRemappings("a=b\nb=c\nc=d"); | ||
|
||
expect(remappings).to.deep.equal({ | ||
a: "b", | ||
b: "c", | ||
c: "d", | ||
}); | ||
}); | ||
|
||
it("should throw if a remapping has a context", async function () { | ||
expect(() => parseRemappings("a:b=c")).to.throw( | ||
"Invalid remapping 'a:b=c', remapping contexts are not allowed" | ||
); | ||
}); | ||
|
||
it("should throw if a remapping doesn't have a target", async function () { | ||
expect(() => parseRemappings("a")).to.throw( | ||
"Invalid remapping 'a', remappings without a target are not allowed" | ||
); | ||
}); | ||
|
||
it("should use the first remapping if more than one has the same prefix", async function () { | ||
const remappings = parseRemappings("a=b\na=c"); | ||
|
||
expect(remappings).to.deep.equal({ | ||
a: "b", | ||
}); | ||
}); | ||
}); | ||
}); |