-
Notifications
You must be signed in to change notification settings - Fork 1
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
dc53a97
commit 60cf056
Showing
2 changed files
with
109 additions
and
0 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,53 @@ | ||
import { describe, expect, test, afterEach } from 'vitest'; | ||
import { render, screen, cleanup } from '@testing-library/svelte'; | ||
import TableRow from '../../lib/home/TableRow.svelte'; | ||
|
||
describe('Unit:Home/TableRow', () => { | ||
let data = { | ||
id: '_1', | ||
name: 'Test Medicine', | ||
chemicalName: 'Test Medicine Chemical Name', | ||
mrp: 50.0, | ||
totalStock: 10, | ||
index: 0, | ||
}; | ||
afterEach(() => { | ||
cleanup() | ||
}) | ||
test('should render parsed data', () => { | ||
render(TableRow, data); | ||
|
||
Object.keys(data).forEach((key) => { | ||
if (key !== 'id' && key != 'totalStock' && key !== 'index') | ||
expect(screen.getByText(data[key])).toBeTruthy(); | ||
}); | ||
}); | ||
|
||
test('should show Out of stock when totalStock == 0', () => { | ||
data['totalStock'] = 0; | ||
render(TableRow, data); | ||
|
||
expect(screen.getByTestId('availability').innerHTML).toBe('Out of stock'); | ||
}) | ||
|
||
test('should show Limited Stocks when totalStock < 100', () => { | ||
data['totalStock'] = 80; | ||
render(TableRow, data); | ||
|
||
expect(screen.getByTestId('availability').innerHTML).toBe('Limited Stocks'); | ||
}) | ||
|
||
test('should show Available when totalStock >= 100', () => { | ||
data['totalStock'] = 110; | ||
render(TableRow, data); | ||
|
||
expect(screen.getByTestId('availability').innerHTML).toBe('Available'); | ||
}) | ||
|
||
test('snapshot test', () => { | ||
render(TableRow, data); | ||
|
||
expect(screen).toMatchSnapshot(); | ||
}) | ||
|
||
}); |
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,56 @@ | ||
// Vitest Snapshot v1 | ||
|
||
exports[`Unit:Home/TableRow > snapshot test 1`] = ` | ||
{ | ||
"debug": [Function], | ||
"findAllByAltText": [Function], | ||
"findAllByDisplayValue": [Function], | ||
"findAllByLabelText": [Function], | ||
"findAllByPlaceholderText": [Function], | ||
"findAllByRole": [Function], | ||
"findAllByTestId": [Function], | ||
"findAllByText": [Function], | ||
"findAllByTitle": [Function], | ||
"findByAltText": [Function], | ||
"findByDisplayValue": [Function], | ||
"findByLabelText": [Function], | ||
"findByPlaceholderText": [Function], | ||
"findByRole": [Function], | ||
"findByTestId": [Function], | ||
"findByText": [Function], | ||
"findByTitle": [Function], | ||
"getAllByAltText": [Function], | ||
"getAllByDisplayValue": [Function], | ||
"getAllByLabelText": [Function], | ||
"getAllByPlaceholderText": [Function], | ||
"getAllByRole": [Function], | ||
"getAllByTestId": [Function], | ||
"getAllByText": [Function], | ||
"getAllByTitle": [Function], | ||
"getByAltText": [Function], | ||
"getByDisplayValue": [Function], | ||
"getByLabelText": [Function], | ||
"getByPlaceholderText": [Function], | ||
"getByRole": [Function], | ||
"getByTestId": [Function], | ||
"getByText": [Function], | ||
"getByTitle": [Function], | ||
"logTestingPlaygroundURL": [Function], | ||
"queryAllByAltText": [Function], | ||
"queryAllByDisplayValue": [Function], | ||
"queryAllByLabelText": [Function], | ||
"queryAllByPlaceholderText": [Function], | ||
"queryAllByRole": [Function], | ||
"queryAllByTestId": [Function], | ||
"queryAllByText": [Function], | ||
"queryAllByTitle": [Function], | ||
"queryByAltText": [Function], | ||
"queryByDisplayValue": [Function], | ||
"queryByLabelText": [Function], | ||
"queryByPlaceholderText": [Function], | ||
"queryByRole": [Function], | ||
"queryByTestId": [Function], | ||
"queryByText": [Function], | ||
"queryByTitle": [Function], | ||
} | ||
`; |