How to use onSelectionChange method in Testcafe

Best JavaScript code snippet using testcafe

_internal_listbox.js

Source:_internal_listbox.js Github

copy

Full Screen

...83 <ListboxMultipleSelect84 {...props}85 onSelectionChange={(values) =>86 exists(props.onSelectionChange) &&87 props.onSelectionChange(Array.from(values))88 }89 />90 );91 }92 return (93 <ListboxSingleSelect94 {...props}95 selectionMode={props.selectionMode}96 onSelectionChange={(value) =>97 exists(props.onSelectionChange) && props.onSelectionChange(value)98 }99 />100 );101}102function parseSingleSelection(selection) {103 if (selection === "all") {104 return undefined;105 } else {106 return selection.values().next().value;107 }108}109function parseMultipleSelection(selection) {110 if (selection === "all") {111 return undefined;112 } else {113 return Array.from(selection);114 }115}116function ListboxSingleSelect(props) {117 const ref = useRef(null);118 const {119 children,120 selectedKeys,121 renderInline,122 onSelectionChange,123 disabledKeys,124 } = props;125 const { style, testId, vislyProps, values } = usePrimitive({126 ref,127 props,128 });129 const state = useSingleSelectListState({130 children: renderCollection(children),131 selectedKey: selectedKeys,132 onSelectionChange,133 disallowEmptySelection: false,134 disabledKeys,135 });136 const { label, registerLabelProps } = useFormLabel();137 const { listBoxProps, labelProps } = useListBox(138 {139 ...props,140 disallowEmptySelection: false,141 selectedKeys: [selectedKeys],142 onSelectionChange: (values) =>143 onSelectionChange(parseSingleSelection(values)),144 label,145 disabledKeys,146 },147 state,148 ref149 );150 useEffect(() => {151 registerLabelProps(labelProps);152 }, []);153 return (154 <ListboxPrimitiveImpl155 {...props}156 listBoxProps={listBoxProps}157 vislyProps={vislyProps}158 renderInline={renderInline}159 values={values}160 testId={testId}161 style={style}162 vislyRef={ref}163 state={state}164 />165 );166}167function ListboxMultipleSelect(props) {168 const ref = useRef(null);169 const {170 children,171 selectedKeys,172 renderInline,173 onSelectionChange,174 disabledKeys,175 } = props;176 const { style, testId, vislyProps, values } = usePrimitive({177 ref,178 props,179 });180 const state = useListState({181 children: renderCollection(children),182 selectionMode: "multiple",183 selectedKeys,184 onSelectionChange: (keys) => {185 onSelectionChange(parseMultipleSelection(keys));186 },187 disallowEmptySelection: false,188 disabledKeys,189 });190 const { label, registerLabelProps } = useFormLabel();191 const { listBoxProps, labelProps } = useListBox(192 {193 ...props,194 disallowEmptySelection: false,195 selectedKeys,196 onSelectionChange: (values) =>197 onSelectionChange(parseMultipleSelection(values)),198 label,199 disabledKeys,200 },201 state,202 ref203 );204 useEffect(() => {205 registerLabelProps(labelProps);206 }, []);207 return (208 <ListboxPrimitiveImpl209 {...props}210 listBoxProps={listBoxProps}211 vislyProps={vislyProps}...

Full Screen

Full Screen

selectable.spec.js

Source:selectable.spec.js Github

copy

Full Screen

1'use strict';2describe("Selectable", function () {3 var Selectable = Bahmni.Clinical.Selectable;4 describe("select", function() {5 it("should select with self as source when source not specified", function() {6 var selectable = new Selectable();7 selectable.select();8 expect(selectable.isSelected()).toBeTruthy();9 expect(selectable.isSelectedFromSelf()).toBeTruthy();10 });11 it("should select with given source", function() {12 var parentSlectable = new Selectable();13 var selectable = new Selectable();14 selectable.select(parentSlectable);15 expect(selectable.isSelected()).toBeTruthy();16 expect(selectable.isSelectedFromOtherSource()).toBeTruthy();17 expect(selectable.isSelectedFromSelf()).toBeFalsy();18 });19 it("should select the children", function() {20 var child1 = new Selectable()21 var child2 = new Selectable()22 var selectable = new Selectable({}, [child1, child2]);23 selectable.select();24 expect(selectable.isSelected()).toBeTruthy();25 expect(child1.isSelected()).toBeTruthy();26 expect(child2.isSelected()).toBeTruthy();27 });28 it("should remove the child's self source", function() {29 var child = new Selectable()30 var selectable = new Selectable({}, [child]);31 child.select();32 expect(child.isSelectedFromSelf()).toBeTruthy();33 selectable.select();34 expect(child.isSelected()).toBeTruthy();35 expect(child.isSelectedFromSelf()).toBeFalsy();36 });37 });38 describe("unselect", function() {39 it("should unselect with self as source", function() {40 var selectable = new Selectable();41 selectable.select();42 selectable.unselect();43 expect(selectable.isSelected()).toBeFalsy();44 expect(selectable.isSelectedFromSelf()).toBeFalsy();45 });46 it("should unselect for given source only", function() {47 var child = new Selectable();48 var parent1 = new Selectable({}, [child]);49 var parent2 = new Selectable({}, [child]);50 parent1.select();51 parent2.select();52 expect(child.isSelected()).toBeTruthy();53 child.unselect(parent1);54 expect(child.isSelected()).toBeTruthy();55 child.unselect(parent2);56 expect(child.isSelected()).toBeFalsy();57 });58 it("should unselect the children", function() {59 var child1 = new Selectable()60 var child2 = new Selectable()61 var selectable = new Selectable({}, [child1, child2]);62 selectable.select();63 selectable.unselect();64 expect(child1.isSelected()).toBeFalsy();65 expect(child2.isSelected()).toBeFalsy();66 expect(selectable.isSelected()).toBeFalsy();67 }); 68 });69 describe("toggle", function() {70 it("should slect when not selected", function() {71 var child1 = new Selectable()72 var child2 = new Selectable()73 var selectable = new Selectable({}, [child1, child2]);74 selectable.toggle();75 expect(selectable.isSelected()).toBeTruthy();76 expect(selectable.isSelectedFromSelf()).toBeTruthy();77 expect(child1.isSelected()).toBeTruthy();78 expect(child2.isSelected()).toBeTruthy();79 });80 it("should unslect when selected", function() {81 var child1 = new Selectable()82 var child2 = new Selectable()83 var selectable = new Selectable({}, [child1, child2]);84 selectable.select();85 selectable.toggle();86 expect(selectable.isSelected()).toBeFalsy();87 expect(selectable.isSelectedFromSelf()).toBeFalsy();88 expect(child1.isSelected()).toBeFalsy();89 expect(child2.isSelected()).toBeFalsy();90 });91 });92 describe("onSelectionChange", function () {93 var onSelectionChange;94 beforeEach(function() {95 onSelectionChange = jasmine.createSpy('onSelectionChange');96 });97 it("should be triggered on selecting", function() {98 var selectable = new Selectable({},[],onSelectionChange);99 selectable.select();100 expect(onSelectionChange).toHaveBeenCalledWith(selectable);101 });102 it("should be triggered on child and parent on selecting parent", function() {103 var child = new Selectable({}, [], onSelectionChange)104 var selectable = new Selectable({}, [child], onSelectionChange);105 selectable.select();106 expect(onSelectionChange.calls.count()).toBe(2);107 expect(onSelectionChange).toHaveBeenCalledWith(selectable);108 expect(onSelectionChange).toHaveBeenCalledWith(child);109 });110 it("should be triggered on unselecting", function() {111 var selectable = new Selectable({},[],onSelectionChange);112 selectable.select();113 selectable.unselect();114 expect(onSelectionChange.calls.count()).toBe(2);115 expect(onSelectionChange.calls.mostRecent().args[0]).toBe(selectable);116 });117 it("should be triggered on child and parent on unselecting parent", function() {118 var child = new Selectable({}, [], onSelectionChange)119 var selectable = new Selectable({}, [child], onSelectionChange);120 selectable.select();121 selectable.unselect();122 expect(onSelectionChange.calls.count()).toBe(4);123 expect(onSelectionChange.calls.all()[2].args[0]).toBe(child);124 expect(onSelectionChange.calls.all()[3].args[0]).toBe(selectable);125 });126 it("should not be triggered on selecting, when it is already selected via same source", function() {127 var selectable = new Selectable({},[],onSelectionChange);128 selectable.select();129 selectable.select();130 selectable.select();131 expect(onSelectionChange.calls.count()).toBe(1);132 });133 it("should not be triggered on unselecting, when it is already unselected via same source", function() {134 var selectable = new Selectable({},[],onSelectionChange);135 selectable.select();136 selectable.unselect();137 selectable.unselect();138 selectable.unselect();139 expect(onSelectionChange.calls.count()).toBe(2);140 });141 it("should be triggered on selecting already selected one via different sources", function() {142 var child = new Selectable({}, [], onSelectionChange);143 var parent1 = new Selectable({}, [child]);144 var parent2 = new Selectable({}, [child]);145 child.select(parent1);146 child.select(parent2);147 expect(onSelectionChange.calls.count()).toBe(2);148 });149 it("should be triggered on unselecting already unselected one via different sources", function() {150 var child = new Selectable({}, [], onSelectionChange);151 var parent1 = new Selectable({}, [child]);152 var parent2 = new Selectable({}, [child]);153 child.select(parent1);154 child.select(parent2);155 child.unselect(parent1);156 child.unselect(parent2);157 expect(onSelectionChange.calls.count()).toBe(4);158 });159 });...

Full Screen

Full Screen

edge-bidirectional.js

Source:edge-bidirectional.js Github

copy

Full Screen

1/**2 * Copyright (c) 2015, The Regents of the University of California,3 * through Lawrence Berkeley National Laboratory (subject to receipt4 * of any required approvals from the U.S. Dept. of Energy).5 * All rights reserved.6 *7 * This source code is licensed under the BSD-style license found in the8 * LICENSE file in the root directory of this source tree.9 */10"use strict";11var _interopRequireDefault = require("babel-runtime/helpers/interop-require-default")["default"];12Object.defineProperty(exports, "__esModule", {13 value: true14});15var _react = require("react");16var _react2 = _interopRequireDefault(_react);17var _edgeLinear = require("./edge-linear");18var _edgeLinear2 = _interopRequireDefault(_edgeLinear);19var _edgeArc = require("./edge-arc");20var _edgeArc2 = _interopRequireDefault(_edgeArc);21exports["default"] = _react2["default"].createClass({22 displayName: "edge-bidirectional",23 getDefaultProps: function getDefaultProps() {24 return {25 width: 1,26 spacing: 3.5,27 offset: 18,28 sourceTargetColor: "#C9CACC",29 targetSourceColor: "#C9CACC",30 selected: false,31 muted: false32 };33 },34 render: function render() {35 var paths = [];36 var sourceToTargetName = this.props.source + "--" + this.props.target;37 var targetToSourceName = this.props.target + "--" + this.props.source;38 // Position of the bidirectional lines relative to the center line39 var position = this.props.width * 0.75;40 if (this.props.shape === "curved") {41 return _react2["default"].createElement(42 "g",43 null,44 _react2["default"].createElement(_edgeArc2["default"], {45 name: this.props.name,46 x1: this.props.x1,47 y1: this.props.y1,48 x2: this.props.x2,49 y2: this.props.y2,50 arrow: true,51 position: position,52 color: this.props.sourceTargetColor,53 width: this.props.width,54 classed: this.props.classed,55 key: sourceToTargetName,56 curveDirection: this.props.curveDirection,57 offset: this.props.offset,58 selected: this.props.selected,59 onSelectionChange: this.props.onSelectionChange,60 muted: this.props.muted }),61 _react2["default"].createElement(_edgeArc2["default"], {62 name: this.props.name,63 x1: this.props.x2,64 y1: this.props.y2,65 x2: this.props.x1,66 y2: this.props.y1,67 arrow: true,68 position: position,69 color: this.props.targetSourceColor,70 width: this.props.width,71 classed: this.props.classed,72 key: targetToSourceName,73 curveDirection: this.props.curveDirection,74 offset: this.props.offset,75 selected: this.props.selected,76 onSelectionChange: this.props.onSelectionChange,77 muted: this.props.muted }),78 _react2["default"].createElement(_edgeArc2["default"], {79 name: this.props.name,80 x1: this.props.x2,81 y1: this.props.y2,82 x2: this.props.x1,83 y2: this.props.y1,84 position: 0,85 width: 5,86 classed: this.props.classed,87 key: sourceToTargetName + "-event-region",88 onSelectionChange: this.props.onSelectionChange,89 curveDirection: this.props.curveDirection,90 offset: this.props.offset,91 invisible: true })92 );93 } else {94 return _react2["default"].createElement(95 "g",96 null,97 _react2["default"].createElement(_edgeLinear2["default"], {98 name: this.props.name,99 x1: this.props.x1,100 y1: this.props.y1,101 x2: this.props.x2,102 y2: this.props.y2,103 arrow: true,104 color: this.props.sourceTargetColor,105 width: this.props.width,106 position: position,107 className: this.props.classed,108 key: sourceToTargetName,109 selected: this.props.selected,110 muted: this.props.muted,111 onSelectionChange: this.props.onSelectionChange }),112 _react2["default"].createElement(_edgeLinear2["default"], {113 name: this.props.name,114 x1: this.props.x2,115 y1: this.props.y2,116 x2: this.props.x1,117 y2: this.props.y1,118 arrow: true,119 color: this.props.targetSourceColor,120 width: this.props.width,121 position: position,122 className: this.props.classed,123 key: targetToSourceName,124 selected: this.props.selected,125 muted: this.props.muted,126 onSelectionChange: this.props.onSelectionChange }),127 _react2["default"].createElement(_edgeLinear2["default"], {128 name: this.props.name,129 x1: this.props.x2,130 y1: this.props.y2,131 x2: this.props.x1,132 y2: this.props.y1,133 width: 5,134 position: 0,135 className: this.props.classed,136 key: targetToSourceName + "-event-region",137 onSelectionChange: this.props.onSelectionChange,138 invisible: true })139 );140 }141 return _react2["default"].createElement(142 "g",143 null,144 paths145 );146 }147});...

Full Screen

Full Screen

useListState.spec.js

Source:useListState.spec.js Github

copy

Full Screen

1import React from 'react';2import { act } from 'react-test-renderer';3import { useListState } from '../useListState';4import createTestInstance from '../../util/createTestInstance';5const log = jest.fn();6const Component = props => {7 const { listStateProps } = props;8 log(useListState(listStateProps));9 return null;10};11test('testing initialState and its shape', () => {12 const props = { selectionModel: 'radio', onSelectionChange: jest.fn() };13 createTestInstance(<Component listStateProps={props} />);14 const [state, api] = log.mock.calls[0][0];15 expect(state).toEqual({16 cursor: null,17 hasFocus: false,18 selection: new Set()19 });20 expect(api).toHaveProperty('setFocus');21 expect(api).toHaveProperty('removeFocus');22 expect(api).toHaveProperty('updateSelection');23 expect(typeof api.setFocus).toBe('function');24 expect(typeof api.removeFocus).toBe('function');25 expect(typeof api.updateSelection).toBe('function');26});27test('setFocus should update cursor and hasFocus values inside state', () => {28 const props = { selectionModel: 'radio', onSelectionChange: jest.fn() };29 createTestInstance(<Component listStateProps={props} />);30 let [state, api] = log.mock.calls[0][0];31 expect(state.cursor).toBeNull();32 expect(state.hasFocus).not.toBeTruthy();33 api.setFocus('001');34 [state, api] = log.mock.calls[1][0];35 expect(state.cursor).toBe('001');36 expect(state.hasFocus).toBeTruthy();37});38test('removeFocus should set hasFocus value to false leaving cursor untouched', () => {39 const props = { selectionModel: 'radio', onSelectionChange: jest.fn() };40 createTestInstance(<Component listStateProps={props} />);41 let [state, api] = log.mock.calls[0][0];42 api.setFocus('002');43 [state, api] = log.mock.calls[1][0];44 expect(state.cursor).toBe('002');45 expect(state.hasFocus).toBeTruthy();46 api.removeFocus();47 [state, api] = log.mock.calls[2][0];48 expect(state.cursor).toBe('002');49 expect(state.hasFocus).not.toBeTruthy();50});51test('updateSelection should replace the selected ID inside selection state when selectionModel is radio', () => {52 const props = {53 selectionModel: 'radio',54 onSelectionChange: jest.fn()55 };56 createTestInstance(<Component listStateProps={props} />);57 let [state, api] = log.mock.calls[0][0];58 api.updateSelection('001');59 [state, api] = log.mock.calls[1][0];60 expect(state.selection.has('001')).toBeTruthy();61 api.updateSelection('002');62 [state, api] = log.mock.calls[2][0];63 expect(state.selection.has('001')).not.toBeTruthy();64 expect(state.selection.has('002')).toBeTruthy();65});66test('updateSelection should add the new ID into selection state when selectionModel is checkbox', () => {67 const props = { selectionModel: 'checkbox', onSelectionChange: jest.fn() };68 createTestInstance(<Component listStateProps={props} />);69 let [state, api] = log.mock.calls[0][0];70 api.updateSelection('001');71 [state, api] = log.mock.calls[1][0];72 expect(state.selection.has('001')).toBeTruthy();73 api.updateSelection('002');74 [state, api] = log.mock.calls[2][0];75 expect(state.selection.has('001')).toBeTruthy();76 expect(state.selection.has('002')).toBeTruthy();77});78test('onSelectionChange should be triggered when selection state changes', () => {79 const onSelectionChange = jest.fn();80 const props = { selectionModel: 'radio', onSelectionChange };81 createTestInstance(<Component listStateProps={props} />);82 expect(onSelectionChange).toHaveBeenNthCalledWith(1, new Set());83 const [, api] = log.mock.calls[0][0];84 act(() => {85 api.updateSelection('001');86 });87 expect(onSelectionChange).toHaveBeenNthCalledWith(2, new Set(['001']));88});89test('if onSelectionChange is not provided, no error should be thrown', () => {90 const props = { selectionModel: 'radio' };91 expect(() =>92 createTestInstance(<Component listStateProps={props} />)93 ).not.toThrow();94});95test('ID selection should have toggling behavior when selectionModel is checkbox', () => {96 const props = { selectionModel: 'checkbox', onSelectionChange: jest.fn() };97 createTestInstance(<Component listStateProps={props} />);98 let [state, api] = log.mock.calls[0][0];99 api.updateSelection('001');100 [state, api] = log.mock.calls[1][0];101 expect(state.selection.has('001')).toBeTruthy();102 api.updateSelection('001');103 [state, api] = log.mock.calls[2][0];104 expect(state.selection.has('001')).not.toBeTruthy();105});106test('ID selection should not have toggling behavior when selectionModel is radio', () => {107 const props = { selectionModel: 'radio', onSelectionChange: jest.fn() };108 createTestInstance(<Component listStateProps={props} />);109 let [state, api] = log.mock.calls[0][0];110 api.updateSelection('001');111 [state, api] = log.mock.calls[1][0];112 expect(state.selection.has('001')).toBeTruthy();113 api.updateSelection('001');114 [state, api] = log.mock.calls[2][0];115 expect(state.selection.has('001')).toBeTruthy();116});117test('setFocus and removeFocus should be memoized', () => {118 const initialProps = {119 selectionModel: 'radio',120 onSelectionChange: jest.fn()121 };122 const comp = createTestInstance(123 <Component listStateProps={initialProps} />124 );125 comp.update(<Component listStateProps={initialProps} />);126 expect(log.mock.calls[1][0][1].setFocus).toBe(127 log.mock.calls[0][0][1].setFocus128 );129 expect(log.mock.calls[1][0][1].removeFocus).toBe(130 log.mock.calls[0][0][1].removeFocus131 );132});133test('updateSelection should get new reference if selectionModel argument changes', () => {134 const initialProps = {135 selectionModel: 'radio',136 onSelectionChange: jest.fn()137 };138 const comp = createTestInstance(139 <Component listStateProps={initialProps} />140 );141 comp.update(142 <Component143 listStateProps={{ ...initialProps, selectionModel: 'checkbox' }}144 />145 );146 expect(log.mock.calls[1][0][1].updateSelection).not.toBe(147 log.mock.calls[0][0][1].updateSelection148 );...

Full Screen

Full Screen

list.js

Source:list.js Github

copy

Full Screen

...46 );47 const handleSelectionChange = useCallback(48 selection => {49 if (onSelectionChange) {50 onSelectionChange(selection);51 }52 },53 [onSelectionChange]54 );55 const Root = useMemo(56 () => fromRenderProp(render, Object.keys(customProps)),57 [render, customProps]58 );59 return (60 <Root className={classes.root} {...customProps} {...restProps}>61 <Items62 getItemKey={getItemKey}63 initialSelection={initialSelection}64 items={items}...

Full Screen

Full Screen

Layout_menu.js

Source:Layout_menu.js Github

copy

Full Screen

1Ext.define('app.view.main.Layout_menu',{2 extend : 'Ext.toolbar.Toolbar',3 xtype : 'menuBar',4 itemId: 'menuBar',5 requires:[6 'app.util.Constants',7 'app.util.commonUtil',8 'Ext.toolbar.Toolbar'9 ],10 height : 40,11 overflowHandler:'scroller',12 items : [ //存放按钮组13 {14 text : '我的工作台',15 border : 0,16 iconCls : 'fa fa-home fa-fw',17 name : 'main.Layout_welcome',18 listeners : {19 click : 'onSelectionChange'20 }21 }/*,'-',{22 text:'Login',23 border :0,24 iconCls : 'fa fa-warning fa-fw',25 name:'anthentication.Login',26 listeners : {27 click : 'onSelectionChange'28 }29 },30 {31 text : '系统日志',32 border : 0,33 iconCls : 'fa fa-home fa-fw',34 name : 'sys.Logs', //提交地址35 listeners : {36 click : 'onSelectionChange'37 }38 }*/,'-'39// {40// text:'系统管理',41// border : 0,42// iconCls: 'fa fa-cogs fa-fw', // <-- icon43// menu: Ext.create('Ext.menu.Menu', {44// id: 'mainMenu',45// items : [46// {text: '菜单资源管理',iconCls:'fa fa-cogs fa-fw',name:'sys.Modular',listeners : {click:'onSelectionChange'}},47// {text: '权限管理',iconCls:'fa fa-lock fa-fw',name:'sys.RightViewPort',listeners : {click:'onSelectionChange'}},48// {text: '角色管理',iconCls:'fa fa-retweet fa-fw',name:'sys.Role',listeners : {click:'onSelectionChange'}},49// {text: '字典管理',iconCls:'fa fa-book fa-fw',name:'sys.Dict',listeners : {click:'onSelectionChange'}},50// {text: '部门管理',iconCls:'fa fa-sitemap fa-fw',name:'sys.DeptViewPort',listeners : {click:'onSelectionChange'}},51// {text: '人员管理',iconCls:'fa fa-users fa-fw',name:'sys.UserViewPort',listeners : {click:'onSelectionChange'}},52// {text: '系统监控',iconCls:'fa fa-comments fa-fw',menu :Ext.create('Ext.menu.Menu',{53// items : [54// {text:'SQL统计',iconCls : 'fa fa- fa-fw',name:'sys.log.SQL',listeners : {click:'onSelectionChange'}},55// {text:'Request统计',iconCls : 'fa fa- fa-fw',name:'sys.log.Request',listeners : {click:'onSelectionChange'}},56// {text:'Session统计',iconCls : 'fa fa- fa-fw',name:'sys.log.Session',listeners : {click:'onSelectionChange'}},57// {text:'系统错误日志',iconCls : 'fa fa-warning-sign fa-fw',name:'sys.log.Error',listeners : {click:'onSelectionChange'}},58// {text:'操作统计',iconCls : 'fa fa- fa-fw',name:'sys.Logs',listeners : {click:'onSelectionChange'}},59// {text:'服务器信息',iconCls : 'fa fa- fa-fw',name:'sys.log.Server',listeners : {click:'onSelectionChange'}}60// ]61// })}62// ]63// })64// }65 ]...

Full Screen

Full Screen

list.spec.js

Source:list.spec.js Github

copy

Full Screen

1import React from 'react';2import List, { Items } from '..';3import createTestInstance from '../../util/createTestInstance';4const classes = {5 root: 'abc'6};7const items = [8 {9 id: '001',10 name: 'Test Product 1',11 small_image: '/test/product/1.png',12 price: {13 regularPrice: {14 amount: {15 value: 10016 }17 }18 }19 },20 {21 id: '002',22 name: 'Test Product 2',23 small_image: '/test/product/2.png',24 price: {25 regularPrice: {26 amount: {27 value: 10028 }29 }30 }31 }32];33const getItemKey = jest.fn(({ id }) => id);34const renderItem = jest.fn(() => <div />);35const onSelectionChange = jest.fn();36test('snapshot testing List component', () => {37 const tree = createTestInstance(38 <List39 classes={classes}40 items={items}41 getItemKey={getItemKey}42 selectionModel="radio"43 render="div"44 renderItem={renderItem}45 onSelectionChange={onSelectionChange}46 />47 );48 expect(tree.toTree()).toMatchSnapshot();49});50test('rerenders should not create new root element if props dint change', () => {51 const renderer = createTestInstance(<List items={items} render="div" />);52 const firstRoot = renderer.root.children[0];53 renderer.update(<List items={items} render="div" />);54 expect(firstRoot).toEqual(renderer.root.children[0]);55});56test('rerenders should create new root element if props change', () => {57 const renderer = createTestInstance(<List items={items} render="div" />);58 const firstRoot = renderer.root.children[0];59 renderer.update(<List items={items} render="ul" />);60 expect(firstRoot).not.toEqual(renderer.root.children[0]);61});62test('handleSelectionChange is memoized on onSelectionChange prop', () => {63 const renderer = createTestInstance(64 <List items={items} onSelectionChange={onSelectionChange} />65 );66 const firstHandleSelectionChange = renderer.root.findByType(Items).props67 .onSelectionChange;68 renderer.update(<List items={items} onSelectionChange={jest.fn()} />);69 expect(firstHandleSelectionChange).not.toEqual(70 renderer.root.findByType(Items).props.onSelectionChange71 );72});73test('renders the component provided using render prop as the container', () => {74 const Nav = () => <nav />;75 const instance = createTestInstance(<List items={items} render={Nav} />)76 .root;77 expect(instance.children[0].type).toEqual(Nav);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('My first test', async t => {3 .typeText('#developer-name', 'John Smith')4 .click('#macos')5 .click('#submit-button')6 .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');7});8 .typeText('#developer-name', 'John Smith')9 .click('#macos')10 .click('#submit-button')11 .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');12});13test('My first test', async t => {14 .typeText('#developer-name', 'John Smith')15 .click('#macos')16 .click('#submit-button')17 .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');18});19 .typeText('#developer-name', 'John Smith')20 .click('#macos')21 .click('#submit-button')22 .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');23});24test('My first test', async t => {25 .typeText('#developer-name', 'John Smith')26 .click('#macos')27 .click('#submit-button')28 .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');29});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('My first test', async t => {3 .typeText('#developer-name', 'John Smith')4 .click('#submit-button')5 .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');6});7test('My second test', async t => {8 .typeText('#developer-name', 'John Smith')9 .click('#submit-button')10 .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');11});12test('My third test', async t => {13 .typeText('#developer-name', 'John Smith')14 .click('#submit-button')15 .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');16});17import { Selector } from 'testcafe';18test('My first test', async t => {19 .typeText('#developer-name', 'John Smith')20 .click('#submit-button')21 .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');22});23test('My second test', async t => {24 .typeText('#developer-name', 'John Smith')25 .click('#submit-button')26 .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');27});28test('My third test', async t => {29 .typeText('#developer-name', 'John Smith')30 .click('#submit-button')31 .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');32});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('My first test', async t => {3 .typeText('#developer-name', 'John Smith')4 .click('#windows')5 .click('#submit-button')6 .wait(5000)7 .takeScreenshot();8});9const getSelectedText = ClientFunction(() => {10 const selection = window.getSelection();11 return selection.toString();12});13const textArea = Selector('#developer-name');14test('Get selected text', async t => {15 .selectText(textArea)16 .pressKey('delete')17 .typeText(textArea, 'John Smith')18 .selectText(textArea, 5, 11)19 .expect(getSelectedText()).eql('Smith');20});21const getSelectedText = ClientFunction(() => {22 const selection = window.getSelection();23 return selection.toString();24});25const textArea = Selector('#developer-name');26test('Get selected text', async t => {27 .selectText(textArea)28 .pressKey('delete')29 .typeText(textArea, 'John Smith')30 .selectText(textArea, 5, 11)31 .expect(getSelectedText()).eql('Smith');32});33const getSelectedText = ClientFunction(() => {34 const selection = window.getSelection();35 return selection.toString();36});37const textArea = Selector('#developer-name');38test('Get selected text', async t => {39 .selectText(textArea)40 .pressKey('delete')41 .typeText(textArea, 'John Smith')42 .selectText(textArea, 5, 11)43 .expect(getSelectedText()).eql('Smith');44});45const getSelectedText = ClientFunction(() => {46 const selection = window.getSelection();47 return selection.toString();48});49const textArea = Selector('#developer-name');50test('Get selected text', async t => {51 .selectText(textArea)52 .pressKey('delete')53 .typeText(textArea, 'John Smith')

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('My Test', async t => {3 .click('#tried-test-cafe')4 .expect(Selector('#tried-test-cafe').checked).ok()5 .click('#macos')6 .expect(Selector('#macos').checked).ok()7 .click('#submit-button');8});9driver.findElement(By.id("tried-test-cafe")).click();10driver.findElement(By.id("macos")).click();11driver.findElement(By.id("submit-button")).click();

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('My Test', async t => {3 .typeText('#developer-name', 'John Smith')4 .click('#macos')5 .click('#submit-button')6 .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');7});8const puppeteer = require('puppeteer');9(async () => {10 const browser = await puppeteer.launch();11 const page = await browser.newPage();12 await page.type('#developer-name', 'John Smith');13 await page.click('#macos');14 await page.click('#submit-button');15 await page.waitForSelector('#article-header');16 const headerText = await page.$eval('#article-header', el => el.textContent);17 await browser.close();18})();19from selenium import webdriver20from selenium.webdriver.common.keys import Keys21driver = webdriver.Firefox()22elem = driver.find_element_by_id("developer-name")23elem.send_keys("John Smith")24elem = driver.find_element_by_id("macos")25elem.click()26elem = driver.find_element_by_id("submit-button")27elem.click()28elem = driver.find_element_by_id("article-header")29print(elem.text)30const { webkit } = require('playwright');31(async () => {32 const browser = await webkit.launch();33 const context = await browser.newContext();34 const page = await context.newPage();35 await page.type('#developer-name', 'John Smith');36 await page.click('#macos');37 await page.click('#submit-button');38 await page.waitForSelector('#article-header');39 const headerText = await page.$eval('#article-header', el => el.textContent);40 await browser.close();41})();42describe('My First Test', function() {43 it('Does not do much!', function() {44 cy.get('#

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('My first test', async t => {3 const table = Selector('table')4 const tableRow = table.find('tr').nth(4)5 const tableColumn = tableRow.find('td').nth(2)6 .click(tableColumn)7});8const { Builder, By, Key, until } = require('selenium-webdriver');9const driver = new Builder()10 .forBrowser('chrome')11 .build();12driver.findElement(By.css('table')).then((table) => {13 table.findElement(By.css('tr:nth-child(4)')).then((tableRow) => {14 tableRow.findElement(By.css('td:nth-child(2)')).then((tableColumn) => {15 tableColumn.getText().then((text) => {16 tableColumn.click()17 }18 })19 })20 })21})

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('My first test', async t => {3 const quill = Selector('.ql-editor');4 const quillContent = Selector('.ql-editor').textContent;5 const quillSelection = Selector('.ql-editor').getSelection();6 const quillSelectionText = Selector('.ql-editor').getSelectionText();7 const quillSelectionStart = Selector('.ql-editor').getSelectionStart();8 const quillSelectionEnd = Selector(

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Testcafe automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful