How to use formatValue method in Cypress

Best JavaScript code snippet using cypress

EnumSyncConfigModal.js

Source:EnumSyncConfigModal.js Github

copy

Full Screen

1/**2 * @description3 * @Version Created by Stephen on 2019/8/22.4 * @Author Stephen5 * @license dongfangdianzi6 */78/**9 *10 * {11 * "dataSourceName": {12 "mapTo": "dataSourceName", //映射到后台需要的参数13 "formatValue": "form.syncConfigDataOriginModal.dataSourceName.label", //统一的用枚举的label名字14 "value": "dataSourceName", //本身的value值,用来映射到详情15 },16 * }17 */18//枚举数据任务-数据同步-新建数据源信息19export const EnumModalFormContent = {20 //数据源21 dataOrigin: {22 //ftp-csv输入23 'cn.gov.ytga.kafka.connect.file.FtpCsvSourceConnector': {24 dataSourceName: {25 mapTo: 'dataSourceName',26 formatValue: 'form.syncConfigDataOriginModal.dataSourceName.label',27 value: 'dataSourceName',28 },29 databaseInfoId:{30 mapTo: 'databaseInfoId',31 formatValue: 'form.syncConfigDataOriginModal.databaseName.label',32 value: 'databaseInfoId',33 },34 serverAddress: {35 mapTo: 'ftp.server',36 formatValue: 'form.syncConfigDataOriginModal.serverAddress.label',37 value: 'serverAddress',38 },39 port: {40 mapTo: 'ftp.port',41 formatValue: 'form.syncConfigDataOriginModal.port.label',42 value: 'port',43 },44 username: {45 mapTo: 'ftp.username',46 formatValue: 'form.syncConfigDataOriginModal.username.label',47 value: 'username',48 },49 password: {50 mapTo: 'ftp.password',51 formatValue: 'form.syncConfigDataOriginModal.password.label',52 value: 'password',53 },54 catalogue: {55 mapTo: 'ftp.dir',56 formatValue: 'form.syncConfigDataOriginModal.ftp.catalogue.label',57 value: 'catalogue',58 },59 filename: {60 mapTo: 'ftp.filename.regex',61 formatValue: 'form.syncConfigDataOriginModal.ftp.filename.label',62 value: 'filename',63 },64 csv: {65 mapTo: 'csv.format',66 formatValue: 'form.syncConfigDataOriginModal.ftp.csv.label',67 value: 'csv',68 },69 filed: {70 mapTo: 'csv.first.header.line',71 formatValue: 'form.syncConfigDataOriginModal.ftp.filed.label',72 value: 'filed',73 },74 header: {75 mapTo: 'csv.header.line',76 formatValue: 'form.syncConfigDataOriginModal.ftp.header.label',77 value: 'header',78 },79 coding: {80 mapTo: 'file.encode',81 formatValue: 'form.syncConfigDataOriginModal.ftp.coding.label',82 value: 'coding',83 },84 },85 //ftp-xml输入86 'cn.gov.ytga.kafka.connect.xmlmanager.XmlSourceConnector': {87 dataSourceName: {88 mapTo: 'dataSourceName',89 formatValue: 'form.syncConfigDataOriginModal.dataSourceName.label',90 value: 'dataSourceName',91 },92 databaseInfoId:{93 mapTo: 'databaseInfoId',94 formatValue: 'form.syncConfigDataOriginModal.databaseName.label',95 value: 'databaseInfoId',96 },97 serverAddress: {98 mapTo: 'ftp.server',99 formatValue: 'form.syncConfigDataOriginModal.serverAddress.label',100 value: 'serverAddress',101 },102 port: {103 mapTo: 'ftp.port',104 formatValue: 'form.syncConfigDataOriginModal.port.label',105 value: 'port',106 },107 username: {108 mapTo: 'ftp.username',109 formatValue: 'form.syncConfigDataOriginModal.username.label',110 value: 'username',111 },112 password: {113 mapTo: 'ftp.password',114 formatValue: 'form.syncConfigDataOriginModal.password.label',115 value: 'password',116 },117 catalogue: {118 mapTo: 'ftp.dir',119 formatValue: 'form.syncConfigDataOriginModal.ftp.catalogue.label',120 value: 'catalogue',121 },122 type: {123 mapTo: 'xml.type',124 formatValue: 'form.syncConfigDataOriginModal.ftp.xml.type.label',125 value: 'type',126 },127 code: {128 mapTo: 'xml.code',129 formatValue: 'form.syncConfigDataOriginModal.ftp.xml.code.label',130 value: 'code',131 },132 schema: {133 mapTo: 'xml.schema',134 formatValue: 'form.syncConfigDataOriginModal.ftp.xml.schema.label',135 value: 'schema',136 },137 tag: {138 mapTo: 'xml.tag',139 formatValue: 'form.syncConfigDataOriginModal.ftp.xml.tag.label',140 value: 'tag',141 },142 },143 //ftp输入144 ftpFileSourceConnector: {145 dataSourceName: {146 mapTo: 'dataSourceName',147 formatValue: 'form.syncConfigDataOriginModal.dataSourceName.label',148 value: 'dataSourceName',149 },150 serverAddress: {151 mapTo: 'ftp.server',152 formatValue: 'form.syncConfigDataOriginModal.serverAddress.label',153 value: 'serverAddress',154 },155 port: {156 mapTo: 'ftp.port',157 formatValue: 'form.syncConfigDataOriginModal.port.label',158 value: 'port',159 },160 username: {161 mapTo: 'ftp.username',162 formatValue: 'form.syncConfigDataOriginModal.username.label',163 value: 'username',164 },165 password: {166 mapTo: 'ftp.password',167 formatValue: 'form.syncConfigDataOriginModal.password.label',168 value: 'password',169 },170 catalogue: {171 mapTo: 'ftp.dir',172 formatValue: 'form.syncConfigDataOriginModal.ftp.catalogue.label',173 value: 'catalogue',174 },175 filename: {176 mapTo: 'ftp.filename.regex',177 formatValue: 'form.syncConfigDataOriginModal.ftp.filename.label',178 value: 'filename',179 },180 coding: {181 mapTo: 'file.encode',182 formatValue: 'form.syncConfigDataOriginModal.ftp.coding.label',183 value: 'coding',184 },185 },186 //rabbitmq输入187 'com.github.jcustenborder.kafka.connect.rabbitmq.RabbitMQSourceConnector': {188 dataSourceName: {189 mapTo: 'dataSourceName',190 formatValue: 'form.syncConfigDataOriginModal.dataSourceName.label',191 value: 'dataSourceName',192 },193 databaseInfoId:{194 mapTo: 'databaseInfoId',195 formatValue: 'form.syncConfigDataOriginModal.databaseName.label',196 value: 'databaseInfoId',197 },198 serverAddress: {199 mapTo: 'rabbitmq.host',200 formatValue: 'form.syncConfigDataOriginModal.serverAddress.label',201 value: 'serverAddress',202 },203 port: {204 mapTo: 'rabbitmq.port',205 formatValue: 'form.syncConfigDataOriginModal.port.label',206 value: 'port',207 },208 username: {209 mapTo: 'rabbitmq.username',210 formatValue: 'form.syncConfigDataOriginModal.username.label',211 value: 'username',212 },213 password: {214 mapTo: 'rabbitmq.password',215 formatValue: 'form.syncConfigDataOriginModal.password.label',216 value: 'password',217 },218 queue: {219 mapTo: 'rabbitmq.queue',220 formatValue: 'form.syncConfigDataOriginModal.rabbitmq.queue.label',221 value: 'queue',222 },223 vhost: {224 mapTo: 'rabbitmq.virtual.host',225 formatValue: 'form.syncConfigDataOriginModal.vhost.label',226 value: 'vhost',227 },228 },229 //jdbc输入230 'cn.gov.ytga.kafka.connect.jdbc.JdbcSourceConnector': {231 dataSourceName: {232 mapTo: 'dataSourceName',233 formatValue: 'form.syncConfigDataOriginModal.dataSourceName.label',234 value: 'dataSourceName',235 },236 databaseInfoId:{237 mapTo: 'databaseInfoId',238 formatValue: 'form.syncConfigDataOriginModal.databaseName.label',239 value: 'databaseInfoId',240 },241 connectionUrl: {242 mapTo: 'connection.url',243 formatValue: 'form.syncConfigDataOriginModal.jdbc.url.label',244 value: 'connectionUrl',245 },246 mode: {247 mapTo: 'mode',248 formatValue: 'form.syncConfigDataOriginModal.jdbc.mode.label',249 value: 'mode',250 },251 /*bulk: {252 mapTo: 'bulk.column.name',253 formatValue: 'form.syncConfigDataOriginModal.jdbc.mode.option.bulk.label',254 value: 'bulk',255 },*/256 poll: {257 mapTo: 'poll.interval.ms',258 formatValue: 'form.syncConfigDataOriginModal.jdbc.mode.option.bulk.label',259 value: 'bulk',260 },261 incrementing: {262 mapTo: 'incrementing.column.name',263 formatValue: 'form.syncConfigDataOriginModal.jdbc.mode.option.incrementing.label',264 value: 'incrementing',265 },266 timestamp: {267 mapTo: 'timestamp.column.name',268 formatValue: 'form.syncConfigDataOriginModal.jdbc.mode.option.timestamp.label',269 value: 'timestamp',270 },271 /*"timestamp+incrementing": {272 "mapTo": "timestamp+incrementing.column.name",273 "formatValue": "form.syncConfigDataOriginModal.jdbc.mode.option.timestampIncrementing.label",274 "value": "timestamp+incrementing",275 },*/276 whitelist: {277 mapTo: 'table.whitelist',278 formatValue: 'form.syncConfigDataOriginModal.jdbc.tableList.option.whitelist.label',279 value: 'whitelist',280 },281 /*blacklist: {282 mapTo: 'table.blacklist',283 formatValue: 'form.syncConfigDataOriginModal.jdbc.tableList.option.blacklist.label',284 value: 'blacklist',285 },*/286 /*table: {287 mapTo: 'table.tablelist',288 formatValue: 'form.syncConfigDataOriginModal.jdbc.tableList.label',289 value: 'table',290 },*/291 /*topicPrefix: {292 mapTo: 'topic.prefix',293 formatValue: 'form.syncConfigDataOriginModal.jdbc.prefix.label',294 value: 'topicPrefix',295 },*/296 /*query: {297 mapTo: 'query',298 formatValue: 'form.syncConfigDataOriginModal.jdbc.query.label',299 value: 'query',300 },*/301 types: {302 mapTo: 'table.types',303 formatValue: 'form.syncConfigDataOriginModal.jdbc.types.label',304 value: 'types',305 },306 },307 //kafka输入308 'cn.gov.ytga.kafka.connect.replicate.KafkaSourceConnector': {309 dataSourceName: {310 mapTo: 'dataSourceName',311 formatValue: 'form.syncConfigDataOriginModal.dataSourceName.label',312 value: 'dataSourceName',313 },314 databaseInfoId:{315 mapTo: 'databaseInfoId',316 formatValue: 'form.syncConfigDataOriginModal.databaseName.label',317 value: 'databaseInfoId',318 },319 topic: {320 mapTo: 'kafka.topic',321 formatValue: 'form.syncConfigDataOriginModal.kafka.topic.label',322 value: 'topic',323 },324 /*serverAddress: {325 mapTo: 'kafka.server',326 formatValue: 'form.syncConfigDataOriginModal.serverAddress.label',327 value: 'serverAddress',328 },329 register: {330 mapTo: 'kafka.schema.registry',331 formatValue: 'form.syncConfigDataOriginModal.kafka.register.label',332 value: 'register',333 },*/334 dataFormat: {335 mapTo: 'kafka.data.format.config',336 formatValue: 'form.syncConfigDataOriginModal.kafka.dataFormat.label',337 value: 'dataFormat',338 },339 isBeginning: {340 mapTo: 'kafka.from.beginning',341 formatValue: 'form.syncConfigDataOriginModal.kafka.isBeginning.label',342 value: 'isBeginning',343 },344 schema: {345 mapTo: 'kafka.schema',346 formatValue: 'form.syncConfigDataOriginModal.kafka.schema.label',347 value: 'schema',348 },349 },350 //kafka输入-可能会过期351 'io.confluent.connect.replicator.ReplicatorSourceConnector': {352 dataSourceName: {353 mapTo: 'dataSourceName',354 formatValue: 'form.syncConfigDataOriginModal.dataSourceName.label',355 value: 'dataSourceName',356 },357 sourceAddress: {358 mapTo: 'src.kafka.bootstrap.servers',359 formatValue: 'form.syncConfigDataOriginModal.kafka.sourceAddress.label',360 value: 'sourceAddress',361 },362 sinkAddress: {363 mapTo: 'dest.kafka.bootstrap.servers',364 formatValue: 'form.syncConfigDataOriginModal.kafka.sinkAddress.label',365 value: 'sinkAddress',366 },367 copyTopic: {368 mapTo: 'topic.whitelist',369 formatValue: 'form.syncConfigDataOriginModal.kafka.copyTopic.label',370 value: 'copyTopic',371 },372 },373 //MySQL输入374 'io.debezium.connector.mysql.MySqlConnector': {375 dataSourceName: {376 mapTo: 'dataSourceName',377 formatValue: 'form.syncConfigDataOriginModal.dataSourceName.label',378 value: 'dataSourceName',379 },380 server: {381 mapTo: 'database.hostname',382 formatValue: 'form.syncConfigDataOriginModal.serverAddress.label',383 value: 'server',384 },385 port: {386 mapTo: 'database.port',387 formatValue: 'form.syncConfigDataOriginModal.port.label',388 value: 'port',389 },390 username: {391 mapTo: 'database.user',392 formatValue: 'form.syncConfigDataOriginModal.username.label',393 value: 'username',394 },395 password: {396 mapTo: 'database.password',397 formatValue: 'form.syncConfigDataOriginModal.password.label',398 value: 'password',399 },400 serverId: {401 mapTo: 'database.server.id',402 formatValue: 'form.syncConfigDataOriginModal.mysql.serverId.label',403 value: 'serverId',404 },405 serverName: {406 mapTo: 'database.server.name',407 formatValue: 'form.syncConfigDataOriginModal.mysql.serverName.label',408 value: 'serverName',409 },410 whiteList: {411 mapTo: 'database.whitelist',412 formatValue: 'form.syncConfigDataOriginModal.mysql.whiteList.label',413 value: 'whiteList',414 },415 },416 },417 //数据目的地418 dataDestination: {419 //ftp-csv输出420 'cn.gov.ytga.kafka.connect.file.FtpCsvSinkConnector': {421 dataSourceName: {422 mapTo: 'dataSourceName',423 formatValue: 'form.syncConfigDataOriginModal.dataSourceName.label',424 value: 'dataSourceName',425 },426 databaseInfoId:{427 mapTo: 'databaseInfoId',428 formatValue: 'form.syncConfigDataOriginModal.databaseName.label',429 value: 'databaseInfoId',430 },431 serverAddress: {432 mapTo: 'ftp.server',433 formatValue: 'form.syncConfigDataOriginModal.serverAddress.label',434 value: 'serverAddress',435 },436 port: {437 mapTo: 'ftp.port',438 formatValue: 'form.syncConfigDataOriginModal.port.label',439 value: 'port',440 },441 username: {442 mapTo: 'ftp.username',443 formatValue: 'form.syncConfigDataOriginModal.username.label',444 value: 'username',445 },446 password: {447 mapTo: 'ftp.password',448 formatValue: 'form.syncConfigDataOriginModal.password.label',449 value: 'password',450 },451 catalogue: {452 mapTo: 'ftp.dir',453 formatValue: 'form.syncConfigDataOriginModal.ftp.catalogue.label',454 value: 'catalogue',455 },456 csv: {457 mapTo: 'csv.format',458 formatValue: 'form.syncConfigDataOriginModal.ftp.csv.label',459 value: 'csv',460 },461 coding: {462 mapTo: 'file.encode',463 formatValue: 'form.syncConfigDataOriginModal.ftp.coding.label',464 value: 'coding',465 },466 },467 //ftp输出468 ftpFileSinkConnector: {469 dataSourceName: {470 mapTo: 'dataSourceName',471 formatValue: 'form.syncConfigDataOriginModal.dataSourceName.label',472 value: 'dataSourceName',473 },474 serverAddress: {475 mapTo: 'ftp.server',476 formatValue: 'form.syncConfigDataOriginModal.serverAddress.label',477 value: 'serverAddress',478 },479 port: {480 mapTo: 'ftp.port',481 formatValue: 'form.syncConfigDataOriginModal.port.label',482 value: 'port',483 },484 username: {485 mapTo: 'ftp.username',486 formatValue: 'form.syncConfigDataOriginModal.username.label',487 value: 'username',488 },489 password: {490 mapTo: 'ftp.password',491 formatValue: 'form.syncConfigDataOriginModal.password.label',492 value: 'password',493 },494 catalogue: {495 mapTo: 'ftp.dir',496 formatValue: 'form.syncConfigDataOriginModal.ftp.catalogue.label',497 value: 'catalogue',498 },499 },500 //rabbitmq输出501 'com.github.jcustenborder.kafka.connect.rabbitmq.RabbitMQSinkConnector': {502 dataSourceName: {503 mapTo: 'dataSourceName',504 formatValue: 'form.syncConfigDataOriginModal.dataSinkName.label',505 value: 'dataSourceName',506 },507 databaseInfoId:{508 mapTo: 'databaseInfoId',509 formatValue: 'form.syncConfigDataOriginModal.databaseName.label',510 value: 'databaseInfoId',511 },512 serverAddress: {513 mapTo: 'rabbitmq.host',514 formatValue: 'form.syncConfigDataOriginModal.serverAddress.label',515 value: 'serverAddress',516 },517 port: {518 mapTo: 'rabbitmq.port',519 formatValue: 'form.syncConfigDataOriginModal.port.label',520 value: 'port',521 },522 username: {523 mapTo: 'rabbitmq.username',524 formatValue: 'form.syncConfigDataOriginModal.username.label',525 value: 'username',526 },527 password: {528 mapTo: 'rabbitmq.password',529 formatValue: 'form.syncConfigDataOriginModal.password.label',530 value: 'password',531 },532 vhost: {533 mapTo: 'rabbitmq.virtual.host',534 formatValue: 'form.syncConfigDataOriginModal.vhost.label',535 value: 'vhost',536 },537 routing: {538 mapTo: 'rabbitmq.routing.key',539 formatValue: 'form.syncConfigDataOriginModal.rabbitmq.routing.label',540 value: 'routing',541 },542 exchange: {543 mapTo: 'rabbitmq.exchange',544 formatValue: 'form.syncConfigDataOriginModal.rabbitmq.exchange.label',545 value: 'exchange',546 },547 },548 //jdbc输出549 'cn.gov.ytga.kafka.connect.jdbc.JdbcSinkConnector': {550 dataSourceName: {551 mapTo: 'dataSourceName',552 formatValue: 'form.syncConfigDataOriginModal.dataSinkName.label',553 value: 'dataSourceName',554 },555 /*connectionUrl: {556 mapTo: 'connection.url',557 formatValue: 'form.syncConfigDataOriginModal.jdbc.url.label',558 value: 'connectionUrl',559 },*/560 databaseInfoId: {561 mapTo: 'databaseInfoId',562 formatValue: 'form.syncConfigDataOriginModal.jdbc.url.label',563 value: 'databaseInfoId',564 },565 insert: {566 mapTo: 'insert.mode',567 formatValue: 'form.syncConfigDataOriginModal.jdbc.insertMode.label',568 value: 'insert',569 },570 pkMode: {571 mapTo: 'pk.mode',572 formatValue: 'form.syncConfigDataOriginModal.jdbc.pkMode.label',573 value: 'pkMode',574 },575 noneFields: {576 mapTo: 'noneFields',577 formatValue: 'form.syncConfigDataOriginModal.jdbc.pkMode.fields.none.label',578 value: 'noneFields',579 },580 fields: {581 mapTo: 'pk.fields',582 formatValue: 'form.syncConfigDataOriginModal.jdbc.pkMode.fields.record_value.label',583 value: 'fields',584 },585 format: {586 mapTo: 'table.name.format',587 formatValue: 'form.syncConfigDataOriginModal.jdbc.format.label',588 value: 'format',589 },590 },591 //kafka输出592 'cn.gov.ytga.kafka.connect.replicate.KafkaSinkConnector': {593 dataSourceName: {594 mapTo: 'dataSourceName',595 formatValue: 'form.syncConfigDataOriginModal.dataSourceName.label',596 value: 'dataSourceName',597 },598 serverAddress: {599 mapTo: 'kafka.server',600 formatValue: 'form.syncConfigDataOriginModal.serverAddress.label',601 value: 'serverAddress',602 },603 topic: {604 mapTo: 'kafka.topic',605 formatValue: 'form.syncConfigDataOriginModal.kafka.topic.label',606 value: 'topic',607 },608 },609 },610};611612//枚举数据任务-数据同步-新建数据源和目的地后台需要的不同的参数613export const EnumCreateProcessorSpecialParam = {614 //数据源615 dataOrigin: {616 //ftp-csv输入617 'cn.gov.ytga.kafka.connect.file.FtpCsvSourceConnector': {618 key: 'topic',619 },620 //ftp-xml输入621 'cn.gov.ytga.kafka.connect.xmlmanager.XmlSourceConnector':{622 key: 'topic',623 },624 //ftp输入625 ftpFileSourceConnector: {626 key: 'topic',627 },628 //rabbitmq输入629 'com.github.jcustenborder.kafka.connect.rabbitmq.RabbitMQSourceConnector': {630 key: 'kafka.topic',631 },632 //jdbc输入633 'cn.gov.ytga.kafka.connect.jdbc.JdbcSourceConnector': {634 key: 'topic',635 },636 //kafka输入637 'cn.gov.ytga.kafka.connect.replicate.KafkaSourceConnector': {638 key: 'topic',639 },640 //kafka输入-可能会过期641 'io.confluent.connect.replicator.ReplicatorSourceConnector': {642 key: 'topic',643 },644 //debezium-mysql输入645 'io.debezium.connector.mysql.MySqlConnector': {646 key: 'database.history.kafka.topic',647 },648 },649 //数据目的地650 dataDestination: {651 //ftp-csv输出652 'cn.gov.ytga.kafka.connect.file.FtpCsvSinkConnector': {653 key: 'topics',654 },655 //ftp输出656 ftpFileSinkConnector: {657 key: 'topics',658 },659 //rabbitmq输出660 'com.github.jcustenborder.kafka.connect.rabbitmq.RabbitMQSinkConnector': {661 key: 'topics',662 },663 //jdbc输出664 'cn.gov.ytga.kafka.connect.jdbc.JdbcSinkConnector': {665 key: 'topics',666 },667 //kafka输出668 'cn.gov.ytga.kafka.connect.replicate.KafkaSinkConnector': {669 key: 'topic',670 },671 },672};673674//有些参数是固定写死加上的,但是后端也会返回,前端不需要显示,所以需要按照种类去掉675export const EnumProcessorNoShowParams = {676 //rabbitmq输入677 'com.github.jcustenborder.kafka.connect.rabbitmq.RabbitMQSourceConnector': ['tasks.max'],678 //rabbitmq 输出679 'com.github.jcustenborder.kafka.connect.rabbitmq.RabbitMQSinkConnector': [680 'key.converter.schemas.enable',681 'value.converter.schemas.enable',682 'value.converter',683 'key.converter',684 ],685 //debezium-mysql 输入686 'io.debezium.connector.mysql.MySqlConnector': [687 'tasks.max',688 'database.history.kafka.bootstrap.servers',689 ],690 //jdbc 输出691 'cn.gov.ytga.kafka.connect.jdbc.JdbcSinkConnector': [692 'tasks.max',693 'key.converter.schemas.enable',694 'value.converter.schemas.enable',695 'value.converter',696 'key.converter',697 ],698 //jdbc 输入699 'cn.gov.ytga.kafka.connect.jdbc.JdbcSourceConnector': [700 'tasks.max',701 'key.converter.schemas.enable',702 'value.converter.schemas.enable',703 'value.converter',704 'key.converter',705 'topic.prefix',706 'table.tablelist',707 ],708 //kafka输入709 'cn.gov.ytga.kafka.connect.replicate.KafkaSourceConnector': [710 'key.converter.schemas.enable',711 'value.converter',712 'tasks.max',713 'key.converter',714 'header.converter',715 'value.converter.schemas.enable',716 'databaseName',717 'kafka.server',718 'kafka.schema.registry',719720 ],721 //ftp-xml输入722 'cn.gov.ytga.kafka.connect.xmlmanager.XmlSourceConnector': [723 'tasks.max',724 'ftp.filename.regex'725 ],726};727728//快速注册 - 队列or文件,枚举数据任务向后端传递729export const EnumQuickRegisterParams = {730 'ftp': {731 serverAddress: {732 mapTo: 'ftp.server',733 value: 'serverAddress',734 },735 port: {736 mapTo: 'ftp.port',737 value: 'port',738 },739 username: {740 mapTo: 'ftp.username',741 value: 'username',742 },743 password: {744 mapTo: 'ftp.password',745 value: 'password',746 },747 remarks:{748 mapTo: 'remarks',749 value: 'remarks',750 }751 },752 'kafka': {753 serverAddress: {754 mapTo: 'kafka.server',755 value: 'serverAddress',756 },757 /*registry: {758 mapTo: 'kafka.schema.registry',759 value: 'registry',760 },*/761 remarks:{762 mapTo: 'remarks',763 value: 'remarks',764 }765 },766 'rabbitmq': {767 serverAddress: {768 mapTo: 'rabbitmq.host',769 value: 'serverAddress',770 },771 port: {772 mapTo: 'rabbitmq.port',773 value: 'port',774 },775 username: {776 mapTo: 'rabbitmq.username',777 value: 'username',778 },779 password: {780 mapTo: 'rabbitmq.password',781 value: 'password',782 },783 remarks:{784 mapTo: 'remarks',785 value: 'remarks',786 }787 }, ...

Full Screen

Full Screen

minified-util-text-test.js

Source:minified-util-text-test.js Github

copy

Full Screen

...71 assert(_.isEmpty([]));72 });73 });74 75 describe('formatValue()', function() {76 it('formats numbers', function() {77 assert.equal(_.formatValue("#", 1), "1");78 assert.equal(_.formatValue("0", -1), "-1");79 assert.equal(_.formatValue("#####", 1), "1");80 assert.equal(_.formatValue("00000", 1), "00001");81 assert.equal(_.formatValue("00000", -1), "-00001");82 assert.equal(_.formatValue("?#", 1), "1");83 assert.equal(_.formatValue("?00000", -1), "-00001");84 85 assert.equal(_.formatValue("#.0", 1), "1.0");86 assert.equal(_.formatValue("0.00", 1), "1.00");87 assert.equal(_.formatValue("0.0000", 1), "1.0000");88 assert.equal(_.formatValue("#.#", 1), "1");89 assert.equal(_.formatValue("#.####", 1), "1");90 assert.equal(_.formatValue("#.0000", -1), "-1.0000");91 assert.equal(_.formatValue("0.#", -1), "-1");92 93 assert.equal(_.formatValue("#.0", 287591/1024), "280.9");94 assert.equal(_.formatValue("##.0", 287591/1024), "280.9");95 assert.equal(_.formatValue("###.0", 287591/1024), "280.9");96 assert.equal(_.formatValue("####.0", 287591/1024), "280.9");97 assert.equal(_.formatValue("0.0", 287591/1024), "280.9");98 assert.equal(_.formatValue("00.0", 287591/1024), "280.9");99 assert.equal(_.formatValue("000.0", 287591/1024), "280.9");100 assert.equal(_.formatValue("0000.0", 287591/1024), "0280.9");101 assert.equal(_.formatValue("##.0", -287591/1024), "-280.9");102 assert.equal(_.formatValue("00.0", -287591/1024), "-280.9");103 assert.equal(_.formatValue("####.0", -287591/1024), "-280.9");104 assert.equal(_.formatValue("0000.0", -287591/1024), "-0280.9");105 106 assert.equal(_.formatValue("#0", 2), "2");107 assert.equal(_.formatValue("##00", 4), "04");108 assert.equal(_.formatValue("##00", 40), "40");109 assert.equal(_.formatValue("##00", 402), "402");110 assert.equal(_.formatValue("###0", 1), "1");111 assert.equal(_.formatValue("###0", 12), "12");112 113 assert.equal(_.formatValue("#", 1.5), "2");114 assert.equal(_.formatValue("#.0", 1.5), "1.5");115 assert.equal(_.formatValue("#.00", 1.5), "1.50");116 assert.equal(_.formatValue("#.000", 1.5), "1.500");117 assert.equal(_.formatValue("#.###", 1.5), "1.5");118 119 assert.equal(_.formatValue("#.0", 1.667), "1.7");120 assert.equal(_.formatValue("#.00", 1.667), "1.67");121 assert.equal(_.formatValue("#.000", 1.667), "1.667");122 assert.equal(_.formatValue("#.0000", 1.667), "1.6670");123 assert.equal(_.formatValue("#.#", 1.667), "1.7");124 assert.equal(_.formatValue("#.##", 1.667), "1.67");125 assert.equal(_.formatValue("#.###", 1.667), "1.667");126 assert.equal(_.formatValue("#.####", 1.667), "1.667");127 128 assert.equal(_.formatValue("#,0", 1), "1,0");129 assert.equal(_.formatValue("#,#", 1.667), "1,7");130 assert.equal(_.formatValue("#,0", 1.667), "1,7");131 132 assert.equal(_.formatValue("00.0000", 1.667), "01.6670");133 assert.equal(_.formatValue("0.#", 10.667), "10.7");134 assert.equal(_.formatValue("000000000,00", 1.667), "000000001,67");135 assert.equal(_.formatValue("000000000.##", 777.667), "000000777.67");136 137 assert.equal(_.formatValue("#.###.###.###", 9999999999), "9.999.999.999");138 assert.equal(_.formatValue("#.###.###.###", 999999999), "999.999.999");139 assert.equal(_.formatValue("0.000.000.000", 999999999), "0.999.999.999");140 assert.equal(_.formatValue("#########,###.##", 9999999999), "9999999,999");141 assert.equal(_.formatValue("####### ## ###.##", 9999999999.129), "99999 99 999.13");142 assert.equal(_.formatValue("#########,###.00", 9999999999), "9999999,999.00");143 assert.equal(_.formatValue("0,000,000,000.##", 9999999999), "9,999,999,999");144 assert.equal(_.formatValue("0,000,000,000.00", 9999999999), "9,999,999,999.00");145 assert.equal(_.formatValue("000,000,000.##", 123456.256), "000,123,456.26");146 assert.equal(_.formatValue("000 000 000.00", 123456.256), "000 123 456.26");147 assert.equal(_.formatValue("000-000-000.00", 123456.256), "000-123-456.26");148 assert.equal(_.formatValue("###,###,###.00", 123456.256), "123,456.26");149 assert.equal(_.formatValue("###, xud ##x5#, #f5##.00", 1234.256), "1, 2f534.26");150 assert.equal(_.formatValue("#.###.###.###", 9), "9");151 assert.equal(_.formatValue("#.###.###.###", 99), "99");152 assert.equal(_.formatValue("#.###.###.###", 999), "999");153 assert.equal(_.formatValue("#.###.###.###", 9999), "9.999");154 assert.equal(_.formatValue("#.###.###.###", 99999), "99.999");155 assert.equal(_.formatValue("#.###.###.###", 999999), "999.999");156 assert.equal(_.formatValue("#.###.###.###", 9999999), "9.999.999");157 assert.equal(_.formatValue("#.###.#00.000", 9), "00.009");158 assert.equal(_.formatValue("#.###.#00.000", 99), "00.099");159 assert.equal(_.formatValue("#.###.#00.000", 999), "00.999");160 assert.equal(_.formatValue("#.###.#00.000", 9999), "09.999");161 assert.equal(_.formatValue("#.###.#00.000", 99999), "99.999");162 assert.equal(_.formatValue("#.###.#00.000", 999999), "999.999");163 assert.equal(_.formatValue("#.###.#00.000", 9999999), "9.999.999");164 assert.equal(_.formatValue("#,###.###,###", 1234.567890), "1,234.567,89");165 166 assert.equal(_.formatValue("ABC#####DEF", 1), "ABC1DEF");167 assert.equal(_.formatValue("?ABC#####DEF", 1), "ABC1DEF");168 assert.equal(_.formatValue("$#.00", 1), "$1.00");169 assert.equal(_.formatValue("$#.00", -1), "$-1.00");170 assert.equal(_.formatValue("$0.00", -1), "$-1.00");171 assert.equal(_.formatValue("$#.00", -10), "$-10.00");172 assert.equal(_.formatValue("$0.00", -10), "$-10.00");173 assert.equal(_.formatValue("bla=0.000 bla", 1.5), "bla=1.500 bla");174 assert.equal(_.formatValue("#.## EUR", 1.667), "1.67 EUR");175 assert.equal(_.formatValue("c 0,000,000,000.00 e", 9999999999), "c 9,999,999,999.00 e");176 });177 178 it('supports string choices', function() {179 assert.equal(_.formatValue("a:0|b:1|c:2|d:3|4", "c"), "2");180 assert.equal(_.formatValue("a:0|b:1|c:2|d:3|4", "a"), "0");181 assert.equal(_.formatValue("a:0|b:1|c:2|d:3|4", "e"), "4");182 assert.equal(_.formatValue("?a:0|b:1|c:2|d:3|4", "e"), "4");183 assert.equal(_.formatValue("a: 0 | b: 1 | c: 2| d: 3| 4", "c"), "2");184 assert.equal(_.formatValue("a: 0 | b: 1 | c: 2| d: 3| 4", "a"), "0");185 assert.equal(_.formatValue("a: 0 | b: 1 | c: 2| d: 3| 4", "e"), "4");186 assert.equal(_.formatValue("true:xx| false:yyy", true), "xx");187 assert.equal(_.formatValue("true:xx| false:yyy", false), "yyy");188 assert.equal(_.formatValue("true:xx| yyy", false), "yyy");189 assert.equal(_.formatValue("abc:cba|def:fed|ghi", "abc"), "cba");190 assert.equal(_.formatValue("abc:cba|def:fed|ghi", null), "ghi");191 assert.equal(_.formatValue("abc:cba|def:fed|null:n0ll|ghi", null), "n0ll");192 });193 194 it('supports number choices', function() {195 assert.equal(_.formatValue("<0:neg|0:zero|>0:pos|funny", -0.1), "neg");196 assert.equal(_.formatValue("<0:neg|=0:zero|>0:pos|funny", 0), "zero");197 assert.equal(_.formatValue("<0:neg|0:zero|>0:pos|funny", 0), "zero");198 assert.equal(_.formatValue("<0:neg|0:zero|>0:pos|funny", 0.1), "pos");199 assert.equal(_.formatValue("?<0:neg|0:zero|>0:pos|funny", 0.1), "pos");200 assert.equal(_.formatValue(">0:a|>=0:b|<10:c|<=10:d|e", 1), "a");201 assert.equal(_.formatValue("<13:kid | <=19:teen | >=65:senior | adult", 12), "kid");202 assert.equal(_.formatValue("<13:kid | <=19:teen | >=65:senior | adult", 13), "teen");203 assert.equal(_.formatValue("<13:kid | <=19:teen | >=65:senior | adult", 19), "teen");204 assert.equal(_.formatValue("<13:kid | <=19:teen | >=65:senior | adult", 20), "adult");205 assert.equal(_.formatValue("<13:kid | <=19:teen | >=65:senior | adult", 64), "adult");206 assert.equal(_.formatValue("<13:kid | <=19:teen | >=65:senior | adult", 65), "senior");207 assert.equal(_.formatValue("<13:kid | <=19:teen | >=65:senior | adult", 66), "senior");208 assert.equal(_.formatValue("<10: small #.00 | >100: big 0000.0000 | medium #.#", 1.1), "small 1.10");209 assert.equal(_.formatValue("<10: small #.00 | >100: big 0000.0000 | medium #.#", 54), "medium 54");210 assert.equal(_.formatValue("<10: small #.00 | >100: big 0000.0000 | medium #.#", 217), "big 0217.0000");211 assert.equal(_.formatValue("<10: small #.00 | >100: big 0000.0000 | medium", 50), "medium");212 });213 214 it('formats dates', function() {215 var d = new Date(2011, 11, 6, 13, 30, 10, 501);216 var d2 = new Date(2013, 0, 5, 02, 0, 0, 0);217 assert.equal(_.formatValue("yMd", d), "2011126");218 assert.equal(_.formatValue("yyyyMMdd", d), "20111206");219 assert.equal(_.formatValue("yyyyyyMMMMMddd", d), "00201100012006");220 assert.equal(_.formatValue("?yyyyyyMMMMMddd", d), "00201100012006");221 assert.equal(_.formatValue("yyyyYYMMdd,n,N,m,H,h,k,K,s,S,a,w,W", d), "2011111206,Dec,December,30,13,1,14,1,10,501,pm,Tue,Tuesday");222 assert.equal(_.formatValue("yyyyYYMMdd,n,N,m,H,h,k,K,s,SSS,a,w,W", d2), "2013130105,Jan,January,0,2,2,3,2,0,000,am,Sat,Saturday");223 assert.equal(_.formatValue("n[a,b,c,d,e,f,g,h,i,j,k,l],N[01,02,03,04,05,06,07,08,09,10,11,12]", d), "l,12");224 assert.equal(_.formatValue("w[a,b,c,d,e,f,g],W[01,02,03,04,05,06,07]", d), "c,03");225 var d3 = new Date(2011, 11, 6, 12, 37, 10, 501);226 assert.equal(_.formatValue("hhmmss aa", d3), "123710 pm");227 });228 229 it('formats timezone', function() {230 var d = new Date(2011, 11, 6, 13, 30, 10, 501);231 var zzzz = (d.getTimezoneOffset() > 0 ? '-' : '+') + _.pad(2, Math.abs(Math.floor(d.getTimezoneOffset()/60))) + _.pad(2, Math.floor(Math.abs(d.getTimezoneOffset()%60)));232 assert.equal(_.formatValue("HHmmss z", d), "133010 " + zzzz);233 assert.equal(_.formatValue("HHmmss zzzzz", d), "133010 " + zzzz);234 var d2 = new Date(1362956403000); // Sun, 10 Mar 2013 23:00:03 GMT NO DAYLIGHT SAVING235 assert.equal(_.formatValue("[+0000] yyyy-MM-dd HH:mm:ss zzzzz", d2), "2013-03-10 23:00:03 +0000");236 assert.equal(_.formatValue("[+0001] yyyy-MM-dd HH:mm:ss zzzzz", d2), "2013-03-10 23:01:03 +0001");237 assert.equal(_.formatValue("[+0100] yyyy-MM-dd HH:mm:ss zzzzz", d2), "2013-03-11 00:00:03 +0100");238 assert.equal(_.formatValue("[-1100] yyyy-MM-dd HH:mm:ss zzzzz", d2), "2013-03-10 12:00:03 -1100");239 assert.equal(_.formatValue("?[-1100] yyyy-MM-dd HH:mm:ss zzzzz", d2), "2013-03-10 12:00:03 -1100");240 241 var d3 = new Date(1530973632000); // Sat, 07 Jul 2018 14:27:12 GMT DAYLIGHT SAVING242 assert.equal(_.formatValue("[+0000] yyyy-MM-dd HH:mm:ss zzzzz", d3), "2018-07-07 14:27:12 +0000");243 assert.equal(_.formatValue("[+0001] yyyy-MM-dd HH:mm:ss zzzzz", d3), "2018-07-07 14:28:12 +0001");244 assert.equal(_.formatValue("[+0100] yyyy-MM-dd HH:mm:ss zzzzz", d3), "2018-07-07 15:27:12 +0100");245 assert.equal(_.formatValue("[-1100] yyyy-MM-dd HH:mm:ss zzzzz", d3), "2018-07-07 03:27:12 -1100");246 assert.equal(_.formatValue("?[-1100] yyyy-MM-dd HH:mm:ss zzzzz", d3), "2018-07-07 03:27:12 -1100");247 assert.equal(_.formatValue("yyyy-MM-dd HH:mm:ss zzzzz", cloneWithTimezone(d, 0)), "2011-12-06 13:30:10 +0000");248 assert.equal(_.formatValue("yyyy-MM-dd HH:mm:ss zzzzz", cloneWithTimezone(d, -1)), "2011-12-06 13:30:10 +0001");249 assert.equal(_.formatValue("yyyy-MM-dd HH:mm:ss zzzzz", cloneWithTimezone(d, 1)), "2011-12-06 13:30:10 -0001");250 assert.equal(_.formatValue("yyyy-MM-dd HH:mm:ss zzzzz", cloneWithTimezone(d, -60)), "2011-12-06 13:30:10 +0100");251 assert.equal(_.formatValue("yyyy-MM-dd HH:mm:ss zzzzz", cloneWithTimezone(d, 660)), "2011-12-06 13:30:10 -1100");252 assert.equal(_.formatValue("?yyyy-MM-dd HH:mm:ss zzzzz", cloneWithTimezone(d, 660)), "2011-12-06 13:30:10 -1100");253 });254 });255 256 describe('parseDate()', function() {257 it('parses dates', function() {258 var d0 = new Date(2011, 11, 6);259 var d = new Date(2011, 11, 6, 13, 30, 10, 501);260 var d2 = new Date(2013, 0, 5, 02, 0, 0, 0);261 262 assertDateEqual(_.parseDate("yyyyMMdd", "20111206"), d0);263 assertDateEqual(_.parseDate("yyyy,MM,dd", "2011,12,06"), d0);264 assertDateEqual(_.parseDate("y,M,d", "2011,12,06"), d0);265 assertDateEqual(_.parseDate("y,M,d", "2011,12,6"), d0);266 assertDateEqual(_.parseDate("Y,M,d", "11,12,6"), d0);267 assertDateEqual(_.parseDate("yyyyMMddhhmmssaa", "20130105020000am"), d2);268 assertDateEqual(_.parseDate("y,M,d,h,m,s,a", "2013,1,5,2,0,0,am"), d2);269 assertDateEqual(_.parseDate("Y,M,d,h,m,s,a", "13,1,5,2,0,0,AM"), d2);270 assertDateEqual(_.parseDate("yyyy,d,n,m,H,s,S,w,W", "2011,6,Dec,30,13,10,501,Tue,Tuesday"), d);271 assertDateEqual(_.parseDate("yyyy,d,n,m,h,s,S,a,w,W", "2011,6,Decem,30,1,10,501,pm,Tue,Tuesday"), d);272 assertDateEqual(_.parseDate("yyyy,d,n,m,K,s,S,w,W", "2011,06,Dec,30,14,10,501,Wed,Wednesday"), d); // ignored w/W273 assertDateEqual(_.parseDate("?yyyy,d,N,m,k,s,S,a,w,W", "2011,06,December,30,2,10,501,pm,Tue,Tuesday"), d);274 assertDateEqual(_.parseDate("yyyy+d-N(m)k,s,S,a\\w,W", "2011+06-December(30)2,10,501,pm\\Tue,Tuesday"), d);275 assertDateEqual(_.parseDate("yyyy-N[MoneM,Mtwo,Mthree,Mfour,Mfive,Msix,Mseven,Meight,Mnine,Mten,Meleven,Mtwelve]-dd", "2011-Mtwelve-06"), d0);276 assertDateEqual(_.parseDate("?y,M,d,h,m,s,S,a[AMM,PAM]", "2011,12,6,1,30,10,501,PAM"), d);277 assertDateEqual(_.parseDate("y,M,d,h,m,s,a[AMM,PAM]", "2013,1,5,2,0,0,AMM"), d2);278 assertDateEqual(_.parseDate("yyyy-N[J1M,M2M,M3M,M4M,M5M,M6M,M7M,M8M,M9M,M10M,M11M,D\u00d6c]-dd", "2011-D\u00d6c-06"), d0); // non-ASCII279 assertDateEqual(_.parseDate("yyyynddhhmmssa", "2013Jan05020000AM"), d2); 280 });281 it('handles timezones', function() {282 var dUtc = new Date(1323178210501); //new Date(2011, 11, 6, 13, 30, 10, 501); in UTC283 var d2Utc = new Date(1357351200000); // new Date(2013, 0, 5, 02, 0, 0, 0); in UTC284 var f1 = "[+0000] yyyy-MM-dd HH:mm:ss.SSS";285 assertDateEqual(_.parseDate("[+0000] yyyy-MM-dd HH:mm:ss.SSS", "2011-12-06 13:30:10.501"), dUtc);286 assertDateEqual(_.parseDate("[+0200] yyyy-MM-dd HH:mm:ss.SSS", "2011-12-06 15:30:10.501"), dUtc);287 assertDateEqual(_.parseDate("[+0201] yyyy-MM-dd HH:mm:ss.SSS", "2011-12-06 15:31:10.501"), dUtc);288 assertDateEqual(_.parseDate("[+1200] yyyy-MM-dd HH:mm:ss.SSS", "2011-12-07 01:30:10.501"), dUtc);289 assertDateEqual(_.parseDate("[-0005] yyyy-MM-dd HH:mm:ss.SSS", "2011-12-06 13:25:10.501"), dUtc);290 assertDateEqual(_.parseDate("[-1200] yyyy-MM-dd HH:mm:ss.SSS", "2011-12-06 01:30:10.501"), dUtc);291 assertDateEqual(_.parseDate("[-1400] yyyy-MM-dd HH:mm:ss.SSS", "2011-12-05 23:30:10.501"), dUtc);292 assertDateEqual(_.parseDate(f1, "2013-01-05 02:00:00.000"), d2Utc);293 assertDateEqual(_.parseDate("[-0500] y,M,d,H,m,s,S", "2013,1,5,2,0,0,0"), _.dateAdd(d2Utc, 'minutes', 300));294 assertDateEqual(_.parseDate("[+0501] y,M,d,H,m,s,S", "2013,1,5,2,0,0,0"), _.dateAdd(d2Utc, 'minutes', -301));295 var f2 = "yyyy-MM-dd HH:mm:ss.SSS zz";296 assertDateEqual(_.parseDate(f2, "2011-12-06 13:30:10.501 +0000"), dUtc);297 assertDateEqual(_.parseDate(f2, "2011-12-06 13:30:10.501 +0030"), _.dateAdd(dUtc, 'minutes', -30));298 assertDateEqual(_.parseDate(f2, "2011-12-06 13:30:10.501 +0200"), _.dateAdd(dUtc, 'minutes', -120));299 assertDateEqual(_.parseDate(f2, "2011-12-06 13:30:10.501 +0230"), _.dateAdd(dUtc, 'minutes', -150));300 assertDateEqual(_.parseDate(f2, "2011-12-06 13:30:10.501 +1200"), _.dateAdd(dUtc, 'minutes', -720));301 assertDateEqual(_.parseDate(f2, "2011-12-06 13:30:10.501 -0030"), _.dateAdd(dUtc, 'minutes', 30));302 assertDateEqual(_.parseDate(f2, "2011-12-06 13:30:10.501 -0100"), _.dateAdd(dUtc, 'minutes', 60));303 assertDateEqual(_.parseDate(f2, "2011-12-06 13:30:10.501 -0125"), _.dateAdd(dUtc, 'minutes', 85));304 assert.equal(_.formatValue(f2, _.parseDate(f2, _.formatValue(f2, dUtc))), _.formatValue(f2, dUtc));305 });306 it('does not parse broken strings', function() {307 assert.strictEqual(_.parseDate("yyyy-MM-dd", "2010-a2-02"), undefined);308 assert.strictEqual(_.parseDate("yyyy-MM-dd", "2010.02.02"), undefined);309 assert.strictEqual(_.parseDate("yyyy-MM-dd", "2010-02-"), undefined);310 assert.strictEqual(_.parseDate("yyyy-NN-dd", "2010-Snowctober-07"), undefined);311 assert.strictEqual(_.parseDate("yyyy-NN[Jan,Feb]-dd", "2010-October-07"), undefined);312 });313 it('parses empty strings', function() {314 assert.strictEqual(_.parseDate("?yyyy-MM-dd", ""), null);315 assert.strictEqual(_.parseDate("?__yyyy-MM-dd ()()(", " "), null);316 });317 });318 describe('parseNumber()', function() {...

Full Screen

Full Screen

index.jsx

Source:index.jsx Github

copy

Full Screen

1/**2 * Created by zhiyongwang3 * date:2016-04-05后开始独立改造4 * edit 2021-03-11 修复bug5 * edit 2021-04-12 完善交互性6 * 下拉框7 */8import React, { Component } from 'react';9import PropTypes from "prop-types";10//libs11import func from "../../libs/func.js";12import propsTran from "../../libs/propsTran"13import dom from "../../libs/dom"14//hoc15import loadDataHoc from "../../loadDataHoc";16import validateHoc from "../validateHoc";1718import ArrowInput from "./ArrowInput";19import SelectbleList from "./SelectbleList";20import Msg from "../../Info/Msg"21import "./select.css"22class Select extends Component {23 constructor(props) {24 super(props);25 this.input = React.createRef();26 this.state = {27 sortType: "",//排序方式28 rawData: [],//原数据29 data: [],//数据30 show: false,//是否显示下拉框31 value: "",32 text: "",33 //在可以自由添加的时候,清除输入,不会清除选择项34 inputText: "",//输入框的值默认传下来的文本值35 oldPropsValue: null,//保存初始化的值36 };37 this.showPicker = this.showPicker.bind(this);38 this.hidePicker = this.hidePicker.bind(this);39 this.keyUpHandler = this.keyUpHandler.bind(this);40 this.addHandler = this.addHandler.bind(this);41 this.filter = this.filter.bind(this);42 this.onSelect = this.onSelect.bind(this);43 this.onClear = this.onClear.bind(this);44 this.onSort = this.onSort.bind(this);45 this.onClick = this.onClick.bind(this);46 this.onChange = this.onChange.bind(this);47 }48 static getDerivedStateFromProps(props, state) {49 let newState = {};50 if (props.data && props.data instanceof Array && func.diff(props.data, state.rawData)) {51 /**52 * 因为此组件有追加数据的功能,所以要判断数据变化53 *data就成为了状态值54 */55 newState.rawData = (props.data);56 newState.data = func.clone(props.data)//复制一份57 58 newState.text = propsTran.processText(state.value, newState.data).join(",")||state.text;59 newState.inputText=newState.text||state.inputText;60 61 }62 if (props.value !==state.oldPropsValue) {//父组件强行更新了63 let text = propsTran.processText(props.value, newState.data || state.data);64 65 newState = {66 value: props.value || "",67 oldPropsValue: props.value,68 text: text.join(","),69 inputText: text.join(",")70 }71 }72 return newState;73 }7475 /**76 * 设置值77 * @param {*} value 78 */79 setValue(value) {80 81 let text = propsTran.processText(value, this.state.data);82 this.setState({83 value: value,84 text: text,85 inputText: text.join(","),86 })87 88 }89 /**90 * 获取值91 * @returns 92 */93 getValue() {94 return this.state.value;95 }96 /**97 * 显示下拉框98 * @returns 99 */100 showPicker(event) {101 try{102 103 //显示下拉选项104 if (this.props.readOnly) {105 return;106 }107 this.setState({108 show: true109 });110 document.addEventListener("click", this.hidePicker)111 }112 catch(e){113114 }115 116 117 }118 /**119 * 隐藏下拉框120 * @param {*} event 121 */122 hidePicker(event) {123 if (event.target&&!dom.isDescendant(document.getElementById(this.props.containerid), event.target)) {124 this.setState({125 show: false126 });127 try {128129 document.removeEventListener("click", this.hidePicker);130 this.props.validate(this.state.value);//验证131 //在此处处理失去焦点事件132 this.props.onBlur && this.props.onBlur(this.state.value, this.state.text, this.props.name);133 }134 catch (e) {135136 }137 }138 }139 /**140 * 键盘事件141 * @param {*} event 142 */143 keyUpHandler(event) {144 if (this.props && (this.props.attachAble ) && event.keyCode == 13) {145 ////为了兼容旧属性146 this.addHandler(event);147148 }149 }150 /**151 * 手动输入添加152 * @param {*} event 事件153 * @param {*} isAdd 是否添加154 */155 addHandler(event) {156 let formatValue = this.regValue(event);157 let newValue =this.state.value!==undefined&&this.state.value!==null ? this.state.value.toString().split(",") : [];158 let newText = this.state.text ? this.state.text.toString().split(",") : [];159 ////如果允许添加,则把未匹配的,添加到数据源中160 if (this.props && (this.props.attachAble) && formatValue.length > 0) {161 //允许添加,并且输入有值162 let filterData = this.filter(event);//筛选数据163 /**164 * 注意了165 * 添加时不能把旧的选择删除了166 * 新增选择中的值与文本,167 */168169 let addItems = [];//需要追加的数据项170 for (let i = 0; i < formatValue.length; i++) {171 //先从精确匹配的数据查找172 let findIndex = filterData.absFilter.findIndex(item => item.value == formatValue[i] || item.text == formatValue[i]);173 //精确匹配的肯定不是追加项174 if (findIndex > -1) {175 //已经存在,不追加到数据中,但是要判断选中的值与文本是否都区别,防止用户输入的是值或者文本176 if (newValue.findIndex(item => item == formatValue[i]) > -1) {//存在了177178 }179 else if (newText.findIndex(item => item == formatValue[i]) > -1) {//存在了180181 }182 else {183 //不存在,添加184 newValue.push(formatValue[i]);185 newText.push(formatValue[i]);186 }187 }188 else {189 ////追加新的数据项190 addItems.push({191 value: formatValue[i],192 text: formatValue[i]193 })194 ////追加新的数据项也要插选中的值内195 newValue.push(formatValue[i]);196 newText.push(formatValue[i]);197198 }199200 }201 let data = [].concat(addItems, filterData.absFilter, filterData.dimFilter, filterData.undimFilter);202 //单选的时候,则默认是添加的第一个,或者精确匹配的第一个203 newValue = this.props.multiple ? newValue.join(",") : data[0].value;204 newText = this.props.multiple ? newText.join(",") : data[0].text;205 this.setState({206 value: newValue,207 text: newText,208 data: data//先添加的荐放在最前面,模糊的次之,非模糊居后209 })210211 this.props.onSelect && this.props.onSelect(newValue, newText,212 this.props.name, [{ text: newText, value: newValue }]);213214215 }216217 }218 /**219 * 筛选220 * @param {*} event 221 */222 filter(event) {223 let formatValue = this.regValue(event);224 if (formatValue && formatValue.length > 0) {225 let absFilter = [];//精确筛选226 let dimFilter = [];//模糊筛选227 let undimFilter = [];//没有模糊筛选成功的228229 this.state.data && this.state.data.forEach((item, index) => {230 /**231 * **************注意事项********************232 * 前后加逗号匹配,防止数字匹配失效,233 * 先匹配value值,匹配成功则不再匹配text,防止value与text中含有相似的而导致一个下拉选择匹配两次234 */235 let findIndex = formatValue.findIndex(i => i == item.value || i == item.text);//精确236 let dimFind = false;//是否模糊匹配237 for (let i = 0; i < formatValue.length; i++) {238 //注意了,是从数据集中去模糊匹配输入值239 dimFind = item.value.toString().indexOf(formatValue[i]) > -1 || item.text.toString().indexOf(formatValue[i]) > -1240 }241 if (findIndex > -1) {242 formatValue.splice(findIndex, 1);//移除匹配的243 absFilter.push(item);244 }245 else if (dimFind) {246 dimFilter.push(item);//模糊匹配247 }248 else {249 undimFilter.push(item);//非模糊匹配项250 }251 return false;252253 });254 return {255 absFilter: absFilter,256 dimFilter: dimFilter,257 undimFilter: undimFilter258 }259 }260 else {261 return {262 absFilter: [],263 dimFilter: [],264 undimFilter: this.state.data265 }266 }267 }268 /**269 * 格式化输入270 */271 regValue(event) {272 let formatValue = event.target.value.replace(/[,|]/g, ",");//除去空格,替换汉字逗号,及用|作为分隔符,为英文逗号273 // todo 后期改用正则,再次除去每一个的两端空格,但是不除去文字内部空格274 formatValue = formatValue ? formatValue.split(",").map(item => {275 return item;//再次除去两端空格276 }) : [];277 formatValue = formatValue.filter(item => {278 return item !==null && item !=="";//除去空值的279 });280 return formatValue;281 }282 /***283 * 输入框的单击事件284 */285 onClick(event) {286 this.showPicker(event);287 this.props.onClick && this.props.onClick(event);288 }289 /**290 * 选择事件291 * @param {*} value 值292 * @param {*} text 文本293 * @param {*} row 此行数据294 */295 onSelect(value, text, row) {296 if (value!==undefined&&value!==null) {297 //选中事件298 let newValue = [], newText = [];299 let inputText = [];300 if (this.props.multiple) {//多选301 if (this.state.value!==undefined&&this.state.value!==null) {302 newValue = this.state.value!==undefined&&this.state.value!==null ? this.state.value.toString().split(',') : [];303 newText = this.state.text ? this.state.text.toString().split(',') : [];304 inputText = this.state.inputText ? this.state.inputText.split(",") : [];305 }306 if (newValue.indexOf(value.toString()) > -1) {307 //取消选中308 newValue.splice(newValue.indexOf(value.toString()), 1);309 newText.splice(newText.indexOf(text.toString()), 1);310 let findIndex = inputText.findIndex(item => item == value || item == text);311 if (findIndex > -1) {//输入框可能不含有312 inputText.splice(findIndex, 1);313 }314315 }316 else {//选中317 newValue.push(value);318 newText.push(text);319 inputText.push(text);320 }321 this.setState({322 inputText: inputText.join(","),323 value: newValue.join(","),324 text: newText.join(",")325 }); /**326 * 注意了,这里多了一个inputText值327 */ 328 329 this.props.onSelect && this.props.onSelect(newValue.join(","), newText.join(","), this.props.name, row);330331332 } else {333 newValue = value;334 newText = text;335 inputText=text;336 this.setState({337 show: false,338 value: newValue,339 text: newText,340 inputText: newText341 });342 this.props.onSelect && this.props.onSelect(newValue, newText, this.props.name, row);343 }344345346 }347 else {348 Msg.alert("值是空值");349 }350351 }352 /**353 * onchage 事件354 * @param {*} event 355 */356 onChange(event) {357 let filterData = this.filter(event);//筛选数据358 this.setState({359 show: true,360 inputText: event.target.value,361 data: [].concat(filterData.absFilter, filterData.dimFilter, filterData.undimFilter),362 })363 this.props.onChange && this.props.onChange(event.target.value, event.target.value, this.props.name, event);364 }365 /**366 * 全部清除367 */368 onClear(event) {369 event.stopPropagation();//防止冒泡370 this.setState({371 inputText: "",372 value: "",373 text: "",374 show: true,375 })376 this.showPicker();377 this.props.onSelect && this.props.onSelect("", "", this.props.name);378379 }380 /**381 * 移除某个节点382 */383 onRemove(index) {384 let data = this.state.data;385 data.splice(index, 1);386 this.setState({387 data: data388 })389 }390 /**391 * 排序392 */393 onSort() {394 let data = this.state.data;395 let sortType = this.state.sortType;396 if (data && data.length > 0) {397 data.sort((second, first) => {398 let secondProp = second[this.props.valueField] || second.value;399 let firstProp = first[this.props.valueField] || first.value;400 if (secondProp > firstProp) {401 return sortType == "asc" ? 1 : -1;402 }403 else if (secondProp < firstProp) {404 return sortType == "asc" ? -1 : 1;405 }406 else {407 return 0;408 }409 })410411 this.setState({412 show: true,413 data: data,414 sortType: sortType == "asc" ? "desc" : "asc"415 })416 }417 }418 render() {419 420 return (<div className={'combobox wasabi-select'}>421 <ArrowInput422 ref={this.input}423 show={this.state.show}424 value={(this.state.inputText??"")}425 attachAble={this.props.attachAble}426 name={this.props.name}427 title={(this.props.title??"")}428 placeholder={(this.props.placeholder??"")}429 sortType={this.state.sortType}430 readOnly={this.props.readOnly}431 onChange={this.onChange.bind(this)}432 onClear={this.onClear.bind(this)}433 onKeyUp={this.keyUpHandler.bind(this)}434 onClick={this.onClick.bind(this)}435 onSort={this.onSort.bind(this)}436 ></ArrowInput>437 <SelectbleList438 show={this.state.show}439 value={this.state.value}440 data={this.state.data}441 removeAble={this.props.removeAble}442 onSelect={this.onSelect.bind(this)}443 onRemove={this.onRemove.bind(this)}444 ></SelectbleList> </div>);445446 }447448}449450export default validateHoc(loadDataHoc(Select, "select"),"select");451 ...

Full Screen

Full Screen

handleBandwidthStats.js

Source:handleBandwidthStats.js Github

copy

Full Screen

...42 };43 this.stats = null;44 }45 gatherSendAudioPacketsStats() {46 this.model.audio_send.bytes = formatValue(this.stats, 'audio', 'send', 'bytes');47 this.model.audio_send.packets = formatValue(this.stats, 'audio', 'send', 'packets');48 this.model.audio_send.echo_return_loss = formatValue(this.stats, 'audio', 'send', 'echoReturnLoss');49 this.model.audio_send.echo_return_loss_enhancement = formatValue(this.stats, 'audio', 'send', 'echoReturnLossEnhancement');50 this.model.audio_send.round_trip_time = formatValue(this.stats, 'audio', 'send', 'roundTripTime');51 this.model.audio_send.audio_level = formatValue(this.stats, 'audio', 'send', 'audioLevel');52 this.model.audio_send.jitter = formatValue(this.stats, 'audio', 'send', 'jitter');53 }54 gatherReceiveAudioPacketsStats() {55 this.model.audio_recv.bytes = formatValue(this.stats, 'audio', 'recv', 'bytes');56 this.model.audio_recv.packets = formatValue(this.stats, 'audio', 'recv', 'packets');57 this.model.audio_recv.packets_lost = formatValue(this.stats, 'audio', 'recv', 'packetsLost');58 this.model.audio_recv.jitter = formatValue(this.stats, 'audio', 'recv', 'jitter');59 this.model.audio_recv.audio_level = formatValue(this.stats, 'audio', 'recv', 'audioLevel');60 }61 gatherSendVideoPacketsStats() {62 this.model.video_send.bytes = formatValue(this.stats, 'video', 'send', 'bytes');63 this.model.video_send.packets = formatValue(this.stats, 'video', 'send', 'packets');64 this.model.video_send.nack_count = formatValue(this.stats, 'video', 'send', 'nacks');65 this.model.video_send.firs_count = formatValue(this.stats, 'video', 'send', 'firs');66 this.model.video_send.plis_count = formatValue(this.stats, 'video', 'send', 'plis');67 this.model.video_send.frames_encoded = formatValue(this.stats, 'video', 'send', 'framesEncoded');68 this.model.video_send.frame_width = formatValue(this.stats, 'video', 'send', 'frameWidth');69 this.model.video_send.frame_height = formatValue(this.stats, 'video', 'send', 'frameHeight');70 this.model.video_send.round_trip_time = formatValue(this.stats, 'video', 'send', 'roundTripTime');71 this.model.video_send.qp_sum = formatValue(this.stats, 'video', 'send', 'qpSum');72 this.model.video_send.jitter = formatValue(this.stats, 'video', 'send', 'jitter');73 this.model.video_send.frames = formatValue(this.stats, 'video', 'send', 'frames');74 this.model.video_send.hugeFrames = formatValue(this.stats, 'video', 'send', 'hugeFramesSent');75 this.model.video_send.framesPerSecond = formatValue(this.stats, 'video', 'send', 'framesPerSecond');76 }77 gatherReceiveVideoPacketsStats() {78 this.model.video_recv.bytes = formatValue(this.stats, 'video', 'recv', 'bytes');79 this.model.video_recv.packets = formatValue(this.stats, 'video', 'recv', 'packets');80 this.model.video_recv.packets_lost = formatValue(this.stats, 'video', 'recv', 'packetsLost');81 this.model.video_recv.nack_count = formatValue(this.stats, 'video', 'recv', 'nacks');82 this.model.video_recv.firs_count = formatValue(this.stats, 'video', 'recv', 'firs');83 this.model.video_recv.plis_count = formatValue(this.stats, 'video', 'recv', 'plis');84 this.model.video_recv.frames_decoded = formatValue(this.stats, 'video', 'recv', 'framesDecoded');85 this.model.video_recv.qp_sum = formatValue(this.stats, 'video', 'recv', 'qpSum');86 this.model.video_recv.frames_decoded = formatValue(this.stats, 'video', 'recv', 'framesDecoded');87 this.model.video_recv.frames_dropped = formatValue(this.stats, 'video', 'recv', 'framesDropped');88 this.model.video_recv.decoderImplementation = formatValue(this.stats, 'video', 'recv', 'decoderImplementation');89 }90 buildTrackInfo(roomKey) {91 const state = Skylink.getSkylinkState(roomKey);92 const { peerStreams, user, streamsSettings } = state;93 const streamObjs = Object.values(peerStreams[user.sid]);94 streamObjs.forEach((streamObj) => {95 if (streamObj) {96 const stream = streamObj;97 const { settings } = streamsSettings[streamObj.id];98 const audioTracks = stream.getAudioTracks();99 const videoTracks = stream.getVideoTracks();100 audioTracks.forEach((audioTrack) => {101 const audioTrackInfo = buildAudioTrackInfo(stream, audioTrack);102 this.model.audio_send.tracks.push(audioTrackInfo);...

Full Screen

Full Screen

core_money_editor.js

Source:core_money_editor.js Github

copy

Full Screen

...28 BX.unbind(this.input, 'bxchange', BX.proxy(this.valueEdit, this));29 this.input = null;30 };31 BX.Currency.Editor.prototype.valueEdit = function(){32 this.formatValue();33 };34 BX.Currency.Editor.prototype.setCurrency = function(currency)35 {36 this.value = BX.Currency.Editor.getUnFormattedValue(this.input.value, this.currency);37 this.currency = currency;38 this.input.value = BX.Currency.Editor.getFormattedValue(39 this.value,40 this.currency41 );42 this.callValueChangeCallback();43 };44 BX.Currency.Editor.prototype.formatValue = function()45 {46 var cursorPos = BX.getCaretPosition(this.input);...

Full Screen

Full Screen

format_value.js

Source:format_value.js Github

copy

Full Screen

...42 });43 // For time_of_day and time_of_week test values which are offsets in seconds44 // from UTC start of week / day are formatted correctly using the test timezone.45 it('correctly formats time_of_week value from numeric input', () => {46 expect(formatValue(359739, 'time_of_week', undefined, timeOfWeekRecord)).to.be('Wed 23:55');47 });48 it('correctly formats time_of_day value from numeric input', () => {49 expect(formatValue(73781, 'time_of_day', undefined, timeOfDayRecord)).to.be('15:29');50 });51 it('correctly formats number values from numeric input', () => {52 expect(formatValue(1483228800, 'mean')).to.be(1483228800);53 expect(formatValue(1234.5678, 'mean')).to.be(1234.6);54 expect(formatValue(0.00012345, 'mean')).to.be(0.000123);55 expect(formatValue(0, 'mean')).to.be(0);56 expect(formatValue(-0.12345, 'mean')).to.be(-0.123);57 expect(formatValue(-1234.5678, 'mean')).to.be(-1234.6);58 expect(formatValue(-100000.1, 'mean')).to.be(-100000);59 });60 it('correctly formats time_of_week value from array input', () => {61 expect(formatValue([359739], 'time_of_week', undefined, timeOfWeekRecord)).to.be('Wed 23:55');62 });63 it('correctly formats time_of_day value from array input', () => {64 expect(formatValue([73781], 'time_of_day', undefined, timeOfDayRecord)).to.be('15:29');65 });66 it('correctly formats number values from array input', () => {67 expect(formatValue([1483228800], 'mean')).to.be(1483228800);68 expect(formatValue([1234.5678], 'mean')).to.be(1234.6);69 expect(formatValue([0.00012345], 'mean')).to.be(0.000123);70 expect(formatValue([0], 'mean')).to.be(0);71 expect(formatValue([-0.12345], 'mean')).to.be(-0.123);72 expect(formatValue([-1234.5678], 'mean')).to.be(-1234.6);73 expect(formatValue([-100000.1], 'mean')).to.be(-100000);74 });75 it('correctly formats multi-valued array', () => {76 expect(formatValue([30.3, 26.2], 'lat_long')).to.be('[30.3,26.2]');77 });...

Full Screen

Full Screen

plural.js

Source:plural.js Github

copy

Full Screen

1define([2 "./core",3 "./common/validate",4 "./common/validate/cldr",5 "./common/validate/default-locale",6 "./common/validate/parameter-key-presence",7 "./common/validate/parameter-presence",8 "./common/validate/parameter-type",9 "./common/validate/parameter-type/number",10 "./common/validate/parameter-type/plain-object",11 "./plural/form",12 "./common/format-message"13], function( Globalize, validate, validateCldr, validateDefaultLocale, validateParameterKeyPresence,14 validateParameterPresence, validateParameterType, validateParameterTypeNumber,15 validateParameterTypePlainObject, pluralForm, formatMessage ) {16/**17 * .formatPlural( value, data, formatValue )18 *19 * @value [Number]20 *21 * @messageData [JSON] eg. { one: "{0} second", other: "{0} seconds" }22 *23 * @formatValue [String|Number] It defaults to `value`. It's used to replace the24 * {0} variable of plural messages.25 *26 * Return the appropriate message based on value's plural group: zero | one |27 * two | few | many | other.28 */29Globalize.formatPlural =30Globalize.prototype.formatPlural = function( value, messageData, formatValue ) {31 var form;32 // Note: validateParameterTypeNumber( value, "value" ) is deferred to this.plural().33 validateParameterPresence( value, "value" );34 validateParameterPresence( messageData, "messageData" );35 validateParameterTypePlainObject( messageData, "messageData" );36 validateParameterType(37 formatValue,38 "formatValue",39 formatValue === undefined || typeof formatValue === "string" ||40 typeof formatValue === "number",41 "String or Number"42 );43 form = this.plural( value );44 // formatValue defaults to value, but it accepts anything including empty strings.45 formatValue = formatValue === undefined ? value : formatValue;46 validateParameterKeyPresence( messageData, "messageData", form );47 return formatMessage( messageData[ form ], [ formatValue ] );48};49/**50 * .plural( value )51 *52 * @value [Number]53 *54 * Return the corresponding form (zero | one | two | few | many | other) of a55 * value given locale.56 */57Globalize.plural =58Globalize.prototype.plural = function( value ) {59 var cldr, form;60 validateParameterPresence( value, "value" );61 validateParameterTypeNumber( value, "value" );62 cldr = this.cldr;63 validateDefaultLocale( cldr );64 cldr.on( "get", validateCldr );65 form = pluralForm( value, cldr );66 cldr.off( "get", validateCldr );67 validate( "E_INVALID_CLDR", "{description}", typeof form === "string", {68 description: "Missing rules to deduce plural form of `" + value + "`"69 });70 return form;71};72return Globalize;...

Full Screen

Full Screen

prefer-formatValues.js

Source:prefer-formatValues.js Github

copy

Full Screen

...21 };22}23ruleTester.run("check-length", rule, {24 valid: [25 "document.l10n.formatValue('foobar');",26 "document.l10n.formatValues(['foobar', 'foobaz']);",27 `if (foo) {28 document.l10n.formatValue('foobar');29 } else {30 document.l10n.formatValue('foobaz');31 }`,32 `document.l10n.formatValue('foobaz');33 if (foo) {34 document.l10n.formatValue('foobar');35 }`,36 `if (foo) {37 document.l10n.formatValue('foobar');38 }39 document.l10n.formatValue('foobaz');`,40 `if (foo) {41 document.l10n.formatValue('foobar');42 }43 document.l10n.formatValues(['foobaz']);`,44 ],45 invalid: [46 {47 code: `document.l10n.formatValue('foobar');48 document.l10n.formatValue('foobaz');`,49 errors: [error(1, 1), error(2, 14)],50 },51 {52 code: `document.l10n.formatValue('foobar');53 if (foo) {54 document.l10n.formatValue('foobiz');55 }56 document.l10n.formatValue('foobaz');`,57 errors: [error(1, 1), error(5, 14)],58 },59 {60 code: `document.l10n.formatValues('foobar');61 document.l10n.formatValue('foobaz');`,62 errors: [error(1, 1), error(2, 14)],63 },64 ],...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add("formatValue", (value) => {2 return new Intl.NumberFormat("en-US", {3 }).format(value);4});5Cypress.Commands.add("formatValue", (value) => {6 return new Intl.NumberFormat("en-US", {7 }).format(value);8});9Cypress.Commands.add("formatValue", (value) => {10 return new Intl.NumberFormat("en-US", {11 }).format(value);12});13Cypress.Commands.add("formatValue", (value) => {14 return new Intl.NumberFormat("en-US", {15 }).format(value);16});17Cypress.Commands.add("formatValue", (value) => {18 return new Intl.NumberFormat("en-US", {19 }).format(value);20});21Cypress.Commands.add("formatValue", (value) => {22 return new Intl.NumberFormat("en-US", {23 }).format(value);24});25Cypress.Commands.add("formatValue", (value) => {26 return new Intl.NumberFormat("en-US", {27 }).format(value);28});

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Does not do much!', function() {3 cy.get('#data-table').invoke('removeAttr', 'target').click({force:true})4 cy.get('#thumbnail-1 td').each(($el, index, $list) => {5 const text = $el.text()6 if(text.includes('Python')){7 cy.get($el).find('a').invoke('removeAttr', 'target').click()8 }9 })10 })11})12describe('My First Test', function() {13 it('Does not do much!', function() {14 cy.get('#data-table').invoke('removeAttr', 'target').click({force:true})15 cy.get('#thumbnail-1 td').each(($el, index, $list) => {16 const text = $el.text()17 if(text.includes('Python')){18 cy.get($el).find('a').invoke('removeAttr', 'target').click()19 }20 })21 })22})23describe('My First Test', function() {24 it('Does not do much!', function() {25 cy.get('#data-table').invoke('removeAttr', 'target').click({force:true})26 cy.get('#thumbnail-1 td').each(($el, index, $list) => {27 const text = $el.text()28 if(text.includes('Python')){29 cy.get($el).find('a').invoke('removeAttr', 'target').click()30 }31 })32 })33})34describe('My First Test', function() {35 it('Does not do much!', function() {36 cy.get('#data-table').invoke('removeAttr', 'target').click({force:true})37 cy.get('#thumbnail-1 td').each(($el, index, $list) => {38 const text = $el.text()39 if(text.includes('Python')){40 cy.get($el).find('a').invoke('removeAttr', 'target').click()41 }42 })43 })44})

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add('formatValue', (value) => {2 return new Intl.NumberFormat('en-US').format(value)3})4Cypress.Commands.add('formatValue', (value) => {5 return new Intl.NumberFormat('en-US').format(value)6})7Cypress.Commands.add('formatValue', (value) => {8 return new Intl.NumberFormat('en-US').format(value)9})10Cypress.Commands.add('formatValue', (value) => {11 return new Intl.NumberFormat('en-US').format(value)12})13Cypress.Commands.add('formatValue', (value) => {14 return new Intl.NumberFormat('en-US').format(value)15})16Cypress.Commands.add('formatValue', (value) => {17 return new Intl.NumberFormat('en-US').format(value)18})19Cypress.Commands.add('formatValue', (value) => {20 return new Intl.NumberFormat('en-US').format(value)21})22Cypress.Commands.add('formatValue', (value) => {23 return new Intl.NumberFormat('en-US').format(value)24})25Cypress.Commands.add('formatValue', (value) => {26 return new Intl.NumberFormat('en-US').format(value)27})28Cypress.Commands.add('formatValue', (value) => {29 return new Intl.NumberFormat('en-US').format(value)30})31Cypress.Commands.add('formatValue', (value) => {32 return new Intl.NumberFormat('en-US').format(value)33})34Cypress.Commands.add('formatValue', (value) => {35 return new Intl.NumberFormat('en-US').format(value)

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add('formatValue', (value) => {2 if (value === null) {3 return 'null';4 }5 const type = typeof value;6 if (type === 'string') {7 return `"${value}"`;8 }9 if (type === 'object') {10 return JSON.stringify(value);11 }12 return String(value);13});14Cypress.Commands.add('formatValue', (value) => {15 if (value === null) {16 return 'null';17 }18 const type = typeof value;19 if (type === 'string') {20 return `"${value}"`;21 }22 if (type === 'object') {23 return JSON.stringify(value);24 }25 return String(value);26});27Cypress.Commands.add('formatValue', (value) => {28 if (value === null) {29 return 'null';30 }31 const type = typeof value;32 if (type === 'string') {33 return `"${value}"`;34 }35 if (type === 'object') {36 return JSON.stringify(value);37 }38 return String(value);39});40Cypress.Commands.add('formatValue', (value) => {41 if (value === null) {42 return 'null';43 }44 const type = typeof value;45 if (type === 'string') {46 return `"${value}"`;47 }48 if (type === 'object') {49 return JSON.stringify(value);50 }51 return String(value);52});53Cypress.Commands.add('formatValue', (value) => {54 if (value === null) {55 return 'null';56 }57 const type = typeof value;58 if (type === 'string') {59 return `"${value}"`;60 }61 if (type === 'object') {62 return JSON.stringify(value);63 }64 return String(value);65});66Cypress.Commands.add('formatValue', (value) => {67 if (value === null) {68 return 'null';69 }70 const type = typeof value;71 if (type

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add('formatValue', (value) => {2 const str = value.toString()3 if (str.includes('.')) {4 return str.split('.')[0]5 }6})7Cypress.Commands.add('formatValue', (value) => {8 const str = value.toString()9 if (str.includes('.')) {10 return str.split('.')[0]11 }12})13Cypress.Commands.add('formatValue', (value) => {14 const str = value.toString()15 if (str.includes('.')) {16 return str.split('.')[0]17 }18})19Cypress.Commands.add('formatValue', (value) => {20 const str = value.toString()21 if (str.includes('.')) {22 return str.split('.')[0]23 }24})25Cypress.Commands.add('formatValue', (value) => {26 const str = value.toString()27 if (str.includes('.')) {28 return str.split('.')[0]29 }30})31Cypress.Commands.add('formatValue', (value) => {32 const str = value.toString()33 if (str.includes('.')) {34 return str.split('.')[0]35 }36})37Cypress.Commands.add('formatValue', (value) => {38 const str = value.toString()39 if (str.includes('.')) {40 return str.split('.')[0]41 }42})43Cypress.Commands.add('formatValue', (value) => {44 const str = value.toString()45 if (str.includes('.')) {46 return str.split('.')[0]47 }48})49Cypress.Commands.add('formatValue', (value) => {50 const str = value.toString()51 if (str.includes('.')) {52 return str.split('.')[0]53 }54})55Cypress.Commands.add('formatValue', (value) => {56 const str = value.toString()57 if (str.includes('.')) {

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add('formatValue', (value) => {2 return Number(value.replace(/[^\d.-]/g, ''));3});4it('should add two numbers', () => {5 cy.get('[data-cy="first-number-input"]').type('10');6 cy.get('[data-cy="second-number-input"]').type('20');7 cy.get('[data-cy="add-button"]').click();8 cy.get('[data-cy="result"]').then(($result) => {9 const result = $result.text();10 expect(Cypress.formatValue(result)).to.equal(30);11 });12});13it('should set local storage', () => {14 cy.window().then((win) => {15 win.localStorage.setItem('key', 'value');16 expect(win.localStorage.getItem('key')).to.equal('value');17 });18});19it('should set cookie', () => {20 cy.window().then((win) => {21 win.localStorage.setItem('key', 'value');22 expect(win.localStorage.getItem('key')).to.equal('value');23 });24});25it('should intercept HTTP request', () => {26 cy.intercept('GET', '/users', (req) => {27 req.reply({

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress 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