Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ListView SSR tests #3094

Merged
merged 8 commits into from
May 4, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/@react-spectrum/list/src/DragPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {classNames, SlotProvider} from '@react-spectrum/utils';
import {Content} from '@react-spectrum/view';
import {Grid} from '@react-spectrum/layout';
import {GridNode} from '@react-types/grid';
import listStyles from './listview.css';
import listStyles from './styles.css';
import {Provider} from '@react-spectrum/provider';
import {ProviderContext} from '@react-types/provider';
import React from 'react';
Expand Down
4 changes: 2 additions & 2 deletions packages/@react-spectrum/list/src/ListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {GridKeyboardDelegate, useGrid} from '@react-aria/grid';
import intlMessages from '../intl/*.json';
import {ListLayout} from '@react-stately/layout';
import {ListState, useListState} from '@react-stately/list';
import listStyles from './listview.css';
import listStyles from './styles.css';
import {ListViewItem} from './ListViewItem';
import {ProgressCircle} from '@react-spectrum/progress';
import React, {ReactElement, useContext, useMemo, useRef} from 'react';
Expand Down Expand Up @@ -65,7 +65,7 @@ const ROW_HEIGHTS = {
}
};

export function useListLayout<T>(state: ListState<T>, density: ListViewProps<T>['density']) {
function useListLayout<T>(state: ListState<T>, density: ListViewProps<T>['density']) {
let {scale} = useProvider();
let collator = useCollator({usage: 'search', sensitivity: 'base'});
let isEmpty = state.collection.size === 0;
Expand Down
2 changes: 1 addition & 1 deletion packages/@react-spectrum/list/src/ListViewItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import type {DraggableItemResult} from '@react-aria/dnd';
import {FocusRing, useFocusRing} from '@react-aria/focus';
import {Grid} from '@react-spectrum/layout';
import ListGripper from '@spectrum-icons/ui/ListGripper';
import listStyles from './listview.css';
import listStyles from './styles.css';
import {ListViewContext} from './ListView';
import {mergeProps} from '@react-aria/utils';
import React, {useContext, useRef} from 'react';
Expand Down
31 changes: 31 additions & 0 deletions packages/@react-spectrum/list/test/ListView.ssr.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/

import {testSSR} from '@react-spectrum/test-utils';

describe('ListView SSR', function () {
it('should render without errors', async function () {
await testSSR(__filename, `
import {Provider} from '@react-spectrum/provider';
import {theme} from '@react-spectrum/theme-default';
import {ListView, Item} from '../';

<Provider theme={theme}>
<ListView aria-label="List view">
<Item>One</Item>
<Item>Two</Item>
<Item>Three</Item>
</ListView>
</Provider>
`);
});
});