• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mendersoftware / gui / 951400782

pending completion
951400782

Pull #3900

gitlab-ci

web-flow
chore: bump @testing-library/jest-dom from 5.16.5 to 5.17.0

Bumps [@testing-library/jest-dom](https://github.com/testing-library/jest-dom) from 5.16.5 to 5.17.0.
- [Release notes](https://github.com/testing-library/jest-dom/releases)
- [Changelog](https://github.com/testing-library/jest-dom/blob/main/CHANGELOG.md)
- [Commits](https://github.com/testing-library/jest-dom/compare/v5.16.5...v5.17.0)

---
updated-dependencies:
- dependency-name: "@testing-library/jest-dom"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #3900: chore: bump @testing-library/jest-dom from 5.16.5 to 5.17.0

4446 of 6414 branches covered (69.32%)

8342 of 10084 relevant lines covered (82.73%)

186.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

71.74
/src/js/components/common/chipselect.js
1
// Copyright 2023 Northern.tech AS
2
//
3
//    Licensed under the Apache License, Version 2.0 (the "License");
4
//    you may not use this file except in compliance with the License.
5
//    You may obtain a copy of the License at
6
//
7
//        http://www.apache.org/licenses/LICENSE-2.0
8
//
9
//    Unless required by applicable law or agreed to in writing, software
10
//    distributed under the License is distributed on an "AS IS" BASIS,
11
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//    See the License for the specific language governing permissions and
13
//    limitations under the License.
14
import React, { useEffect, useState } from 'react';
15

16
import { Autocomplete, TextField } from '@mui/material';
17

18
import { TIMEOUTS } from '../../constants/appConstants';
19
import { duplicateFilter, unionizeStrings } from '../../helpers';
20
import { useDebounce } from '../../utils/debouncehook';
21

22
export const ChipSelect = ({
9✔
23
  className = '',
46✔
24
  id = 'chip-select',
×
25
  selection = [],
×
26
  disabled = false,
46✔
27
  inputRef,
28
  label = '',
×
29
  onChange,
30
  options = [],
×
31
  placeholder = ''
×
32
}) => {
33
  const [value, setValue] = useState('');
46✔
34
  const [currentSelection, setCurrentSelection] = useState(selection);
46✔
35

36
  const debouncedValue = useDebounce(value, TIMEOUTS.debounceDefault);
46✔
37

38
  useEffect(() => {
46✔
39
    onChange({ currentValue: debouncedValue, selection: currentSelection });
3✔
40
  }, [debouncedValue, JSON.stringify(currentSelection)]);
41

42
  // to allow device types to automatically be selected on entered ',' we have to filter the input and transform any completed device types (followed by a ',')
43
  // while also checking for duplicates and allowing complete resets of the input
44
  const onTextInputChange = (inputValue, reason) => {
46✔
45
    const value = inputValue || '';
18✔
46
    if (reason === 'clear') {
18!
47
      setValue('');
×
48
      return setCurrentSelection([]);
×
49
    } else if (reason === 'reset') {
18!
50
      return setValue('');
×
51
    }
52
    const lastIndex = value.lastIndexOf(',');
18✔
53
    const possibleSelection = value.substring(0, lastIndex).split(',').filter(duplicateFilter);
18✔
54
    const currentValue = value.substring(lastIndex + 1);
18✔
55
    const nextSelection = unionizeStrings(currentSelection, possibleSelection);
18✔
56
    setValue(currentValue);
18✔
57
    setCurrentSelection(nextSelection);
18✔
58
  };
59

60
  const onTextInputLeave = value => {
46✔
61
    const nextSelection = unionizeStrings(currentSelection, [value]);
1✔
62
    setValue('');
1✔
63
    setCurrentSelection(nextSelection);
1✔
64
  };
65

66
  return (
46✔
67
    <Autocomplete
68
      id={id}
69
      value={currentSelection}
70
      className={className}
71
      filterSelectedOptions
72
      freeSolo={true}
73
      includeInputInList={true}
74
      multiple
75
      // allow edits to the textinput without deleting existing device types by ignoring backspace
76
      onChange={(e, value) => (e.key !== 'Backspace' ? setCurrentSelection(value) : null)}
×
77
      onInputChange={(e, v, reason) => onTextInputChange(null, reason)}
9✔
78
      options={options}
79
      readOnly={disabled}
80
      renderInput={params => (
81
        <TextField
49✔
82
          {...params}
83
          fullWidth
84
          inputProps={{ ...params.inputProps, value }}
85
          InputProps={{ ...params.InputProps, disableUnderline: disabled }}
86
          key={`${id}-input`}
87
          label={label}
88
          onBlur={e => onTextInputLeave(e.target.value)}
1✔
89
          onChange={e => onTextInputChange(e.target.value, 'input')}
9✔
90
          placeholder={currentSelection.length ? '' : placeholder}
49✔
91
          inputRef={inputRef}
92
        />
93
      )}
94
    />
95
  );
96
};
97

98
export default ChipSelect;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc