Device manager - extract filtered device list header (#9323)
* extract filtered device list header * stylelint
This commit is contained in:
parent
c3bfb6e4a9
commit
951cad98d3
10 changed files with 144 additions and 28 deletions
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
Copyright 2022 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed 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 CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { render } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
|
||||
import FilteredDeviceListHeader from '../../../../../src/components/views/settings/devices/FilteredDeviceListHeader';
|
||||
|
||||
describe('<FilteredDeviceListHeader />', () => {
|
||||
const defaultProps = {
|
||||
selectedDeviceCount: 0,
|
||||
children: <div>test</div>,
|
||||
['data-testid']: 'test123',
|
||||
};
|
||||
const getComponent = (props = {}) => (<FilteredDeviceListHeader {...defaultProps} {...props} />);
|
||||
|
||||
it('renders correctly when no devices are selected', () => {
|
||||
const { container } = render(getComponent());
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('renders correctly when some devices are selected', () => {
|
||||
const { getByText } = render(getComponent({ selectedDeviceCount: 2 }));
|
||||
expect(getByText('2 sessions selected')).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,19 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<FilteredDeviceListHeader /> renders correctly when no devices are selected 1`] = `
|
||||
<div>
|
||||
<div
|
||||
class="mx_FilteredDeviceListHeader"
|
||||
data-testid="test123"
|
||||
>
|
||||
<span
|
||||
class="mx_FilteredDeviceListHeader_label"
|
||||
>
|
||||
Sessions
|
||||
</span>
|
||||
<div>
|
||||
test
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
|
@ -279,7 +279,7 @@ describe('<SessionManagerTab />', () => {
|
|||
await flushPromisesWithFakeTimers();
|
||||
|
||||
// unverified filter is set
|
||||
expect(container.querySelector('.mx_FilteredDeviceList_header')).toMatchSnapshot();
|
||||
expect(container.querySelector('.mx_FilteredDeviceListHeader')).toMatchSnapshot();
|
||||
});
|
||||
|
||||
describe('device detail expansion', () => {
|
||||
|
|
|
@ -17,10 +17,10 @@ exports[`<SessionManagerTab /> Sign out Signs out of current device 1`] = `
|
|||
|
||||
exports[`<SessionManagerTab /> goes to filtered list from security recommendations 1`] = `
|
||||
<div
|
||||
class="mx_FilteredDeviceList_header"
|
||||
class="mx_FilteredDeviceListHeader"
|
||||
>
|
||||
<span
|
||||
class="mx_FilteredDeviceList_headerLabel"
|
||||
class="mx_FilteredDeviceListHeader_label"
|
||||
>
|
||||
Sessions
|
||||
</span>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue