-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(frontend): add tests for tint store
- Loading branch information
1 parent
446a51b
commit a655ca5
Showing
2 changed files
with
55 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// vitest-environment jsdom | ||
|
||
import { DEFAULT_TINT_COLOR } from '@scissors/sharp' | ||
|
||
import { createTintStore } from '@stores/tint' | ||
|
||
describe('@stores/tint', () => { | ||
it('should correctly add / remove tint', () => { | ||
const store = createTintStore() | ||
expect(store.getState().isAdded).toBe(false) | ||
store.getState().add() | ||
expect(store.getState().isAdded).toBe(true) | ||
store.getState().remove() | ||
expect(store.getState().isAdded).toBe(false) | ||
}) | ||
|
||
it('should correctly set / reset state', () => { | ||
const store = createTintStore() | ||
|
||
expect(store.getState().isAdded).toBe(false) | ||
|
||
store.getState().set('#0f883f') | ||
expect(store.getState().color).toBe('#0f883f') | ||
expect(store.getState().isAdded).toBe(true) | ||
|
||
store.getState().reset() | ||
expect(store.getState().color).toBe(DEFAULT_TINT_COLOR) | ||
expect(store.getState().isAdded).toBe(true) | ||
|
||
store.getState().set(null) | ||
expect(store.getState().color).toBe(null) | ||
expect(store.getState().isAdded).toBe(false) | ||
|
||
store.getState().reset() | ||
expect(store.getState().color).toBe(null) | ||
}) | ||
|
||
it('should correctly set color value', () => { | ||
const store = createTintStore() | ||
|
||
store.getState().setColor('#f77333') | ||
expect(store.getState().color).toBe('#f77333') | ||
|
||
store.getState().setColor('#000000') | ||
expect(store.getState().color).toBe('#000000') | ||
}) | ||
}) |
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