Skip to content
This repository has been archived by the owner on Dec 21, 2021. It is now read-only.

More frontend tests #56

Merged
merged 37 commits into from
Sep 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
c78fd8e
add complete coverage for InputField
Sep 3, 2018
3eec937
add more coverage for InputFieldInput
Sep 3, 2018
eb78bff
add complete coverage for InputFieldLabel
Sep 3, 2018
cdbfaa7
add full coverage for InputFieldValidation
Sep 3, 2018
34d4497
Merge remote-tracking branch 'origin/master' into more-frontend-test
Sep 4, 2018
c16400d
remove base app
Sep 5, 2018
b6642ec
add utils tests
Sep 5, 2018
02843fb
remove register_service_worker
Sep 5, 2018
5b0d529
add more ContextMenu tests
Sep 5, 2018
ff461d9
add full DropDownMenu coverage
Sep 5, 2018
834add9
add more checkbox tests
Sep 5, 2018
fccaa07
add more form tests
Sep 5, 2018
93d03e7
remove obsolete snapshot
Sep 5, 2018
dad791b
format all test files
Sep 5, 2018
113f347
add full coverage for Form
Sep 6, 2018
018c69f
add an internal Link Button
Sep 6, 2018
a1f6376
add full coverage for SlideInPanel
Sep 6, 2018
9e2b492
add full coverage for SelectList
Sep 6, 2018
ae1cb3e
update jest settings
Sep 7, 2018
cfe5d3a
add full coverage for SlideOutContainer
Sep 7, 2018
02b89fc
add more coverage to Popup
Sep 7, 2018
ea1b843
add more tests for Tooltip
Sep 7, 2018
59cc9de
add more tests for TagsSelector
Sep 7, 2018
2908f0e
add more tests for ImageFile
Sep 7, 2018
a28a19f
use jsdom as the testEnvironment
Sep 11, 2018
3657ca8
add more tests to Tooltip
Sep 12, 2018
cf315df
fix isBrowserWindowHidden test
Sep 12, 2018
b987e9c
remove obsolete snapshots
Sep 12, 2018
ec57a86
add more tests to UserAccountMenu
Sep 12, 2018
9ba2589
add more tests to ToggleButton
Sep 12, 2018
0f92964
add more tests for Modal
Sep 12, 2018
98b72bc
add full coverage for CloseButton
Sep 12, 2018
c92e4a1
add test to DatePicker
Sep 12, 2018
64d0696
some test improvements
Sep 12, 2018
9b9c033
fix Dropzone import issues with jest
Sep 14, 2018
51ac7e9
conform to agreed standards
Sep 14, 2018
7fc10f4
add some comments
Sep 14, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,12 @@
],
"coverageThreshold": {
"global": {
"statements": 73,
"branches": 39,
"functions": 49,
"lines": 68
"statements": 80,
"branches": 80,
"functions": 80,
"lines": 80
}
},
"testEnvironment": "node",
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
Expand All @@ -109,7 +108,7 @@
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/src/__mocks__/testFileStub.tsx",
"\\.(css|sass)$": "<rootDir>/src/__mocks__/emptyModule.tsx"
"\\.(css|scss)$": "<rootDir>/src/__mocks__/emptyModule.tsx"
},
"moduleFileExtensions": [
"ts",
Expand Down
2 changes: 1 addition & 1 deletion src/__mocks__/clickMock.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Copyright (c) 2018 Ultimaker B.V.

export const mockClickEvent = { stopPropagation: () => { } };
export const mockClickEvent = { stopPropagation: jest.fn(), preventDefault: jest.fn() };
2 changes: 2 additions & 0 deletions src/__mocks__/testFileStub.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Copyright (c) 2018 Ultimaker B.V.
module.exports = 'test-file-stub';
16 changes: 15 additions & 1 deletion src/components/__tests__/__snapshots__/button.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`The Button component renders a anchor when prop \`type\` is link 1`] = `
exports[`The Button component renders a anchor when prop \`type\` is link and an external link is given 1`] = `
<a
className="btn btn--primary btn--rectangle "
href="https://ultimaker.com/"
Expand All @@ -14,6 +14,20 @@ exports[`The Button component renders a anchor when prop \`type\` is link 1`] =
</a>
`;

exports[`The Button component renders a link when prop \`type\` is link and an internal link is given 1`] = `
<Link
className="btn btn--primary btn--rectangle "
replace={false}
to="/print_jobs"
>
<span
className="text"
>
Button text
</span>
</Link>
`;

exports[`The Button component should render 1`] = `
<button
className="btn btn--primary btn--rectangle "
Expand Down
113 changes: 112 additions & 1 deletion src/components/__tests__/__snapshots__/form.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,116 @@ exports[`The Form component should render 1`] = `
className="form"
noValidate={true}
onSubmit={[Function]}
/>
>
<div
className="form__actions"
>
<div
className="form__btn-container"
>
<Button
className=""
disabled={true}
linkToNewTab={false}
shape="rectangle"
style="primary"
type="submit"
>
primaryBtnText
</Button>
</div>
</div>
</form>
`;

exports[`The Form component should render with a form item 1`] = `
<Form
onSubmitHandler={[MockFunction]}
primaryBtnText="primaryBtnText"
>
<form
className="form"
noValidate={true}
onSubmit={[Function]}
>
<div
className="form__item"
key=".0"
>
<InputField
id="test"
labelLayoutWidth="1/1"
labelWidthBreakpoint="sm"
onChangeHandler={[MockFunction]}
type="text"
value={null}
>
<div
className="input-field input-field--text layout"
>
<InputFieldInput
id="test"
labelLayoutWidth="1/1"
labelWidthBreakpoint="sm"
onChangeHandler={[Function]}
type="text"
value={null}
>
<div
className="layout__item u-fill layout__item--middle"
>
<div
className="input-container layout layout--gutter-xs"
>
<div
className="layout__item u-fill"
>
<input
className="input"
id="test"
max={null}
min={null}
name="test"
onChange={[Function]}
type="text"
value=""
/>
</div>
</div>
</div>
</InputFieldInput>
</div>
</InputField>
</div>
<div
className="form__actions"
>
<div
className="form__btn-container"
>
<Button
className=""
disabled={true}
linkToNewTab={false}
shape="rectangle"
style="primary"
type="submit"
>
<button
className="btn btn--primary btn--rectangle disabled"
disabled={true}
onClick={[Function]}
type="submit"
>
<span
className="text"
>
primaryBtnText
</span>
</button>
</Button>
</div>
</div>
</form>
</Form>
`;
12 changes: 10 additions & 2 deletions src/components/__tests__/__snapshots__/image_upload.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`The ImageFile component should render 1`] = `
<Component
<t
accept="image/jpeg, image/png"
className="image-upload"
disableClick={false}
disablePreview={false}
disabled={false}
getDataTransferItems={[Function]}
inputProps={Object {}}
maxSize={Infinity}
minSize={0}
multiple={false}
onDragEnter={[Function]}
onDragLeave={[Function]}
onDrop={[Function]}
preventDropOnDocument={true}
style={
Object {
"height": "18rem",
Expand All @@ -27,5 +35,5 @@ exports[`The ImageFile component should render 1`] = `
<div
className="placeholder placeholder--round"
/>
</Component>
</t>
`;
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`The InputFieldInput component should render 1`] = `
exports[`The InputFieldInput component should render a static text field 1`] = `
<Fragment>
<div
className="layout__item u-fit layout__item--middle"
>
Test input
</div>
</Fragment>
`;

exports[`The InputFieldInput component should render a text input 1`] = `
<Fragment>
<div
className="layout__item u-fill layout__item--middle"
Expand All @@ -26,3 +36,37 @@ exports[`The InputFieldInput component should render 1`] = `
</div>
</Fragment>
`;

exports[`The InputFieldInput component should render children after the input 1`] = `
<Fragment>
<div
className="layout__item u-fill layout__item--middle"
>
<div
className="input-container layout layout--gutter-xs"
>
<div
className="layout__item u-fill"
>
<input
className="input"
id="testInputField"
max={null}
min={null}
name="testInputField"
onChange={[Function]}
type="text"
value="Test input"
/>
</div>
</div>
</div>
<div
className="layout__item u-fit"
>
<div
className="child"
/>
</div>
</Fragment>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,84 @@ exports[`The InputFieldLabel component should render 1`] = `
</div>
</div>
`;

exports[`The InputFieldLabel component should render info link 1`] = `
<div
className="input-field__label layout__item u-1/1-sm"
>
<div
className="layout layout--gutter-sm"
>
<div
className="layout__item u-fit"
>
<label
htmlFor="testInputField"
>
Input label
</label>
</div>
<div
className="layout__item u-fit input-field__label-addition"
>
<InfoLink
infoLinkURL="https://ultimaker.com/"
/>
</div>
</div>
</div>
`;

exports[`The InputFieldLabel component should render info tooltip 1`] = `
<div
className="input-field__label layout__item u-1/1-sm"
>
<div
className="layout layout--gutter-sm"
>
<div
className="layout__item u-fit"
>
<label
htmlFor="testInputField"
>
Input label
</label>
</div>
<div
className="layout__item u-fit input-field__label-addition"
>
<InfoTooltip
infoText="Test tooltip text"
/>
</div>
</div>
</div>
`;

exports[`The InputFieldLabel component should render pre label element before the label 1`] = `
<div
className="input-field__label layout__item u-1/1-sm"
>
<div
className="layout layout--gutter-sm"
>
<div
className="layout__item u-fit input-field__pre-element"
>
<div
className="pre-label-element"
/>
</div>
<div
className="layout__item u-fit"
>
<label
htmlFor="testInputField"
>
Input label
</label>
</div>
</div>
</div>
`;