-
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.
Move RaindexVersionValidator to components-ui
- Loading branch information
1 parent
90d5712
commit af1df66
Showing
5 changed files
with
52 additions
and
51 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
packages/ui-components/src/lib/components/RaindexVersionValidator.svelte
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,21 @@ | ||
<script lang="ts"> | ||
import { Alert } from 'flowbite-svelte'; | ||
import { InfoCircleOutline } from 'flowbite-svelte-icons'; | ||
export let error: unknown; | ||
</script> | ||
|
||
{#if error && typeof error == 'string' && error.startsWith('Raindex version')} | ||
<Alert color="red"> | ||
<InfoCircleOutline slot="icon" class="h-5 w-5" /> | ||
<div class="flex flex-col"> | ||
<span>{error}</span> | ||
<span | ||
>This order may not be compatible with this version of Raindex. Head to | ||
<a class="underline" href="https://github.com/rainlanguage/rain.orderbook/releases" | ||
>Github</a | ||
> to find a compatible release.</span | ||
> | ||
</div> | ||
</Alert> | ||
{/if} |
30 changes: 30 additions & 0 deletions
30
packages/ui-components/src/lib/components/RaindexVersionValidator.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,30 @@ | ||
import { describe, test, expect } from 'vitest'; | ||
import { render } from '@testing-library/svelte'; | ||
import RaindexVersionValidator from './RaindexVersionValidator.svelte'; | ||
|
||
describe('RaindexVersionValidator Component', () => { | ||
test('should show error message if error is a string that starts with "Raindex version"', () => { | ||
const error = 'Raindex version error'; | ||
const comp = render(RaindexVersionValidator, { props: { error } }); | ||
|
||
const alert = comp.getByRole('alert'); | ||
expect(alert).toContainHTML('<span>Raindex version error</span>'); | ||
expect(alert).toHaveTextContent( | ||
`This order may not be compatible with this version of Raindex. ` | ||
); | ||
}); | ||
|
||
test('should not show error message if error is not a string', () => { | ||
const error = 42; | ||
const comp = render(RaindexVersionValidator, { props: { error } }); | ||
|
||
expect(() => comp.getByRole('alert')).toThrow(); | ||
}); | ||
|
||
test('should not show error message if error does not start with "Raindex version"', () => { | ||
const error = 'Some other error'; | ||
const comp = render(RaindexVersionValidator, { props: { error } }); | ||
|
||
expect(() => comp.getByRole('alert')).toThrow(); | ||
}); | ||
}); |
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
21 changes: 0 additions & 21 deletions
21
tauri-app/src/lib/components/RaindexVersionValidator.svelte
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
tauri-app/src/lib/components/RaindexVersionValidator.test.ts
This file was deleted.
Oops, something went wrong.