我正在为流星写一个噩梦写单元测试.有太多旧的,过时的文章和太少的清晰,相关的文档,以便我能够找出实际需要做的事情来实现这一点.
我遇到了问题之后的问题,并且真的希望有人可以告诉我他们如何为我的一种方法编写测试,这样我就可以看到他们做了什么,并为我的其余方法进行逆向工程.
这是我想为以下方法编写测试的方法:
Meteor.methods({
'client.new':( clientDetails ) => {
check( clientDetails, {
name: String,
numberTeamMembers: String
});
clientDetails.teamMembers = [];
if(!Meteor.userId() || !Roles.userIsInRole(Meteor.userId(), 'administrator')) {
throw new Meteor.Error('500', 'You are not authorised to do this.');
}
if(Clients.findOne({ name: clientDetails.name})) {
throw new Meteor.Error('500', 'This client name already exists!');
};
return Clients.insert(clientDetails);
},
});
Run Code Online (Sandbox Code Playgroud)
到目前为止,我有以下内容:
import { Meteor } from 'meteor/meteor';
import { expect, be } from 'meteor/practicalmeteor:chai';
import { describe, it, before } from 'meteor/practicalmeteor:mocha';
import { resetDatabase } from …Run Code Online (Sandbox Code Playgroud) 我有以下monorepo结构
root
--AppOne
----package.json
----node_modules
------styled-components
--AppTwo
----package.json
----node_modules
------styled-components
--Shared
----componentA
----package.json
----node_modules
------styled-components
Run Code Online (Sandbox Code Playgroud)
我的问题是AppOne和AppTwo都componentA在shared目录中使用a ,并且它取决于NPM软件包,例如styled-components
这意味着我需要styled-components在所有三个目录中进行安装,这会增加捆绑包的大小,如果版本不同,则可能会导致软件包执行应做的问题。
这也意味着我收到以下错误消息styled-components:
It looks like there are several instances of 'styled-components' initialized in this application.
This may cause dynamic styles not rendering properly, errors happening during rehydration process and makes your application bigger without a good reason.
我的问题是-解决这种情况的最佳方法是什么?理想情况下,我只希望将此软件包安装在一个地方。我应该在其中安装Shared别名AppOne并AppTwo在其中使用别名并使用该软件包吗?
任何建议,不胜感激!
我正在构建一个基于日历的应用程序,其中日历中有事件。事件可以重复发生(每日、每周、每月、每季度、每两年和每年)。
每个事件文档都有一个默认值name,defaultDate并且还包含与每个用户 ( , )关联的对象description数组 ( ) 。尽管事件是集中的,但某些用户有自己的事件,这不是默认事件,每个用户都可以为事件设置自己的事件。这就是该对象存在的原因。userDatauserDateuserDescriptionuserDateuserDescriptionuserData
澄清一下,事件文档看起来像这样:
{
_id: '1234567',
name: 'Event One',
description: 'This is the default description',
defaultDate: '2017-02-15T12:00:00.000Z',
userData: [
{
userId: '8765432',
userDate: '2017-06-10T12:00:00.000Z',
userDescription: 'My personalised description',
},
{
userId: '461938',
userDate: '2017-03-21T12:00:00.000Z',
userDescription: 'I have a description too!',
},
]
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试找出处理这些事件创建时的重复存储的最佳方法。编辑事件时,还需要编辑该事件的所有其他副本。永远不会出现需要编辑单个事件但重复事件保持不变的情况。
创建事件时,我有一个 HTML 选择,询问事件是否重复发生,并具有以下选项:无、每日、每周、每月、每季度、每两年、每年
如果有人可以建议创建这些事件的重复副本的最佳方法,我将不胜感激!
我有一个使用flexbox构建的布局,但有一个方面我似乎无法开始工作.
我有面板,其中有锚标签,我想垂直和水平居中,但我希望锚标签是面板宽度和高度的100%,这样当你点击面板中的任何地方它会链接你,而不是单击链接文本.
这是面板的HTML:
<div class="panel--link panel--one">
<a href="#" class="link">
Panel 1
</a>
</div>
Run Code Online (Sandbox Code Playgroud)
和SCSS:
.panel {
box-sizing: content-box;
flex: 1;
border: 3px solid #fff;
padding: 0px;
text-align: center;
}
.panel--link {
@extend .panel;
display: flex;
flex: 1;
justify-content: center;
align-items: center;
a.link {
text-decoration: none;
color: #fff;
text-transform: uppercase;
font-weight: 600;
font-size: 1rem;
letter-spacing: 3px;
flex: 1;
}
}
Run Code Online (Sandbox Code Playgroud)
请参阅我的Codepen了解整个布局,以便您更好地理解它!
http://codepen.io/zauber/pen/BpRJQG
谢谢您的帮助
我有一个 Meteor 应用程序,我使用预签名 URL 从 S3 下载文件(需要通过 API 调用生成)。
我遇到了弹出窗口拦截器的问题,阻止使用 AWS-SDK 生成的 url 打开新选项卡,因此我将代码更改为以下内容:
downloadDocument(document, event) {
// open tab immediately to prevent popup blocker
const myNewTab = window.open();
// call method to generate url
Meteor.call('Events.Methods.Document.Download', { key: document.key, eventId: event._id }, (error, res) => {
if (error) { ... } // removed handle error code
// if url generated, set tab location to url
if (res) myNewTab.location.href = res;
// auto close the tab after 1 second
myNewTab.setTimeout(() => …Run Code Online (Sandbox Code Playgroud)