Skip to content

Commit

Permalink
Migrate sdk tests to vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
cristovaoth committed Jan 27, 2025
1 parent 99d9a7c commit cf72c06
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 26 deletions.
10 changes: 5 additions & 5 deletions packages/sdk/test/applyAllowances.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { expect, it, suite } from "vitest"
import { AbiCoder, concat, hexlify, zeroPadValue } from "ethers"

import { applyAllowances } from "../src/allowances"

import { Roles__factory } from "../../evm/typechain-types"
import { Allowance } from "zodiac-roles-deployments"
import { expect } from "chai"

const iface = Roles__factory.createInterface()

Expand All @@ -13,8 +13,8 @@ const key2 = hexlify(zeroPadValue("0x02", 32)) as `0x${string}`
const key3 = hexlify(zeroPadValue("0x03", 32)) as `0x${string}`
const key4 = hexlify(zeroPadValue("0x04", 32)) as `0x${string}`

describe("applyAllowances", () => {
describe("replace", () => {
suite("applyAllowances", () => {
suite("replace", () => {
it("unsets allowances that are not mentioned, and sets the ones passed in", async () => {
const currentAllowances: Allowance[] = [
{
Expand Down Expand Up @@ -99,7 +99,7 @@ describe("applyAllowances", () => {
})
})

describe("extend", () => {
suite("extend", () => {
it("sets the allowances passed in, and ignores existing ones", async () => {
const currentAllowances: Allowance[] = [
{
Expand Down Expand Up @@ -184,7 +184,7 @@ describe("applyAllowances", () => {
})
})

describe("remove", () => {
suite("remove", () => {
it("unsets the allowances passed in, and ignores existing ones", async () => {
const currentAllowances: Allowance[] = [
{
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/test/applyTargets.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { expect } from "chai"
import { expect, it, suite } from "vitest"
import { Operator, ParameterType, Target } from "zodiac-roles-deployments"

import { replaceTargets } from "../src/targets/applyTargets"

describe("replaceTargets", () => {
suite("replaceTargets", () => {
it("should revoke function-scoped targets", () => {
const before: Target[] = [
{
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk/test/checkConditionIntegrity.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from "chai"
import { expect, it, suite } from "vitest"
import { Operator, ParameterType } from "zodiac-roles-deployments"

import {
Expand All @@ -7,7 +7,7 @@ import {
} from "../src/conditions"
import { encodeAbiParameters } from "../src/utils/encodeAbiParameters"

describe("checkConditionIntegrity()", () => {
suite("checkConditionIntegrity()", () => {
it("should throw for And without children", () => {
expect(() =>
checkConditionIntegrity({
Expand Down Expand Up @@ -80,7 +80,7 @@ describe("checkConditionIntegrity()", () => {
})
})

describe("checkRootConditionIntegrity()", () => {
suite("checkRootConditionIntegrity()", () => {
it("should throw if the root param type is not Calldata", () => {
expect(() =>
checkRootConditionIntegrity({
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/test/conditionId.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { expect } from "chai"
import { expect, it, suite } from "vitest"
import { Operator, ParameterType } from "zodiac-roles-deployments"

import { conditionAddress, normalizeCondition } from "../src/conditions"

describe("conditionAddress", () => {
suite("conditionAddress", () => {
it("calculates the create2 storage address of the condition", () => {
const normalizedCondition = normalizeCondition({
operator: Operator.Matches,
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/test/diffTargets.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from "chai"
import { expect, it, suite } from "vitest"
import {
Clearance,
ExecutionOptions,
Expand All @@ -9,7 +9,7 @@ import {

import { diffTargets } from "../src/targets/diffTargets"

describe("diffTargets", () => {
suite("diffTargets", () => {
it("should correctly diff target-cleared targets", () => {
const a: Target[] = [
{
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/test/normalizeCondition.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from "chai"
import { expect, it, suite } from "vitest"
import { Operator, ParameterType } from "zodiac-roles-deployments"

import { normalizeCondition } from "../src/conditions"
Expand All @@ -14,7 +14,7 @@ const DUMMY_COMP = (id: number) => ({
compValue: encodeAbiParameters(["uint256"], [id]),
})

describe("normalizeCondition()", () => {
suite("normalizeCondition()", () => {
it("flattens nested AND conditions", () => {
expect(
stripIds(
Expand Down
5 changes: 2 additions & 3 deletions packages/sdk/test/processAnnotations.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { expect } from "chai"

import { expect, it, suite } from "vitest"
import { processAnnotations } from "../src/entrypoints/annotations"
import { PermissionCoerced } from "../src/permissions"

describe("processAnnotations()", () => {
suite("processAnnotations()", () => {
it("returns the original set of permissions if no annotations are given", async () => {
const permissions = [
{
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/test/removeObsoleteCalls.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { expect } from "chai"
import { expect, it, suite } from "vitest"
import { ExecutionOptions } from "zodiac-roles-deployments"

import { removeObsoleteCalls } from "../src/calls"
import { Call } from "../src/calls/types"

describe("removeObsoleteCalls", () => {
suite("removeObsoleteCalls", () => {
it("should remove function permission updates if later on the entire target is cleared", () => {
const calls: Call[] = [
{
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/test/splitCondition.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from "chai"
import { expect, it, suite } from "vitest"
import { Condition, Operator, ParameterType } from "zodiac-roles-deployments"

import { normalizeCondition } from "../src/conditions"
Expand All @@ -11,7 +11,7 @@ const DUMMY_COMP = (id: number): Condition => ({
compValue: encodeAbiParameters(["uint256"], [id]),
})

describe("splitCondition", () => {
suite("splitCondition", () => {
it("returns the remainder condition for ORs", () => {
const combined = {
paramType: ParameterType.None,
Expand Down
5 changes: 2 additions & 3 deletions packages/sdk/test/splitTargets.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { expect } from "chai"

import { expect, it, suite } from "vitest"
import {
Permission,
processPermissions,
reconstructPermissions,
} from "../src/permissions"
import { diffTargets, splitTargets } from "../src/targets"

describe("splitTargets", () => {
suite("splitTargets", () => {
it("splits so that both shares combined yield the original permissions", () => {
const { targets: combinedTargets } = processPermissions(combinedPermissions)
const { targets: split } = processPermissions(splitPermissions)
Expand Down

0 comments on commit cf72c06

Please sign in to comment.