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

upgraded jest version to 29.6.2 #121

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,31 +101,31 @@
"@babel/preset-typescript": "^7.21.5",
"@storybook/addon-actions": "^7.0.9",
"@storybook/addon-essentials": "^7.0.9",
"@storybook/addon-jest": "^7.0.9",
"@storybook/addon-jest": "^7.3.2",
"@storybook/addon-links": "^7.0.9",
"@storybook/cli": "^7.0.9",
"@storybook/preset-scss": "^1.0.3",
"@storybook/react": "^7.0.9",
"@storybook/react-webpack5": "^7.0.9",
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/jest-dom": "^6.0.1",
"@testing-library/react": "^12.1.2",
"@types/carbon-components-react": "^7.55.2",
"@types/codemirror": "^5.60.5",
"@types/color": "^3.0.2",
"@types/jest": "^24.9.1",
"@types/jest": "^29.5.3",
"@types/lodash": "^4.14.194",
"@typescript-eslint/eslint-plugin": "^5.59.11",
"@typescript-eslint/parser": "^5.59.11",
"babel-jest": "^27.5.1",
"babel-jest": "^29.6.2",
"chromatic": "^6.17.4",
"eslint": "^8.42.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-simple-import-sort": "^10.0.0",
"husky": "4",
"identity-obj-proxy": "^3.0.0",
"jest": "^26.6.3",
"jest-environment-jsdom-fourteen": "1.0.1",
"jest-pnp-resolver": "^1.2.1",
"jest": "^29.6.2",
"jest-environment-jsdom": "^29.6.3",
"jest-pnp-resolver": "^1.2.3",
"lint-staged": "^13.2.2",
"node-sass-package-importer": "^5.3.2",
"prettier": "^2.8.8",
Expand Down Expand Up @@ -193,7 +193,7 @@
"testMatch": [
"<rootDir>/src/**/*(*.)@(spec|test).{js,jsx,ts,tsx}"
],
"testEnvironment": "jest-environment-jsdom-fourteen",
"testEnvironment": "jest-environment-jsdom",
"transform": {
"^.+\\.(js|jsx|ts|tsx)$": "babel-jest"
},
Expand Down
54 changes: 33 additions & 21 deletions src/components/AutoSuggestion/tests/AutoSuggestion.test.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,49 @@
import React from "react";
import "@testing-library/jest-dom";
import {render} from "@testing-library/react";
import AutoSuggestion, {AutoSuggestionProps} from "../AutoSuggestion"
import { render } from "@testing-library/react";
import AutoSuggestion, { AutoSuggestionProps } from "../AutoSuggestion";

describe("AutoSuggestion", () => {
let props: AutoSuggestionProps
let props: AutoSuggestionProps;
beforeAll(() => {
document.createRange = () => {
const range = new Range();
range.getBoundingClientRect = jest.fn();
range.getClientRects = () => {
return {
item: () => null,
length: 0,
[Symbol.iterator]: jest.fn(),
};
};
return range;
};
});

beforeEach(() => {
props = {
label: "test value path",
initialValue: "",
onChange: jest.fn((value) => {
}),
onChange: jest.fn((value) => {}),
fetchSuggestions: jest.fn((inputString, cursorPosition) => undefined),
checkInput: jest.fn(inputString => ({
valid: true
checkInput: jest.fn((inputString) => ({
valid: true,
})),
onInputChecked: jest.fn(validInput => {
}),
onInputChecked: jest.fn((validInput) => {}),
validationErrorText: "",
clearIconText: "",
onFocusChange: jest.fn(hasFocus => {
}),
id: "test-auto-suggestion"
}
})
onFocusChange: jest.fn((hasFocus) => {}),
id: "test-auto-suggestion",
};
});

it("should render properly", () => {
const {container} = render(<AutoSuggestion {...props} />)
expect(container).not.toBeEmptyDOMElement()
})
const { container } = render(<AutoSuggestion {...props} />);
expect(container).not.toBeEmptyDOMElement();
});

it("should set label prop properly", () => {
const {getByText} = render(<AutoSuggestion {...props}/>)
expect(getByText(props.label!!)).toBeTruthy()
})
})
const { getByText } = render(<AutoSuggestion {...props} />);
expect(getByText(props.label!!)).toBeTruthy();
});
});
28 changes: 19 additions & 9 deletions src/components/AutoSuggestion/tests/SingleLineCodeEditor.test.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
import React from "react";
import "@testing-library/jest-dom";
import { render } from "@testing-library/react";
import {
SingleLineCodeEditor,
SingleLineCodeEditorProps,
} from "../../../../index";
import { SingleLineCodeEditor, SingleLineCodeEditorProps } from "../../../../index";
import CodeMirror from "codemirror";
import { CLASSPREFIX as eccgui } from "../../../configuration/constants";

describe("SingleLineCodeEditor", () => {
let props: SingleLineCodeEditorProps,
codeMirrorEditorInstance: CodeMirror.Editor = null as any;
beforeAll(() => {
document.createRange = () => {
const range = new Range();
range.getBoundingClientRect = jest.fn();
range.getClientRects = () => {
return {
item: () => null,
length: 0,
[Symbol.iterator]: jest.fn(),
};
};
return range;
};
});

beforeEach(() => {
props = {
setEditorInstance: jest.fn((editor) => {
codeMirrorEditorInstance = editor;
}),
onChange: jest.fn((value) => {}),
onCursorChange: jest.fn((pos, coords) => {}),
mode: null,
mode: undefined,
initialValue: "",
onFocusChange: jest.fn((focused) => {}),
onKeyDown: jest.fn((event) => {}),
Expand Down Expand Up @@ -49,14 +61,12 @@ describe("SingleLineCodeEditor", () => {

it("should not allow user to create new lines", () => {
render(<SingleLineCodeEditor {...props} />);
codeMirrorEditorInstance
.getDoc()
.setValue("I'm entering a new line \n character");
codeMirrorEditorInstance.getDoc().setValue("I'm entering a new line \n character");
expect(codeMirrorEditorInstance.lineCount()).toBe(1);
});

it("should convert multiple lines to a single line", () => {
render(<SingleLineCodeEditor {...{...props, initialValue: "1\n2\n3"}} />);
render(<SingleLineCodeEditor {...{ ...props, initialValue: "1\n2\n3" }} />);
expect(codeMirrorEditorInstance.lineCount()).toBe(1);
});
});
Loading