在过去的几周里,我一直在学习React,Babel,Semantic UI和Jest.我没有真正遇到太多问题,我的组件没有在浏览器中呈现,但我在使用Jest编写单元测试时遇到了渲染问题.
SUT如下:
EditUser.jsx
var React = require('react');
var { browserHistory, Link } = require('react-router');
var $ = require('jquery');
import Navigation from '../Common/Navigation';
const apiUrl = process.env.API_URL;
const phoneRegex = /^[(]{0,1}[0-9]{3}[)]{0,1}[-\s\.]{0,1}[0-9]{3}[-\s\.]{0,1}[0-9]{4}$/;
var EditUser = React.createClass({
getInitialState: function() {
return {
email: '',
firstName: '',
lastName: '',
phone: '',
role: ''
};
},
handleSubmit: function(e) {
e.preventDefault();
var data = {
"email": this.state.email,
"firstName": this.state.firstName,
"lastName": this.state.lastName,
"phone": this.state.phone,
"role": this.state.role
};
if($('.ui.form').form('is valid')) {
$.ajax({
url: apiUrl + …Run Code Online (Sandbox Code Playgroud) 基本上,我需要一种方法为我的应用程序注入环境变量,因为我不想将.env文件检入我的仓库.我希望运行类似的东西API_URL=api.example.com npm run build,但看起来你不能在任务命令之前添加前缀.
有没有办法做到这一点,还是有更好的方法为Azure中托管的节点应用程序创建环境变量?
我正在尝试使用 akka 流来流式传输文件,并且遇到了将流的结果提取到 Future[String] 中的小问题:
def streamMigrationFile(source: Source[ByteString, _]): Future[String] = {
var fileString = ""
val sink = Sink.foreach[ByteString](byteString => fileString =
fileString.concat(byteString.decodeString("US-ASCII")))
source.runWith(sink)
}
Run Code Online (Sandbox Code Playgroud)
我收到编译错误:
Expression of type Future[Done] does not conform to expected type Future[String]
Run Code Online (Sandbox Code Playgroud)
谁能帮助我理解我做错了什么以及我需要做什么来提取流的结果?
我正在使用 JUnit 和 JMockit 创建一个单元测试方法,用于测试 CSV 文件的创建和操作。如何拦截正在创建的文件以确保正确创建?
@Test
public void testPersistResultsAsCSV() throws IOException {
final Long id = new Long(1234l);
TableRow row = new TableRow();
row.setValue(317l);
row.setId(1234l);
final List<TableRow> rows = new ArrayList<TableRow>();
rows.add(row);
final List<TableRow> empty = new ArrayList<TableRow>();
new Expectations() {
{
tableService.findTableRowsById(id, (TableQueryOptions)any);
result = rows;
tableService.findTableRowsById(id, (TableQueryOptions)any);
result = empty;
fileDataService.saveResultsFile((ResultsFile) any);
}
};
resultsToCsvService.persistResultsAsCSV(id);
}
Run Code Online (Sandbox Code Playgroud) akka ×1
akka-http ×1
akka-stream ×1
azure-devops ×1
babeljs ×1
java ×1
jestjs ×1
jmockit ×1
jquery ×1
junit ×1
node.js ×1
npm ×1
reactjs ×1
scala ×1
semantic-ui ×1
unit-testing ×1