我使用的是@coreui/react与React-select问题是,返回Select的元素scoped slots符core-ui的功能就像搜索和排序
但是,如果在返回带有文本Ex 的a<label>或 a时它工作正常:<p><label>{item.status}</label>
题
为什么 Select 组件会破坏功能?
任何解决方法/努力都受到高度赞赏
笔记
我尝试过类似的解决方法<p hidden >{item.status}</p>,然后渲染Select组件,但它不起作用
import React from "react";
import Select from "react-select";
import { CDataTable } from "@coreui/react";
...
<CDataTable
bordered
clickableRows
fields={fields}
hover
items={[...employeeData]}
itemsPerPage={10}
itemsPerPageSelect
loading={tableLoader}
onRowClick={(e) => rowSelectHandler(e)}
pagination
size="sm"
sorter={{ resetable: true }}
striped
tableFilter={{
placeholder: "Filter",
label: "Search:",
}}
scopedSlots={{
status: (item, …Run Code Online (Sandbox Code Playgroud) 我想更改内部方法的实现jest.mock,以便我可以检查我的应用程序对不同边缘情况的反应,所以我这样做了,但是打字稿不允许我模拟firebase.auth().currentUser方法...我在下面显示我的代码和错误
应用程序.js
\n\nimport firebase from 'firebase/app'\nimport 'firebase/auth'\nimport './Init'\n\nconst App = {\ngetLoggedInUser: () => {\n const currentUser = firebase.auth().currentUser\n if (currentUser) {\n return {\n email: firebase.auth().currentUser.email,\n userId: firebase.auth().currentUser.uid,\n isEmailVerified: firebase.auth().currentUser.emailVerified\n }\n } else {\n return undefined\n }\n },\n isAuthenticated: () => {\n return !!((App.getLoggedInUser() && App.getLoggedInUser().isEmailVerified === true))\n },\n}\nexport default App\nRun Code Online (Sandbox Code Playgroud)\n\n应用程序规范
\n\nimport myAuthenticationPlugin from 'authenticationPlugin/App'\nimport firebase from 'firebase/app'\n\njest.mock('firebase/app', () => {\n const userCredentialMock = {\n user: {\n sendEmailVerification: jest.fn()\n }\n }\n return …Run Code Online (Sandbox Code Playgroud) javascript unit-testing typescript jestjs firebase-authentication
我已经filesystem使用multer
我的服务器是node,客户端是react.
我在客户端下载和显示保存的文件时遇到问题 react
每当我这样做时,res.download(file)都会因为客户端拒绝连接而引发错误。
我的代码如下:
用户上传映射.js
const mongoose = require("mongoose");
const UserToUploadMapping = new mongoose.Schema({
userId: {
type:String,
required:true
},
file: {
type: Object,
required: true,
},
date: {
type: Date,
default: Date.now,
},
});
module.exports = mongoose.model("UserToUploadMapping", UserToUploadMapping);
Run Code Online (Sandbox Code Playgroud)
上传视频.js
const router = require("express").Router();
const multer = require('multer');
const UserToUploadMapping = require('../models/UserToUploadMapping')
let nameFile = ''
const storage = multer.diskStorage({
destination:'./Videos',
filename:(req,file,cb) => {
console.log(file)
nameFile = file.originalname + " …Run Code Online (Sandbox Code Playgroud) 我正在使用Javascript并与我的应用程序Vue集成firebase
场景(已搭建)
sign in用户登录的页面emailVerified属性中签名的用户应为 true问题
firebase.auth().createUserWithEmailAndPassword(email, password)方法时发送验证电子邮件报名方式
signup: async (email, password) => {
const user = await firebase.auth().createUserWithEmailAndPassword(email, password)
await user.user.sendEmailVerification()
return `Check your email for verification mail before logging in`
},
Run Code Online (Sandbox Code Playgroud)
所需的解决方案
我从 firebase console
我email作为参数传递或uid该方法应该向用户发送验证电子邮件,以便他们可以验证他们的电子邮件
完全废弃该signup方法,因为我不再需要它来发送验证邮件
无论如何,是否可以在不登录的情况下发送验证电子邮件?
这是我当前的模拟,我想createUserWithEmailAndPassword返回firebase.auth.UserCredential,这样我就可以测试它是否在我的中被调用App.ts
应用程序规范
import myAuthenticationPlugin from 'authenticationPlugin/App'
import firebase from 'firebase/app'
jest.mock('firebase/app', () => {
return {
auth: jest.fn().mockReturnThis(),
currentUser: {
email: 'test',
uid: '123',
emailVerified: true
},
signInWithEmailAndPassword: jest.fn(),
createUserWithEmailAndPassword:jest.fn(() => {
return {
user:{
sendEmailVerification:jest.fn(),
},
}
}),
initializeApp:jest.fn()
};
});
describe('Test for signup (email,password)',() => {
it('createUserWithEmailAndPassword ()',async () => { //this works
await myAuthenticationPlugin.signup(email, password)
expect(firebase.auth().createUserWithEmailAndPassword).toBeCalledWith(email, password)
})
it('sendEmailVerification()',async ()=>{
await myAuthenticationPlugin.signup(email, password)
const userCredential= await firebase.auth().createUserWithEmailAndPassword(email,password)
if(userCredential.user!=null){
expect(userCredential.user.sendEmailVerification).toBeCalled() //this fails as …Run Code Online (Sandbox Code Playgroud) 如何将set只有值的对象转换为键值对包含相同值的对象key?
let set = new Set()
set.add(a)
set.add(example)
console.log(set)
//OUTPUT {"a", "example"}
//perform some operation to get result below ?
Run Code Online (Sandbox Code Playgroud)
到
{"a":"a","example":"example"}
javascript ×6
firebase ×2
jestjs ×2
typescript ×2
unit-testing ×2
core-ui ×1
express ×1
mongoose ×1
multer ×1
node.js ×1
react-select ×1
reactjs ×1
vue.js ×1