generated from neurobagel/react-bagel
-
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.
Updated tests, refactored components and store
- Loading branch information
Showing
8 changed files
with
101 additions
and
87 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
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,13 @@ | ||
participant_id age sex | ||
sub-718211 28.4 M | ||
sub-718213 24.6 F | ||
sub-718216 43.6 M | ||
sub-718217 28.4 F | ||
sub-718218 72.1 M | ||
sub-718219 56.2 M | ||
sub-718220 23 M | ||
sub-718221 22 F | ||
sub-718222 21 M | ||
sub-718223 45 F | ||
sub-718224 34 M | ||
sub-718225 65 M |
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
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 |
---|---|---|
@@ -1,22 +1,24 @@ | ||
import { act, renderHook } from '@testing-library/react'; | ||
import { describe, it, expect } from 'vitest'; | ||
import { mockDataTable, mockInitialColumns } from '~/utils/mocks'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import useDataStore from './data'; | ||
import { mockHeaders, mockDataTable } from '../utils/mocks'; | ||
|
||
describe('store actions', () => { | ||
it('should set dataTable', () => { | ||
it('should process a file and update dataTable, columns, and uploadedDataTableFileName', async () => { | ||
const { result } = renderHook(() => useDataStore()); | ||
act(() => { | ||
result.current.setDataTable(mockDataTable); | ||
}); | ||
expect(result.current.dataTable).toEqual(mockDataTable); | ||
}); | ||
|
||
it('should initialize columns', () => { | ||
const { result } = renderHook(() => useDataStore()); | ||
act(() => { | ||
result.current.initializeColumns(mockHeaders); | ||
const filePath = path.resolve(__dirname, '../../cypress/fixtures/examples/mock.tsv'); | ||
const fileContent = fs.readFileSync(filePath, 'utf-8'); | ||
const file = new File([fileContent], 'mock.tsv', { type: 'text/tab-separated-values' }); | ||
|
||
await act(async () => { | ||
await result.current.processFile(file); | ||
}); | ||
expect(result.current.columns).toEqual(mockHeaders); | ||
|
||
expect(result.current.dataTable).toEqual(mockDataTable); | ||
expect(result.current.columns).toEqual(mockInitialColumns); | ||
expect(result.current.uploadedDataTableFileName).toEqual('mock.tsv'); | ||
}); | ||
}); |
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