-
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.
Merge pull request #891 from rainlanguage/2024-09-25-account-settings
Resetting account filter on settings change
- Loading branch information
Showing
3 changed files
with
59 additions
and
1 deletion.
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 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,42 @@ | ||
import { expect, test, beforeEach, describe } from 'vitest'; | ||
import { settings, activeAccountsItems } from './settings'; | ||
import { mockConfigSource } from '$lib/mocks/settings'; | ||
import { get } from 'svelte/store'; | ||
|
||
describe('Settings active accounts items', async () => { | ||
beforeEach(() => { | ||
activeAccountsItems.set(mockConfigSource.accounts as Record<string, string>); | ||
expect(get(activeAccountsItems)).toEqual(mockConfigSource.accounts); | ||
}); | ||
|
||
test('should remove account if that account is removed', () => { | ||
const newSettings = { | ||
...mockConfigSource, | ||
accounts: { | ||
name_one: mockConfigSource.accounts?.name_one as string, | ||
}, | ||
}; | ||
|
||
settings.set(newSettings); | ||
|
||
expect(get(activeAccountsItems)).toEqual({ | ||
name_one: mockConfigSource.accounts?.name_one as string, | ||
}); | ||
}); | ||
|
||
test('should remove account if the value is different', () => { | ||
const newSettings = { | ||
...mockConfigSource, | ||
accounts: { | ||
name_one: mockConfigSource.accounts?.name_one as string, | ||
name_two: 'new_value', | ||
}, | ||
}; | ||
|
||
settings.set(newSettings); | ||
|
||
expect(get(activeAccountsItems)).toEqual({ | ||
name_one: mockConfigSource.accounts?.name_one as string, | ||
}); | ||
}); | ||
}); |
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