-
Notifications
You must be signed in to change notification settings - Fork 6
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
5763ea4
commit c8d56d2
Showing
1 changed file
with
106 additions
and
0 deletions.
There are no files selected for viewing
106 changes: 106 additions & 0 deletions
106
packages/ui-components/src/__tests__/deploymentStepsStore.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,106 @@ | ||
import { get } from 'svelte/store'; | ||
import deploymentStepsStore from '../lib/components/deployment/wizard/deploymentStepsStore' | ||
import type { WizardStep, TokenInputStep, FieldStep } from '../lib/types/wizardSteps'; | ||
|
||
describe('deploymentStepsStore', () => { | ||
beforeEach(() => { | ||
deploymentStepsStore.reset(); | ||
}); | ||
|
||
it('should initialize with empty array', () => { | ||
const steps = get(deploymentStepsStore); | ||
expect(steps).toEqual([]); | ||
}); | ||
|
||
it('should populate steps correctly', () => { | ||
const mockSteps: WizardStep[] = [ | ||
{ | ||
type: 'tokenInput', | ||
input: { | ||
token: '0x123...', | ||
decimals: 18, | ||
symbol: 'TEST' | ||
}, | ||
gui: { | ||
name: 'Test GUI', | ||
description: 'Test Description', | ||
}, | ||
tokenInfos: { | ||
}, | ||
i: 0, | ||
inputVaultIds: ['vault1', 'vault2'] | ||
} as unknown as TokenInputStep, | ||
{ | ||
type: 'fields', | ||
fieldDefinition: { | ||
name: 'Test Field', | ||
type: 'uint256', | ||
}, | ||
gui: { | ||
name: 'Test GUI', | ||
description: 'Test Description', | ||
} | ||
} as unknown as FieldStep | ||
]; | ||
|
||
deploymentStepsStore.populateDeploymentSteps(mockSteps); | ||
const steps = get(deploymentStepsStore); | ||
|
||
expect(steps).toEqual(mockSteps); | ||
}); | ||
|
||
it('should update a specific step correctly', () => { | ||
const initialSteps: WizardStep[] = [ | ||
{ | ||
type: 'tokenInput', | ||
input: { | ||
token: '0x123...', | ||
decimals: 18, | ||
symbol: 'TEST' | ||
}, | ||
gui: { | ||
name: 'Test GUI', | ||
description: 'Test Description' | ||
}, | ||
tokenInfos: { | ||
}, | ||
i: 0, | ||
inputVaultIds: ['vault1'] | ||
} as unknown as TokenInputStep | ||
]; | ||
|
||
deploymentStepsStore.populateDeploymentSteps(initialSteps); | ||
|
||
const updatedStep: TokenInputStep = { | ||
...initialSteps[0], | ||
inputVaultIds: ['vault1', 'vault2'] | ||
} as unknown as TokenInputStep; | ||
|
||
deploymentStepsStore.updateDeploymentStep(0, updatedStep); | ||
|
||
const steps = get(deploymentStepsStore); | ||
expect(steps[0]).toEqual(updatedStep); | ||
}); | ||
|
||
it('should reset store to initial state', () => { | ||
const mockSteps: WizardStep[] = [ | ||
{ | ||
type: 'fields', | ||
fieldDefinition: { | ||
name: 'Test Field', | ||
type: 'uint256', | ||
}, | ||
gui: { | ||
name: 'Test GUI', | ||
description: 'Test Description', | ||
} | ||
} as unknown as FieldStep | ||
]; | ||
|
||
deploymentStepsStore.populateDeploymentSteps(mockSteps); | ||
deploymentStepsStore.reset(); | ||
|
||
const steps = get(deploymentStepsStore); | ||
expect(steps).toEqual([]); | ||
}); | ||
}); |