-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Daniel Leroux <daniel.leroux@siemens.com>
- Loading branch information
1 parent
61eeddf
commit 92cfe01
Showing
11 changed files
with
2,044 additions
and
31 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,11 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 Siemens AG | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
/* eslint-disable no-undef */ | ||
module.exports = 'test-file-stub'; |
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,21 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 Siemens AG | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
import { render } from '@testing-library/react'; | ||
import React from 'react'; | ||
import { describe, it } from 'vitest'; | ||
import Content from './example'; | ||
|
||
describe(`example`, () => { | ||
it(`basic`, () => { | ||
const { getByText } = render(<Content />); | ||
|
||
const button = getByText('Hallo'); | ||
button.click(); | ||
}); | ||
}); |
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,21 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 Siemens AG | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { IxButton } from '../../components'; | ||
|
||
const Index = () => { | ||
return ( | ||
<> | ||
<IxButton onClick={() => console.log('Hallo')}>Hallo</IxButton> | ||
</> | ||
); | ||
}; | ||
|
||
export default Index; |
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,17 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Siemens AG | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
import * as matchers from '@testing-library/jest-dom/matchers'; | ||
import { cleanup } from '@testing-library/react'; | ||
import { afterEach, expect } from 'vitest'; | ||
|
||
expect.extend(matchers); | ||
|
||
afterEach(() => { | ||
cleanup(); | ||
}); |
21 changes: 21 additions & 0 deletions
21
packages/react/src/tests/undefined-error/undefined-error.spec.tsx
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,21 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 Siemens AG | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
import { render } from '@testing-library/react'; | ||
import React from 'react'; | ||
import { describe, it } from 'vitest'; | ||
import Content from './undefined-error'; | ||
|
||
describe(`undefined-error`, () => { | ||
it(`basic`, () => { | ||
const { getByText } = render(<Content />); | ||
|
||
const button = getByText('Open'); | ||
button.click(); | ||
}); | ||
}); |
36 changes: 36 additions & 0 deletions
36
packages/react/src/tests/undefined-error/undefined-error.tsx
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,36 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 Siemens AG | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { | ||
IxButton, | ||
IxDivider, | ||
IxDropdown, | ||
IxDropdownHeader, | ||
IxDropdownItem, | ||
} from '../../components'; | ||
|
||
const Index = () => { | ||
// The following example is one of many ways to potentially trigger an undefined access on the OnListener decorator | ||
return ( | ||
<> | ||
<IxButton id="triggerId">Open</IxButton> | ||
<IxDropdown trigger="triggerId"> | ||
<IxDropdownHeader label="Category"></IxDropdownHeader> | ||
<IxDropdownItem label="Item 1"></IxDropdownItem> | ||
<IxDropdownItem label="Item 2"></IxDropdownItem> | ||
<IxDropdownItem label="Item 3"></IxDropdownItem> | ||
<IxDivider></IxDivider> | ||
<IxDropdownItem label="Extra Item"></IxDropdownItem> | ||
</IxDropdown> | ||
</> | ||
); | ||
}; | ||
|
||
export default Index; |
21 changes: 21 additions & 0 deletions
21
...ages/react/src/tests/validation-tooltip-null-error/validation-tooltip-null-error.spec.tsx
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,21 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 Siemens AG | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
import { render } from '@testing-library/react'; | ||
import React from 'react'; | ||
import { describe, it } from 'vitest'; | ||
import Content from './validation-tooltip-null-error'; | ||
|
||
describe(`null-error`, () => { | ||
it(`basic`, () => { | ||
const { getByText } = render(<Content />); | ||
|
||
const input = getByText('Name'); | ||
input.click(); | ||
}); | ||
}); |
40 changes: 40 additions & 0 deletions
40
packages/react/src/tests/validation-tooltip-null-error/validation-tooltip-null-error.tsx
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,40 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 Siemens AG | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { useForm } from 'react-hook-form'; | ||
import { IxValidationTooltip } from '../../components'; | ||
|
||
const Index = () => { | ||
const { register, formState } = useForm({ | ||
defaultValues: { | ||
name: undefined, | ||
}, | ||
shouldFocusError: false, | ||
shouldUseNativeValidation: true, | ||
}); | ||
|
||
return ( | ||
<> | ||
<IxValidationTooltip message="Error hint text"> | ||
<label htmlFor="name">Name</label> | ||
<input | ||
type="text" | ||
className={`${formState.errors.name ? 'is-invalid' : ''}`} | ||
id="name" | ||
{...register('name', { | ||
required: true, | ||
})} | ||
/> | ||
</IxValidationTooltip> | ||
</> | ||
); | ||
}; | ||
|
||
export default Index; |
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,17 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Siemens AG | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
import { defineConfig } from 'vitest/config'; | ||
|
||
export default defineConfig({ | ||
test: { | ||
globals: true, | ||
environment: 'jsdom', | ||
setupFiles: './src/tests/setup.js', | ||
}, | ||
}); |
Oops, something went wrong.