How to use setHref method in Cypress

Best JavaScript code snippet using cypress

ChartView.js

Source:ChartView.js Github

copy

Full Screen

...367                                xAxisLabel: 'Week',368                                yAxisLabel: 'Invoice'369                            });370                        });371                        self.setHref('invoice');372                    },373                    purchaseInvoiceByWeek: function () {374                        var _opts = self.options;375                        var filter = {376                            date: {377                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]378                            }379                        };380                        common.getinvoiceByWeek(filter, false, function (data) {381                            self.renderLineChart(data, '_id', 'count', {382                                xAxisLabel: 'Week',383                                yAxisLabel: 'Purchase Invoice'384                            });385                        });386                        self.setHref('purchaseInvoices');387                    }388                },389                horizontalBar: {390                    revenueBySales: function () {391                        var _opts = self.options;392                        var filter = {393                            date: {394                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]395                            }396                        };397                        common.getRevenueBySales(filter, true, function (data) {398                            self.renderHorizontalBarChart(data, 'sum', '_id', {399                                xAxisLabel: 'Revenue',400                                yAxisLabel: 'Sales Manager'401                            });402                        });403                        self.setHref('invoice');404                    },405                    revenueByCountry: function () {406                        var _opts = self.options;407                        var filter = {408                            date: {409                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]410                            }411                        };412                        common.getRevenueByCountry(filter, true, function (data) {413                            self.renderHorizontalBarChart(data, 'sum', '_id', {414                                xAxisLabel: 'Revenue',415                                yAxisLabel: 'Country'416                            });417                        });418                        self.setHref('invoice');419                    },420                    revenueByCustomer: function () {421                        var _opts = self.options;422                        var filter = {423                            date: {424                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]425                            }426                        };427                        common.getRevenueByCustomer(filter, true, function (data) {428                            self.renderHorizontalBarChart(data, 'sum', '_id', {429                                xAxisLabel: 'Revenue',430                                yAxisLabel: 'Customer'431                            });432                        });433                        self.setHref('invoice');434                    },435                    purchaseRevenueBySales: function () {436                        var _opts = self.options;437                        var filter = {438                            date: {439                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]440                            }441                        };442                        common.getRevenueBySales(filter, false, function (data) {443                            self.renderHorizontalBarChart(data, 'sum', '_id', {444                                xAxisLabel: 'Revenue',445                                yAxisLabel: 'Sales Manager'446                            });447                        });448                        self.setHref('invoice');449                    },450                    purchaseRevenueByCountry: function () {451                        var _opts = self.options;452                        var filter = {453                            date: {454                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]455                            }456                        };457                        common.getRevenueByCountry(filter, false, function (data) {458                            self.renderHorizontalBarChart(data, 'sum', '_id', {459                                xAxisLabel: 'Revenue',460                                yAxisLabel: 'Country'461                            });462                        });463                        self.setHref('invoice');464                    },465                    purchaseRevenueByCustomer: function () {466                        var _opts = self.options;467                        var filter = {468                            date: {469                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]470                            }471                        };472                        common.getRevenueByCustomer(filter, false, function (data) {473                            self.renderHorizontalBarChart(data, 'sum', '_id', {474                                xAxisLabel: 'Revenue',475                                yAxisLabel: 'Customer'476                            });477                        });478                        self.setHref('invoice');479                    }480                },481                verticalBar: {482                    invoiceByWeek: function () {483                        var _opts = self.options;484                        var filter = {485                            date: {486                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]487                            }488                        };489                        common.getinvoiceByWeek(filter, true, function (data) {490                            self.renderVerticalBarChart(data, '_id', 'count', {491                                xAxisLabel: 'Week',492                                yAxisLabel: 'Invoice'493                            });494                        });495                        self.setHref('invoice');496                    },497                    purchaseInvoiceByWeek: function () {498                        var _opts = self.options;499                        var filter = {500                            date: {501                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]502                            }503                        };504                        common.getinvoiceByWeek(filter, false, function (data) {505                            self.renderVerticalBarChart(data, '_id', 'count', {506                                xAxisLabel: 'Week',507                                yAxisLabel: 'Purchase Invoice'508                            });509                        });510                        self.setHref('purchaseInvoices');511                    }512                },513                donut: {514                    revenueBySales: function () {515                        var _opts = self.options;516                        var filter = {517                            date: {518                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]519                            }520                        };521                        common.getRevenueBySales(filter, true, function (data) {522                            self.renderDonutChart(data, 'sum', '_id');523                        });524                        self.setHref('invoice');525                    },526                    revenueByCountry: function () {527                        var _opts = self.options;528                        var filter = {529                            date: {530                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]531                            }532                        };533                        common.getRevenueByCountry(filter, true, function (data) {534                            self.renderDonutChart(data, 'sum', '_id');535                        });536                        self.setHref('invoice');537                    },538                    revenueByCustomer: function () {539                        var _opts = self.options;540                        var filter = {541                            date: {542                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]543                            }544                        };545                        common.getRevenueByCustomer(filter, true, function (data) {546                            self.renderDonutChart(data, 'sum', '_id');547                        });548                        self.setHref('invoice');549                    },550                    purchaseRevenueBySales: function () {551                        var _opts = self.options;552                        var filter = {553                            date: {554                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]555                            }556                        };557                        common.getRevenueBySales(filter, false, function (data) {558                            self.renderDonutChart(data, 'sum', '_id');559                        });560                        self.setHref('invoice');561                    },562                    purchaseRevenueByCountry: function () {563                        var _opts = self.options;564                        var filter = {565                            date: {566                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]567                            }568                        };569                        common.getRevenueByCountry(filter, false, function (data) {570                            self.renderDonutChart(data, 'sum', '_id');571                        });572                        self.setHref('invoice');573                    },574                    purchaseRevenueByCustomer: function () {575                        var _opts = self.options;576                        var filter = {577                            date: {578                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]579                            }580                        };581                        common.getRevenueByCustomer(filter, false, function (data) {582                            self.renderDonutChart(data, 'sum', '_id');583                        });584                        self.setHref('invoice');585                    }586                },587                donutAnimated: {588                    revenueBySales: function () {589                        var _opts = self.options;590                        var filter = {591                            date: {592                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]593                            }594                        };595                        common.getRevenueBySales(filter, true, function (data) {596                            self.renderDonutAnimatedChart(data, 'sum', '_id');597                        });598                        self.setHref('invoice');599                    },600                    revenueByCountry: function () {601                        var _opts = self.options;602                        var filter = {603                            date: {604                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]605                            }606                        };607                        common.getRevenueByCountry(filter, true, function (data) {608                            self.renderDonutAnimatedChart(data, 'sum', '_id');609                        });610                        self.setHref('invoice');611                    },612                    revenueByCustomer: function () {613                        var _opts = self.options;614                        var filter = {615                            date: {616                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]617                            }618                        };619                        common.getRevenueByCustomer(filter, true, function (data) {620                            self.renderDonutAnimatedChart(data, 'sum', '_id');621                        });622                        self.setHref('invoice');623                    },624                    purchaseRevenueBySales: function () {625                        var _opts = self.options;626                        var filter = {627                            date: {628                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]629                            }630                        };631                        common.getRevenueBySales(filter, false, function (data) {632                            self.renderDonutAnimatedChart(data, 'sum', '_id');633                        });634                        self.setHref('invoice');635                    },636                    purchaseRevenueByCountry: function () {637                        var _opts = self.options;638                        var filter = {639                            date: {640                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]641                            }642                        };643                        common.getRevenueByCountry(filter, false, function (data) {644                            self.renderDonutAnimatedChart(data, 'sum', '_id');645                        });646                        self.setHref('invoice');647                    },648                    purchaseRevenueByCustomer: function () {649                        var _opts = self.options;650                        var filter = {651                            date: {652                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]653                            }654                        };655                        common.getRevenueByCustomer(filter, false, function (data) {656                            self.renderDonutAnimatedChart(data, 'sum', '_id');657                        });658                        self.setHref('invoice');659                    }660                },661                pie: {662                    revenueBySales: function () {663                        var _opts = self.options;664                        var filter = {665                            date: {666                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]667                            }668                        };669                        common.getRevenueBySales(filter, true, function (data) {670                            self.renderPieChart(data, 'sum', '_id');671                        });672                        self.setHref('invoice');673                    },674                    revenueByCountry: function () {675                        var _opts = self.options;676                        var filter = {677                            date: {678                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]679                            }680                        };681                        common.getRevenueByCountry(filter, true, function (data) {682                            self.renderPieChart(data, 'sum', '_id');683                        });684                        self.setHref('invoice');685                    },686                    revenueByCustomer: function () {687                        var _opts = self.options;688                        var filter = {689                            date: {690                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]691                            }692                        };693                        common.getRevenueByCustomer(filter, true, function (data) {694                            self.renderPieChart(data, 'sum', '_id');695                        });696                        self.setHref('invoice');697                    },698                    purchaseRevenueBySales: function () {699                        var _opts = self.options;700                        var filter = {701                            date: {702                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]703                            }704                        };705                        common.getRevenueBySales(filter, false, function (data) {706                            self.renderPieChart(data, 'sum', '_id');707                        });708                        self.setHref('invoice');709                    },710                    purchaseRevenueByCountry: function () {711                        var _opts = self.options;712                        var filter = {713                            date: {714                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]715                            }716                        };717                        common.getRevenueByCountry(filter, false, function (data) {718                            self.renderPieChart(data, 'sum', '_id');719                        });720                        self.setHref('invoice');721                    },722                    purchaseRevenueByCustomer: function () {723                        var _opts = self.options;724                        var filter = {725                            date: {726                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]727                            }728                        };729                        common.getRevenueByCustomer(filter, false, function (data) {730                            self.renderPieChart(data, 'sum', '_id');731                        });732                        self.setHref('invoice');733                    }734                },735                pieAnimated: {736                    revenueBySales: function () {737                        var _opts = self.options;738                        var filter = {739                            date: {740                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]741                            }742                        };743                        common.getRevenueBySales(filter, true, function (data) {744                            self.renderPieAnimatedChart(data, 'sum', '_id');745                        });746                        self.setHref('invoice');747                    },748                    revenueByCountry: function () {749                        var _opts = self.options;750                        var filter = {751                            date: {752                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]753                            }754                        };755                        common.getRevenueByCountry(filter, true, function (data) {756                            self.renderPieAnimatedChart(data, 'sum', '_id');757                        });758                        self.setHref('invoice');759                    },760                    revenueByCustomer: function () {761                        var _opts = self.options;762                        var filter = {763                            date: {764                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]765                            }766                        };767                        common.getRevenueByCustomer(filter, true, function (data) {768                            self.renderPieAnimatedChart(data, 'sum', '_id');769                        });770                        self.setHref('invoice');771                    },772                    purchaseRevenueBySales: function () {773                        var _opts = self.options;774                        var filter = {775                            date: {776                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]777                            }778                        };779                        common.getRevenueBySales(filter, false, function (data) {780                            self.renderPieAnimatedChart(data, 'sum', '_id');781                        });782                        self.setHref('invoice');783                    },784                    purchaseRevenueByCountry: function () {785                        var _opts = self.options;786                        var filter = {787                            date: {788                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]789                            }790                        };791                        common.getRevenueByCountry(filter, false, function (data) {792                            self.renderPieAnimatedChart(data, 'sum', '_id');793                        });794                        self.setHref('invoice');795                    },796                    purchaseRevenueByCustomer: function () {797                        var _opts = self.options;798                        var filter = {799                            date: {800                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]801                            }802                        };803                        common.getRevenueByCustomer(filter, false, function (data) {804                            self.renderPieAnimatedChart(data, 'sum', '_id');805                        });806                        self.setHref('invoice');807                    }808                },809                singleValue: {810                    totalPurchaseRevenue: function () {811                        var _opts = self.options;812                        var filter = {813                            date: {814                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]815                            }816                        };817                        common.getRevenueForSingle(filter, false, function (data) {818                            self.renderSingleValue(data, 'Purchase Revenue');819                        });820                        self.setHref('purchaseInvoices');821                    },822                    totalSalesRevenue: function () {823                        var _opts = self.options;824                        var filter = {825                            date: {826                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]827                            }828                        };829                        common.getRevenueForSingle(filter, true, function (data) {830                            self.renderSingleValue(data, 'Sales Revenue');831                        });832                        self.setHref('invoice');833                    },834                    totalSalesOrders: function (){835                        var _opts = self.options;836                        var filter = {837                            date: {838                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]839                            }840                        };841                        common.getTotalOrdersForSingle(filter, true, function (data) {842                            self.renderSingleValue(data, 'Sales Orders');843                        });844                        self.setHref('order');845                    },846                    totalPurchaseOrder: function (){847                        var _opts = self.options;848                        var filter = {849                            date: {850                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]851                            }852                        };853                        common.getTotalOrdersForSingle(filter, false, function (data) {854                            self.renderSingleValue(data, 'Sales Orders');855                        });856                        self.setHref('purchaseOrders');857                    },858                    totalReceivedOrders: function (){859                        var _opts = self.options;860                        var filter = {861                            date: {862                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]863                            }864                        };865                        common.getByStatusForSingle(filter, false, true, function (data) {866                            self.renderSingleValue(data, 'Received Orders');867                        });868                        self.setHref('purchaseOrders');869                    },870                    totalPartialReceivedOrders: function (){871                        var _opts = self.options;872                        var filter = {873                            date: {874                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]875                            }876                        };877                        common.getByStatusForSingle(filter, false, false, function (data) {878                            self.renderSingleValue(data, 'Partial Received Orders');879                        });880                        self.setHref('purchaseOrders');881                    },882                    totalDeliveredPurchaseOrders: function (){883                        var _opts = self.options;884                        var filter = {885                            date: {886                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]887                            }888                        };889                        common.getByStatusForSingle(filter, true, true, function (data) {890                            self.renderSingleValue(data, 'Delivered Orders');891                        });892                        self.setHref('order');893                    },894                    totalPartialDeliveredPurchasedOrders: function (){895                        var _opts = self.options;896                        var filter = {897                            date: {898                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]899                            }900                        };901                        common.getByStatusForSingle(filter, true, false, function (data) {902                            self.renderSingleValue(data, 'Partial Delivered Orders');903                        });904                        self.setHref('order');905                    }906                },907                horizontalBarLayout: {908                    leadsBySource: function () {909                        var _opts = self.options;910                        var filter = {911                            date: {912                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]913                            }914                        };915                        common.getLeadsForChart('source', filter, function (data) {916                            var sources = _.uniq(_.pluck(data, 'source'));917                            var newData = [];918                            var j;919                            var i;920                            // for (i = sources.length; i--;) {921                            //     newData.push({922                            //         source: sources[i],923                            //         total : 0,924                            //         isOpp : 0925                            //     });926                            // }927                            // for (i = data.length; i--;) {928                            //929                            //     for (j = newData.length; j--;) {930                            //931                            //         if (newData[j].source === data[i].source) {932                            //933                            //             if (data[i].isOpp) {934                            //                 newData[j].isOpp += data[i].count;935                            //             } else {936                            //                 newData[j].total += data[i].count;937                            //             }938                            //         }939                            //     }940                            // }941                            self.renderHorizontalBarLayout(data, ['isOpp', 'count'], {942                                xAxisLabel: '',943                                yAxisLabel: 'Source'944                            });945                        });946                        self.setHref('Leads');947                    }948                },949                verticalBarLayout: {},950                overview: {951                    totalPurchaseRevenue: function () {952                        var _opts = self.options;953                        var filter = {954                            date: {955                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]956                            }957                        };958                        common.getInvoiceByWorkflows(filter, false, function (data) {959                            self.renderTableOverview(data, '_id');960                        });961                        self.setHref('purchaseInvoices');962                    },963                    totalSalesRevenue: function () {964                        var _opts = self.options;965                        var filter = {966                            date: {967                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]968                            }969                        };970                        common.getInvoiceByWorkflows(filter, true, function (data) {971                            self.renderTableOverview(data, '_id');972                        });973                        self.setHref('invoice');974                    },975                    purchaseOrders: function () {976                        var _opts = self.options;977                        var filter = {978                            date: {979                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]980                            }981                        };982                        common.getOrdersByWorkflows(filter, false, function (data) {983                            self.renderTableOverview(data, '_id');984                        });985                        self.setHref('purchaseOrders');986                    },987                    orders: function () {988                        var _opts = self.options;989                        var filter = {990                            date: {991                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]992                            }993                        };994                        common.getOrdersByWorkflows(filter, true, function (data) {995                            self.renderTableOverview(data, '_id');996                        });997                        self.setHref('order');998                    }999                },1000                table: {1001                    totalPurchaseRevenue: function () {1002                        var _opts = self.options;1003                        var filter = {1004                            date: {1005                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]1006                            }1007                        };1008                        common.getInvoices(filter, false, function (data) {1009                            self.renderTable(data, '_id');1010                        });1011                        self.setHref('purchaseInvoices');1012                    },1013                    totalSalesRevenue: function () {1014                        var _opts = self.options;1015                        var filter = {1016                            date: {1017                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]1018                            }1019                        };1020                        common.getInvoices(filter, true, function (data) {1021                            self.renderTable(data, '_id');1022                        });1023                        self.setHref('invoice');1024                    },1025                    pastDuePurchaseInvoices: function () {1026                        var _opts = self.options;1027                        var filter = {1028                            date   : {1029                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]1030                            },1031                            pastDue: true1032                        };1033                        common.getInvoices(filter, false, function (data) {1034                            self.renderTable(data, '_id');1035                        });1036                        self.setHref('purchaseInvoices');1037                    },1038                    pastDueInvoices: function () {1039                        var _opts = self.options;1040                        var filter = {1041                            date   : {1042                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]1043                            },1044                            pastDue: true1045                        };1046                        common.getInvoices(filter, true, function (data) {1047                            self.renderTable(data, '_id');1048                        });1049                        self.setHref('invoice');1050                    },1051                    purchaseOrders: function () {1052                        var _opts = self.options;1053                        var filter = {1054                            date: {1055                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]1056                            }1057                        };1058                        common.getOrders(filter, false, function (data) {1059                            self.renderTable(data, '_id');1060                        });1061                        self.setHref('purchaseOrders');1062                    },1063                    orders: function () {1064                        var _opts = self.options;1065                        var filter = {1066                            date: {1067                                value: [new Date(_opts.startDate), new Date(_opts.endDate)]1068                            }1069                        };1070                        common.getOrders(filter, true, function (data) {1071                            self.renderTable(data, '_id');1072                        });1073                        self.setHref('order');1074                    }1075                }1076            };1077            chartObj[this.options.type][this.options.dataSelect]();1078        }1079    });1080    return View;...

Full Screen

Full Screen

map.js

Source:map.js Github

copy

Full Screen

...555         highlightIcon = ge.createIcon('');556557         // Set icon558         if(emotion == emotionGroup[0].name){559             normalIcon.setHref(url + 'happy.png');560             highlightIcon.setHref(url + "happy.png");561         }else if(emotion == emotionGroup[1].name){562             normalIcon.setHref(url + 'sad.png');563             highlightIcon.setHref(url + "sad.png");564         }else if(emotion == emotionGroup[2].name){565             normalIcon.setHref(url + 'worried.png');566             highlightIcon.setHref(url + "worried.png");567         }else if(emotion == emotionGroup[3].name){568             normalIcon.setHref(url + 'angry.png');569             highlightIcon.setHref(url + "angry.png");570         }else if(emotion == emotionGroup[4].name){571             normalIcon.setHref(url + 'disappoint.png');572             highlightIcon.setHref(url + "disappoint.png");573         }else if(emotion == emotionGroup[5].name){574             normalIcon.setHref(url + 'peace.png');575             highlightIcon.setHref(url + "peace.png");576         }else if(emotion == emotionGroup[6].name){577             normalIcon.setHref(url + 'nervous.png');578             highlightIcon.setHref(url + "nervous.png");579         }else if(emotion == emotionGroup[7].name){580             normalIcon.setHref(url + 'afraid.png');581             highlightIcon.setHref(url + "afraid.png");582         }else if(emotion == emotionGroup[8].name){583             normalIcon.setHref(url + 'touched.png');584             highlightIcon.setHref(url + "touched.png");585         }else if(emotion == emotionGroup[9].name){586             normalIcon.setHref(url + 'hope.png');587             highlightIcon.setHref(url + "hope.png");588         }else if(emotion == emotionGroup[10].name){589             normalIcon.setHref(url + 'love.png');590             highlightIcon.setHref(url + "love.png");591         }else if(emotion == emotionGroup[11].name){592             normalIcon.setHref(url + 'hate.png');593             highlightIcon.setHref(url + "hate.png");594595         }else if(emotion == "happiness city"){596597            if(name.indexOf("taipei")!=-1){598                normalIcon.setHref(url + 'newTaipei.png');599                highlightIcon.setHref(url + "newTaipei.png");600            }else if(name.indexOf("kaohsiung")!=-1){601                normalIcon.setHref(url + 'Kaohsiung.png');602                highlightIcon.setHref(url + "Kaohsiung.png");603            }else if(name.indexOf("yilan")!=-1){604                normalIcon.setHref(url + 'Yilan.png');605                highlightIcon.setHref(url + "Yilan.png");606            }else if(name.indexOf("taoyuan")!=-1){607                normalIcon.setHref(url + 'Taoyuan.png');608                highlightIcon.setHref(url + "Taoyuan.png");609            }else if(name.indexOf("hsinchu")!=-1){610                normalIcon.setHref(url + 'Hsinchu.png');611                highlightIcon.setHref(url + "Hsinchu.png");612            }else if(name.indexOf("miaoli")!=-1){613                normalIcon.setHref(url + 'Miaoli.png');614                highlightIcon.setHref(url + "Miaoli.png");615            }else if(name.indexOf("taichung")!=-1){616                normalIcon.setHref(url + 'Taichung.png');617                highlightIcon.setHref(url + "Taichung.png");618            }else if(name.indexOf("changhua")!=-1){619                normalIcon.setHref(url + 'Changhua.png');620                highlightIcon.setHref(url + "Changhua.png");621            }else if(name.indexOf("nantou")!=-1){622                normalIcon.setHref(url + 'Nantou.png');623                highlightIcon.setHref(url + "Nantou.png");624            }else if(name.indexOf("yunlin")!=-1){625                normalIcon.setHref(url + 'Yunlin.png');626                highlightIcon.setHref(url + "Yunlin.png");627            }else if(name.indexOf("chiayi")!=-1){628                normalIcon.setHref(url + 'Chiayi.png');629                highlightIcon.setHref(url + "Chiayi.png");630            }else if(name.indexOf("tainan")!=-1){631                normalIcon.setHref(url + 'Tainan.png');632                highlightIcon.setHref(url + "Tainan.png");633            }else if(name.indexOf("pingtung")!=-1){634                normalIcon.setHref(url + 'Pingtung.png');635                highlightIcon.setHref(url + "Pingtung.png");636            }else if(name.indexOf("hualien")!=-1){637                normalIcon.setHref(url + 'Hualien.png');638                highlightIcon.setHref(url + "Hualien.png");639            }else if(name.indexOf("keelung")!=-1){640                normalIcon.setHref(url + 'Keelung.png');641                highlightIcon.setHref(url + "Keelung.png");642            }else if(name.indexOf("taitung")!=-1){643                normalIcon.setHref(url + 'Taitung.png');644                highlightIcon.setHref(url + "Taitung.png");645            }else{}646647         }else if(emotion!=null){648649              if(intensity.indexOf(",")!=-1){650                  var creditInfo = intensity.split(","),651                  credit = parseInt(creditInfo[0]) - parseInt(creditInfo[1])652                  if(credit>0){653                    normalIcon.setHref(url + "good.png");654                    highlightIcon.setHref(url + "good.png");655                  }else if(credit<0){656                    normalIcon.setHref(url + "bad.png");657                    highlightIcon.setHref(url + "bad.png");658                  }else{659                    normalIcon.setHref(url + "normal.png");660                    highlightIcon.setHref(url + "normal.png");                      661                  }// end if662              }else{663                    normalIcon.setHref(url + 'happy.png');664                    highlightIcon.setHref(url + "happy.png");665              }// end if666667         }else{668             normalIcon.setHref(url + 'happy.png');669             highlightIcon.setHref(url + "happy.png");670         }// end671         672         normalStyle.getIconStyle().setIcon(normalIcon);         673         highlightStyle.getIconStyle().setIcon(highlightIcon);674675         if(emotion == "happiness city"){676            normalStyle.getIconStyle().setScale(1.2);677            highlightStyle.getIconStyle().setScale(5.0); // make same icon bigger while mouse over678         }else if(emotion == "scenic point"){679            highlightStyle.getIconStyle().setScale(3.0); // make same icon bigger while mouse over680         }else{681            highlightStyle.getIconStyle().setScale(3.0); // make same icon bigger while mouse over682         }// end if683         styleMap.setNormalStyle(normalStyle);
...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

...9  incomplete.setName('test');10  t.throws(() => {11    incomplete.toJSON();12  });13  incomplete.setHref('test');14  t.doesNotThrow(() => {15    incomplete.toJSON();16  });17  t.throws(() => {18    incomplete.setMethod('TRACE');19  });20  const conflict = Siren.action()21    .addField('duplicate', Siren.field());22  t.throws(() => {23    conflict.addField('duplicate', Siren.field());24  });25  const action = Siren.action()26    .copy()27    .clone()28    .setName('replace-avatar')29    .addClass('upload')30    .setMethod('PUT')31    .setHref('https://api.example.org/users/joe%40example.org/avatar')32    .setTitle('Avatar')33    .setType('image/jpeg')34    .addField('csrf_token', Siren.field()35      .setType('hidden')36      .setValue('MUyFhg+Ah1I5Iz/jbbHwC2Ip/DqCYZFPncFTp9HnTmU='));37  const expected = {38    name: 'replace-avatar',39    class: ['upload'],40    method: 'PUT',41    href: 'https://api.example.org/users/joe%40example.org/avatar',42    title: 'Avatar',43    type: 'image/jpeg',44    fields: [45      {46        name: 'csrf_token',47        type: 'hidden',48        value: 'MUyFhg+Ah1I5Iz/jbbHwC2Ip/DqCYZFPncFTp9HnTmU='49      }50    ]51  };52  t.deepEqual(action.toJSON(), expected);53  const copy = action.copy();54  t.notEqual(copy, action);55  t.deepEqual(copy.toJSON(), action.toJSON());56  copy.addField('krillin', Siren.field());57  copy.addClass('potatos');58  t.deepEqual(copy.toJSON(), action.toJSON());59  copy.setType('image/png');60  t.deepInequal(copy.toJSON(), action.toJSON());61  const clone = action.clone();62  t.notEqual(clone, action);63  t.deepEqual(clone.toJSON(), action.toJSON());64  clone.addField('dog', Siren.field());65  clone.addClass('spaghetti');66  t.deepInequal(clone.toJSON(), action.toJSON());67  action.addField('dog', Siren.field());68  action.addClass('spaghetti');69  t.deepEqual(clone.toJSON(), action.toJSON());70  clone.setType('image/svg+xml');71  t.deepInequal(clone.toJSON(), action.toJSON());72  t.done();73});74Tap.test('SirenEntity', (t) => {75  const incomplete = Siren.entity();76  t.deepEqual(incomplete.toJSON(), {});77  const conflict = Siren.entity()78    .addAction('duplicate', Siren.action());79  t.throws(() => {80    conflict.addAction('duplicate', Siren.action());81  });82  const entity = Siren.entity()83    .copy()84    .clone()85    .addClass('home')86    .setRel('help')87    .addProperty('salutation', 'Greetings!')88    .addProperty('hapiness', '7/10')89    .addEntity('next', Siren.entity().addProperty('salutation', 'Hallo!'))90    .addEntity('prev', Siren.link().setHref('https://api.example.org/yo'))91    .addAction('reply', Siren.action()92      .setMethod('POST')93      .setHref('https://api.example.org/reply?salutation=Greetings!')94      .addField('response', Siren.field()95        .setType('text')))96    .addLink('self', Siren.link()97      .setHref('https://api.example.org/greetings'));98  const expected = {99    class: ['home'],100    rel: ['help'],101    properties: {102      salutation: 'Greetings!',103      hapiness: '7/10'104    },105    entities: [106      {107        rel: ['next'],108        properties: {109          salutation: 'Hallo!'110        }111      },112      {113        rel: ['prev'],114        href: 'https://api.example.org/yo'115      }116    ],117    actions: [118      {119        name: 'reply',120        method: 'POST',121        href: 'https://api.example.org/reply?salutation=Greetings!',122        fields: [123          {124            name: 'response',125            type: 'text'126          }127        ]128      }129    ],130    links: [131      {132        rel: ['self'],133        href: 'https://api.example.org/greetings'134      }135    ]136  };137  t.deepEqual(entity.toJSON(), expected);138  const copy = entity.copy();139  t.notEqual(copy, entity);140  t.deepEqual(copy.toJSON(), entity.toJSON());141  copy.addAction('logout', Siren.action()142    .setHref('https://api.example.org/sign-out'));143  copy.addLink('home', Siren.link()144    .setHref('https://api.example.org'));145  t.deepEqual(copy.toJSON(), entity.toJSON());146  copy.setRel('spooky');147  t.deepInequal(copy.toJSON(), entity.toJSON());148  const clone = entity.clone();149  t.notEqual(clone, entity);150  t.deepEqual(clone.toJSON(), entity.toJSON());151  clone.addAction('sign-out', Siren.action()152    .setHref('https://api.example.org/logout'));153  clone.addLink('raditz', Siren.link()154    .setHref('https://api.example.org'));155  t.deepInequal(clone.toJSON(), entity.toJSON());156  entity.addAction('sign-out', Siren.action()157    .setHref('https://api.example.org/logout'));158  entity.addLink('raditz', Siren.link()159    .setHref('https://api.example.org'));160  t.deepEqual(clone.toJSON(), entity.toJSON());161  clone.setRel('skunk');162  t.deepInequal(clone.toJSON(), entity.toJSON());163  t.done();164});165Tap.test('SirenField', (t) => {166  const incomplete = Siren.field();167  t.throws(() => {168    incomplete.toJSON();169  });170  incomplete.setName('test');171  t.doesNotThrow(() => {172    incomplete.toJSON();173  });174  const field = Siren.field()175    .copy()176    .clone()177    .setName('telephone')178    .addClass('required')179    .setType('tel')180    .setValue('+X (XXX) XXX-XXXX')181    .setTitle('International Phone No.');182  const expected = {183    name: 'telephone',184    class: ['required'],185    type: 'tel',186    value: '+X (XXX) XXX-XXXX',187    title: 'International Phone No.'188  };189  t.deepEqual(field.toJSON(), expected);190  const copy = field.copy();191  t.notEqual(copy, field);192  t.deepEqual(copy.toJSON(), field.toJSON());193  copy.addClass('spooky');194  t.deepEqual(copy.toJSON(), field.toJSON());195  copy.setName('phone_number');196  t.deepInequal(copy.toJSON(), field.toJSON());197  const clone = field.clone();198  t.notEqual(clone, field);199  t.deepEqual(clone.toJSON(), field.toJSON());200  clone.addClass('vegeta');201  t.deepInequal(clone.toJSON(), field.toJSON());202  field.addClass('vegeta');203  t.deepEqual(clone.toJSON(), field.toJSON());204  clone.setName('cell');205  t.deepInequal(clone.toJSON(), field.toJSON());206  t.done();207});208Tap.test('SirenLink', (t) => {209  const incomplete = Siren.link();210  t.throws(() => {211    incomplete.toJSON();212  });213  incomplete.setRel('about');214  t.throws(() => {215    incomplete.toJSON();216  });217  incomplete.setHref('https://api.example.org/about-us');218  t.doesNotThrow(() => {219    incomplete.toJSON();220  });221  const link = Siren.link()222    .copy()223    .clone()224    .setRel(['next', 'last'])225    .addClass('page')226    .setHref('https://api.example.org/items?page=2')227    .setTitle('Page 2')228    .setType('application/vnd.siren+json');229  const expected = {230    rel: ['next', 'last'],231    class: ['page'],232    href: 'https://api.example.org/items?page=2',233    title: 'Page 2',234    type: 'application/vnd.siren+json'235  };236  t.deepEqual(link.toJSON(), expected);237  const copy = link.copy();238  t.notEqual(copy, link);239  t.deepEqual(copy.toJSON(), link.toJSON());240  copy.addClass('spooky');241  t.deepEqual(copy.toJSON(), link.toJSON());242  copy.setTitle('Page Two');243  t.deepInequal(copy.toJSON(), link.toJSON());244  const clone = link.clone();245  t.notEqual(clone, link);246  t.deepEqual(clone.toJSON(), link.toJSON());247  clone.addClass('goku');248  t.deepInequal(clone.toJSON(), link.toJSON());249  link.addClass('goku');250  clone.setTitle('Page II');251  t.deepInequal(clone.toJSON(), link.toJSON());252  t.done();253});254Tap.test('siren example', (t) => {255  const actual = Siren.entity()256    .addClass('order')257    .addProperty('orderNumber', 42)258    .addProperty('itemCount', 3)259    .addProperty('status', 'pending')260    .addEntity('http://x.io/rels/order-items', Siren.link()261      .addClass('items')262      .addClass('collection')263      .setHref('http://api.x.io/orders/42/items'))264    .addEntity('http://x.io/rels/customer', Siren.entity()265      .addClass('info')266      .addClass('customer')267      .addProperty('customerId', 'pj123')268      .addProperty('name', 'Peter Joseph')269      .addLink('self', Siren.link()270        .setHref('http://api.x.io/customers/pj123')))271    .addAction('add-item', Siren.action()272      .setTitle('Add Item')273      .setMethod('POST')274      .setHref('http://api.x.io/orders/42/items')275      .setType('application/x-www-form-urlencoded')276      .addField('orderNumber', Siren.field()277        .setType('hidden')278        .setValue('42'))279      .addField('productCode', Siren.field()280        .setType('text'))281      .addField('quantity', Siren.field()282        .setType('number')))283    .addLink('self', Siren.link()284      .setHref('http://api.x.io/orders/42'))285    .addLink('previous', Siren.link()286      .setHref('http://api.x.io/orders/41'))287    .addLink('next', Siren.link()288      .setHref('http://api.x.io/orders/43'))289    .toJSON();290  const expected = {291    'class': ['order'],292    'properties': {293      'orderNumber': 42,294      'itemCount': 3,295      'status': 'pending'296    },297    'entities': [298      {299        'class': ['items', 'collection'],300        'rel': ['http://x.io/rels/order-items'],301        'href': 'http://api.x.io/orders/42/items'302      },303      {304        'class': ['info', 'customer'],305        'rel': ['http://x.io/rels/customer'],306        'properties': {307          'customerId': 'pj123',308          'name': 'Peter Joseph'309        },310        'links': [311          { 'rel': ['self'], 'href': 'http://api.x.io/customers/pj123' }312        ]313      }314    ],315    'actions': [316      {317        'name': 'add-item',318        'title': 'Add Item',319        'method': 'POST',320        'href': 'http://api.x.io/orders/42/items',321        'type': 'application/x-www-form-urlencoded',322        'fields': [323          { 'name': 'orderNumber', 'type': 'hidden', 'value': '42' },324          { 'name': 'productCode', 'type': 'text' },325          { 'name': 'quantity', 'type': 'number' }326        ]327      }328    ],329    'links': [330      { 'rel': ['self'], 'href': 'http://api.x.io/orders/42' },331      { 'rel': ['previous'], 'href': 'http://api.x.io/orders/41' },332      { 'rel': ['next'], 'href': 'http://api.x.io/orders/43' }333    ]334  };335  t.deepEqual(actual, expected);336  t.done();337});338Tap.test('addProperties', (t) => {339  const actual = Siren.entity()340    .addProperty('beforeProp', 'should be kept')341    .addProperty('name', 'will be overridden')342    .addProperties({343      'name': 'overrides previous prop',344      'orderNumber': 42,345      'itemCount': 3,346      'status': 'pending'347    })348    .addProperty('afterProp', 'should be kept')349    .addProperty('status', 'overrides pending')350    .toJSON();351  const expected = {352    'properties': {353      'orderNumber': 42,354      'itemCount': 3,355      'status': 'overrides pending',356      'name': 'overrides previous prop',357      'beforeProp': 'should be kept',358      'afterProp': 'should be kept'359    }360  };361  t.deepEqual(actual, expected);362  t.done();363});364Tap.test('readme example', (t) => {365  const actual = Siren.entity()366    .addClass('home')367    .addProperty('version', '2.4.1')368    .addProperty('health', 'green')369    .addAction('find-widget', Siren.action()370      .setTitle('Find Widget')371      .setMethod('GET')372      .setHref('https://api.example.org/widgets/search')373      .setType('application/x-www-form-urlencoded')374      .addField('q', Siren.field()375        .setType('text')))376    .addLink('self', Siren.link()377      .setHref('https://api.example.org/'))378    .toJSON();379  const expected = {380    class: ['home'],381    properties: {382      version: '2.4.1',383      health: 'green'384    },385    actions: [386      {387        name: 'find-widget',388        method: 'GET',389        href: 'https://api.example.org/widgets/search',390        title: 'Find Widget',391        type: 'application/x-www-form-urlencoded',...

Full Screen

Full Screen

mapPersonal.js

Source:mapPersonal.js Github

copy

Full Screen

...160         highlightIcon = ge.createIcon('');161162         // Set icon163         if(emotion == emotionGroup[0].name){164             normalIcon.setHref(url + 'happy.png');165             highlightIcon.setHref(url + "happy.png");166         }else if(emotion == emotionGroup[1].name){167             normalIcon.setHref(url + 'sad.png');168             highlightIcon.setHref(url + "sad.png");169         }else if(emotion == emotionGroup[2].name){170             normalIcon.setHref(url + 'worried.png');171             highlightIcon.setHref(url + "worried.png");172         }else if(emotion == emotionGroup[3].name){173             normalIcon.setHref(url + 'angry.png');174             highlightIcon.setHref(url + "angry.png");175         }else if(emotion == emotionGroup[4].name){176             normalIcon.setHref(url + 'disappoint.png');177             highlightIcon.setHref(url + "disappoint.png");178         }else if(emotion == emotionGroup[5].name){179             normalIcon.setHref(url + 'peace.png');180             highlightIcon.setHref(url + "peace.png");181         }else if(emotion == emotionGroup[6].name){182             normalIcon.setHref(url + 'nervous.png');183             highlightIcon.setHref(url + "nervous.png");184         }else if(emotion == emotionGroup[7].name){185             normalIcon.setHref(url + 'afraid.png');186             highlightIcon.setHref(url + "afraid.png");187         }else if(emotion == emotionGroup[8].name){188             normalIcon.setHref(url + 'touched.png');189             highlightIcon.setHref(url + "touched.png");190         }else if(emotion == emotionGroup[9].name){191             normalIcon.setHref(url + 'hope.png');192             highlightIcon.setHref(url + "hope.png");193         }else if(emotion == emotionGroup[10].name){194             normalIcon.setHref(url + 'love.png');195             highlightIcon.setHref(url + "love.png");196         }else if(emotion == emotionGroup[11].name){197             normalIcon.setHref(url + 'hate.png');198             highlightIcon.setHref(url + "hate.png");199200         }else{201             normalIcon.setHref(url + 'happy.png');202             highlightIcon.setHref(url + "happy.png");203         }// end204         205         normalStyle.getIconStyle().setIcon(normalIcon);         206         highlightStyle.getIconStyle().setIcon(highlightIcon);207         highlightStyle.getIconStyle().setScale(3.0); // make same icon bigger while mouse over208209         styleMap.setNormalStyle(normalStyle);210         styleMap.setHighlightStyle(highlightStyle);211212         // Apply stylemap to a placemark.213         pmk.setStyleSelector(styleMap);214215         // Add the placemark to Earth.216         ge.getFeatures().appendChild(pmk);
...

Full Screen

Full Screen

value.js

Source:value.js Github

copy

Full Screen

...38    const { setHref } = this.props;39    if (!setHref || !this.$el.current) return;40    const $links = this.$el.current.querySelectorAll('a[href^="#"]');41    for (let $link of $links) {42      const href = setHref($link);43      if (href == null) {44        $link.removeAttribute('href');45      } else {46        $link.setAttribute('href', setHref($link));47      }48    }49  }50  handleEndnotes() {51    // We render the endnotes as upper case roman to differentiate them from footnotes52    if (this.$el.current) {53      const $endnotes = this.$el.current.querySelectorAll('a[rel~="endnote"]');54      Array.from($endnotes).forEach($endnote => {55        Array.from($endnote.childNodes).forEach(node => {56          if (node.nodeType === Node.TEXT_NODE && /\s*\d+\s*/.test(node.data)) {57            node.data = node.data.replace(/(\d+)/, (match, p1) => {58              return romanize(p1);59            });60          }...

Full Screen

Full Screen

api-details.es

Source:api-details.es Github

copy

Full Screen

...8/* Support functions */9function setDialogStationName(stationName) {10  $('.js-station-name').text(stationName);11}12function setHref(selector, hrefRoot, args) {13  _.each(CONTENT_TYPES, (contentType) => {14    $(`${selector} a.js-${contentType}`).attr('href', `${API_ROOT}${hrefRoot}.${contentType}${args || ''}`);15  });16}17function showApiDetails(stationId, stationName) {18  setDialogStationName(stationName);19  setHref('.js-station-info-link',20               `/flood-monitoring/id/stations/${stationId}`);21  setHref('.js-station-measures-link',22               `/flood-monitoring/id/stations/${stationId}/measures`);23  setHref('.js-station-readings-link',24               `/flood-monitoring/id/stations/${stationId}/readings`,25               '?_limit=100&_sorted&parameter=rainfall');26  setHref('.js-station-readings-today-link',27               `/flood-monitoring/id/stations/${stationId}/readings`,28               '?today&_sorted&parameter=rainfall');29  $('#apiDetailsModal').modal('show');30}31function bindEvents() {32  $('body').on('click', '.js-action-show-api-details', (e) => {33    e.preventDefault();34    const stationId = $(e.target).data('station-id');35    const stationName = $(e.target).data('station-name');36    showApiDetails(stationId, stationName);37  });38}39/**40 * View class that ensures that the modal dialogue that show API details...

Full Screen

Full Screen

AnchorUnitTests.js

Source:AnchorUnitTests.js Github

copy

Full Screen

...22        assertClass('js.dom.Anchor');2324        assertNull(this.el.getHref());25        assertEmpty(this.el.getText());26        assertEquals(this.el, this.el.setHref('http://js-lib.com'));27        assertEquals('http://js-lib.com', this.node.getAttribute('href'));28        this.el.setText('j(s)-lib');29        assertEquals('j(s)-lib', this.node.firstChild.nodeValue);3031        assertAssertion(this.el, 'setHref');32        assertAssertion(this.el, 'setHref', null);33        assertAssertion(this.el, 'setHref', '');34        assertEquals('http://js-lib.com', this.node.getAttribute('href'));3536        $assert.disable();37        this.el.setHref();38        this.el.setHref(null);39        this.el.setHref('');40        assertEquals('http://js-lib.com', this.node.getAttribute('href'));41    }42};
...

Full Screen

Full Screen

is-staging.js

Source:is-staging.js Github

copy

Full Screen

...3  // https://stackoverflow.com/questions/49975981/specify-window-location-for-each-test-file-for-jest4  delete global.window.location;5  global.window = Object.create(window);6  global.window.location = {};7  function setHref(href) {8    window.location.href = href;9  }10  const testStagingDomains = ["yextpages.net", "landingpagespreview.com"];11  beforeEach(() => {12    // Reset window.location.href to the default value in a jest test13    setHref('http://localhost/');14  });15  it('works correctly for default staging domains', () => {16    expect(isStaging()).toBeTruthy();17    setHref('http://localhost:3000/my-local/url');18    expect(isStaging()).toBeTruthy();19    setHref('http://127.0.0.1/my-local/url');20    expect(isStaging()).toBeTruthy()21    setHref('http://breed.office.yext.com/my-local/url');22    expect(isStaging()).toBeTruthy();23  });24  it('can check stagingDomains correctly', () => {25    setHref('https://yextpages.net/angelas-adventure-articles');26    expect(isStaging()).toBeFalsy();27    expect(isStaging(testStagingDomains)).toBeTruthy();28    setHref('https://bob.landingpagespreview.com/angelas-adventure-articles');29    expect(isStaging()).toBeFalsy();30    expect(isStaging(testStagingDomains)).toBeTruthy();31  });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.get('#link').then(($a) => {2  const href = $a.prop('href')3  cy.visit(href)4})5cy.get('#link').then(($a) => {6  const href = $a.prop('href')7  $a[0].setAttribute('href', href)8  cy.get('#link').click()9})10cy.get('#link').then(($a) => {11  const href = $a.prop('href')12  $a[0].setAttribute('href', href)13  cy.get('#link').click()14})15cy.get('#link').then(($a) => {16  const href = $a.prop('href')17  $a[0].setAttribute('href', href)18  cy.get('#link').click()19})20cy.get('#link').then(($a) => {21  const href = $a.prop('href')22  $a[0].setAttribute('href', href)23  cy.get('#link').click()24})25cy.get('#link').then(($a) => {26  const href = $a.prop('href')27  $a[0].setAttribute('href', href)28  cy.get('#link').click()29})30cy.get('#link').then(($a) => {31  const href = $a.prop('href')32  $a[0].setAttribute('href', href)33  cy.get('#link').click()34})35cy.get('#link').then(($a) => {36  const href = $a.prop('href')37  $a[0].setAttribute('href', href)38  cy.get('#link').click()39})40cy.get('#link').then(($a) => {41  const href = $a.prop('href')42  $a[0].setAttribute('href', href)43  cy.get('#link').click()44})45cy.get('#link').then(($a) => {46  const href = $a.prop('href')47  $a[0].setAttribute('href', href)48  cy.get('#link').click()49})

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.get('a').each(($a) => {2  const href = $a.prop('href')3  cy.visit(href)4})5cy.get('a').each(($a) => {6  const href = $a.prop('href')7  cy.request(href)8})9cy.get('a').each(($a) => {10  const href = $a.prop('href')11  cy.request(href).then((response) => {12    expect(response.status).to.eq(200)13  })14})15cy.get('a').each(($a) => {16  const href = $a.prop('href')17  cy.request(href).then((response) => {18    expect(response.status).to.eq(200)19    cy.log(response.status)20    cy.log(response.body)21    cy.log(response.headers)22  })23})24cy.get('a').each(($a) => {25  const href = $a.prop('href')26  cy.request(href).then((response) => {27    expect(response.status).to.eq(200)28    cy.log(response.status)29    cy.log(response.body)30    cy.log(response.headers)31    cy.writeFile('log.txt', response.body)32  })33})34cy.get('a').each(($a) => {35  const href = $a.prop('href')36  cy.request(href).then((response) => {37    expect(response.status).to.eq(200)38    cy.log(response.status)39    cy.log(response.body)40    cy.log(response.headers)41    cy.writeFile('log.txt', response.body)42    cy.writeFile('log.txt', response.headers)43  })44})45cy.get('a').each(($a) => {46  const href = $a.prop('href')47  cy.request(href).then((response) => {48    expect(response.status).to.eq(200)49    cy.log(response.status)50    cy.log(response.body)51    cy.log(response.headers)52    cy.writeFile('log.txt', response.body)53    cy.writeFile('log.txt', response.headers)54    cy.writeFile('log.txt', response.status)55  })56})

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add('setHref', { prevSubject: 'element' }, (subject, url) => {2  cy.wrap(subject).invoke('attr', 'href', url);3});4Cypress.Commands.overwrite('setHref', (originalFn, subject, url) => {5  cy.wrap(subject).invoke('attr', 'href', url);6});

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Testing the href attribute of a tag', () => {2    it('href attribute of a tag', () => {3        cy.get('#navbar > .container > .navbar-nav > :nth-child(3) > .nav-link').invoke('attr', 'href').then(href => {4            cy.setHref(href)5        })6    })7})8Cypress.Commands.add('setHref', (href) => {9    cy.get('#navbar > .container > .navbar-nav > :nth-child(3) > .nav-link').invoke('attr', 'href', href)10})

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