我是单元测试的新手,我想用方法测试一个组件,在这个方法中,我使用this.random函数,jQuery和Jest。
我想测试是否调用了openPost方法?
当我得到一个测试时,它会抛出错误this.$ is not a function和this.random is not a function。
我怎么写测试?
构成部分:
<template>
<div @click="openPost('note')" class="ml-3 text-center pointer noteBtn">
<
我有两组职能:
$(document).ready(function() {
var id = $(this).attr('id');
// First group of functions
getCountry(id);
// Second group of functions
getResult(id, 'all');
});
在每个组中,函数是Ajax调用并链接在一起。这意味着首先运行getCountry()并在success Ajax属性上调用getRegion(),然后getRegion()调
第二个功能不起作用。它没有收到从第一个函数传递的id。
这是我的JQuery代码。
swal({
title: "Are you sure?",
text: "You will not be able to recover this record!",
type: "warning",
showCancelButton: true,
confirmButtonClass: "btn-danger",
confirmButtonText: "Yes, delete it!
我将SVG数据svgData作为字符串从服务器获得。
这将返回(例如,我正在使用的.svg )62个路径:
var svgPath = $(svgData).find('[class*="style"]');
使用以下代码,我将重新计算SVG的笔画大小:
for (var i = 0; i < svgPath.length; ++i) {
oldStrokeWidth.push(jQuery(svgPath[i]).css('stroke-width').replace(/[^-\d.]/g, ''));
var n