-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests about getLicenseTermByType
- Loading branch information
Showing
2 changed files
with
196 additions
and
8 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
175 changes: 175 additions & 0 deletions
175
packages/core-sdk/test/unit/utils/getLicenseTermsByType.test.ts
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,175 @@ | ||
import { Hex, zeroAddress } from "viem"; | ||
import { PIL_TYPE } from "../../../src/types/resources/license"; | ||
import { getLicenseTermByType } from "../../../src/utils/getLicenseTermsByType"; | ||
import { expect } from "chai"; | ||
|
||
describe("Get License Terms By Type", () => { | ||
it("it should return no commercial license terms when call getLicenseTermByType given NON_COMMERCIAL_REMIX", async () => { | ||
const result = getLicenseTermByType(PIL_TYPE.NON_COMMERCIAL_REMIX); | ||
expect(result).to.deep.include({ | ||
transferable: true, | ||
commercialAttribution: false, | ||
commercialRevCelling: 0n, | ||
commercialRevShare: 0, | ||
commercialUse: false, | ||
commercializerChecker: "0x0000000000000000000000000000000000000000", | ||
commercializerCheckerData: "0x0000000000000000000000000000000000000000", | ||
currency: "0x0000000000000000000000000000000000000000", | ||
derivativeRevCelling: 0n, | ||
derivativesAllowed: true, | ||
derivativesApproval: false, | ||
derivativesAttribution: true, | ||
derivativesReciprocal: true, | ||
expiration: 0n, | ||
mintingFee: 0n, | ||
royaltyPolicy: "0x0000000000000000000000000000000000000000", | ||
uri: "", | ||
}); | ||
}); | ||
|
||
describe("Get Commercial License Terms", () => { | ||
it("it should throw when call getLicenseTermByType given COMMERCIAL_USE without terms", async () => { | ||
expect(() => getLicenseTermByType(PIL_TYPE.COMMERCIAL_USE)).to.throw( | ||
"mintingFee currency are required for commercial use PIL.", | ||
); | ||
}); | ||
|
||
it("it should throw when call getLicenseTermByType given COMMERCIAL_USE without mintFee", async () => { | ||
expect(() => | ||
getLicenseTermByType(PIL_TYPE.COMMERCIAL_USE, { | ||
currency: zeroAddress, | ||
royaltyPolicyLAPAddress: zeroAddress, | ||
}), | ||
).to.throw("mintingFee currency are required for commercial use PIL."); | ||
}); | ||
|
||
it("it should throw when call getLicenseTermByType given COMMERCIAL_USE without currency", async () => { | ||
expect(() => | ||
getLicenseTermByType(PIL_TYPE.COMMERCIAL_USE, { | ||
royaltyPolicyLAPAddress: zeroAddress, | ||
mintingFee: "1", | ||
}), | ||
).to.throw("mintingFee currency are required for commercial use PIL."); | ||
}); | ||
|
||
it("it should throw when call getLicenseTermByType given COMMERCIAL_USE and wrong royaltyAddress", async () => { | ||
expect(() => | ||
getLicenseTermByType(PIL_TYPE.COMMERCIAL_USE, { | ||
royaltyPolicyLAPAddress: "wrong" as Hex, | ||
mintingFee: "1", | ||
currency: zeroAddress, | ||
}), | ||
).to.throw(`Address "wrong" is invalid.`); | ||
}); | ||
|
||
it("it should return commercial license terms when call getLicenseTermByType given COMMERCIAL_USE and correct args", async () => { | ||
const result = getLicenseTermByType(PIL_TYPE.COMMERCIAL_USE, { | ||
royaltyPolicyLAPAddress: zeroAddress, | ||
mintingFee: "1", | ||
currency: zeroAddress, | ||
}); | ||
expect(result).to.deep.contain({ | ||
commercialAttribution: true, | ||
commercialRevCelling: 0n, | ||
commercialRevShare: 0, | ||
commercialUse: true, | ||
commercializerChecker: "0x0000000000000000000000000000000000000000", | ||
commercializerCheckerData: "0x0000000000000000000000000000000000000000", | ||
currency: "0x0000000000000000000000000000000000000000", | ||
derivativeRevCelling: 0n, | ||
derivativesAllowed: true, | ||
derivativesApproval: false, | ||
derivativesAttribution: true, | ||
derivativesReciprocal: false, | ||
expiration: 0n, | ||
mintingFee: 1n, | ||
royaltyPolicy: "0x0000000000000000000000000000000000000000", | ||
transferable: true, | ||
uri: "", | ||
}); | ||
}); | ||
}); | ||
|
||
describe("Get Commercial remix License Terms", () => { | ||
it("it should throw when call getLicenseTermByType given COMMERCIAL_REMIX without terms", async () => { | ||
expect(() => getLicenseTermByType(PIL_TYPE.COMMERCIAL_REMIX)).to.throw( | ||
"mintingFee, currency and commercialRevShare are required for commercial remix PIL.", | ||
); | ||
}); | ||
|
||
it("it should throw when call getLicenseTermByType given COMMERCIAL_REMIX without mintFee", async () => { | ||
expect(() => | ||
getLicenseTermByType(PIL_TYPE.COMMERCIAL_REMIX, { | ||
currency: zeroAddress, | ||
royaltyPolicyLAPAddress: zeroAddress, | ||
commercialRevShare: 100, | ||
}), | ||
).to.throw( | ||
"mintingFee, currency and commercialRevShare are required for commercial remix PIL.", | ||
); | ||
}); | ||
|
||
it("it should throw when call getLicenseTermByType given COMMERCIAL_REMIX without currency", async () => { | ||
expect(() => | ||
getLicenseTermByType(PIL_TYPE.COMMERCIAL_REMIX, { | ||
royaltyPolicyLAPAddress: zeroAddress, | ||
mintingFee: "1", | ||
commercialRevShare: 100, | ||
}), | ||
).to.throw( | ||
"mintingFee, currency and commercialRevShare are required for commercial remix PIL.", | ||
); | ||
}); | ||
|
||
it("it should throw when call getLicenseTermByType given COMMERCIAL_REMIX and wrong royaltyAddress", async () => { | ||
expect(() => | ||
getLicenseTermByType(PIL_TYPE.COMMERCIAL_REMIX, { | ||
royaltyPolicyLAPAddress: "wrong" as Hex, | ||
mintingFee: "1", | ||
currency: zeroAddress, | ||
commercialRevShare: 100, | ||
}), | ||
).to.throw(`Address "wrong" is invalid.`); | ||
}); | ||
|
||
it("it should throw when call getLicenseTermByType given COMMERCIAL_REMIX without commercialRevShare ", async () => { | ||
expect(() => | ||
getLicenseTermByType(PIL_TYPE.COMMERCIAL_REMIX, { | ||
royaltyPolicyLAPAddress: "wrong" as Hex, | ||
mintingFee: "1", | ||
currency: zeroAddress, | ||
}), | ||
).to.throw( | ||
`mintingFee, currency and commercialRevShare are required for commercial remix PIL.`, | ||
); | ||
}); | ||
|
||
it("it should return commercial license terms when call getLicenseTermByType given COMMERCIAL_REMIX and correct args", async () => { | ||
const result = getLicenseTermByType(PIL_TYPE.COMMERCIAL_REMIX, { | ||
royaltyPolicyLAPAddress: zeroAddress, | ||
mintingFee: "1", | ||
currency: zeroAddress, | ||
commercialRevShare: 100, | ||
}); | ||
expect(result).to.deep.contain({ | ||
commercialAttribution: true, | ||
commercialRevCelling: 0n, | ||
commercialRevShare: 100, | ||
commercialUse: true, | ||
commercializerChecker: "0x0000000000000000000000000000000000000000", | ||
commercializerCheckerData: "0x0000000000000000000000000000000000000000", | ||
currency: "0x0000000000000000000000000000000000000000", | ||
derivativeRevCelling: 0n, | ||
derivativesAllowed: true, | ||
derivativesApproval: false, | ||
derivativesAttribution: true, | ||
derivativesReciprocal: true, | ||
expiration: 0n, | ||
mintingFee: 1n, | ||
royaltyPolicy: "0x0000000000000000000000000000000000000000", | ||
transferable: true, | ||
uri: "", | ||
}); | ||
}); | ||
}); | ||
}); |