小编EFO*_*FOE的帖子

使用 vue-test-util 更改 v-select 的选定选项

我正在尝试测试使用 vuetify 构建的组件。为此,我正在使用 vue-test-utils。我的目标是在 v-select 字段中执行更改,并断言执行了突变。这是我的代码:

<div id="app">
  <v-app id="inspire">
    <v-container fluid>
      <v-layout row wrap>
        <v-flex xs6>
          <v-subheader>Standard</v-subheader>
        </v-flex>
        <v-flex xs6>
          <v-select
            :items="items"
            v-model="e1"
            label="Select"
            single-line
          ></v-select>
        </v-flex>
      </v-layout>
    </v-container>
  </v-app>
</div>
Run Code Online (Sandbox Code Playgroud)

当我设置数据时,第一次测试没问题:

componentWrapper.setData({items: storesList})
expect(componentWrapper.vm.$data.items).toHaveLength(2)
Run Code Online (Sandbox Code Playgroud)

我现在想更改我尝试的选定值:

componentWrapper.findAll('#option').at(1).setSelected()
Run Code Online (Sandbox Code Playgroud)

并且

componentWrapper.find('el-select')
Run Code Online (Sandbox Code Playgroud)

有人可以帮我检索选择然后更改所选值吗?谢谢您的支持。

vuetify.js vue-test-utils

7
推荐指数
2
解决办法
1万
查看次数

如何使用 vavr 返回 void 或字符串

我有一个函数,当某些条件不满足时,它应该不返回任何内容( void )或字符串。

我尝试这条线 Either.left(Void)

    private Either<Void,String> processOrReturnErrorMessage(){
        //Do something  and in some case return a message of failed conditions
        return Either.left(Void);
    }
Run Code Online (Sandbox Code Playgroud)

java vavr

5
推荐指数
1
解决办法
5648
查看次数

在 vertx 上使用 httpclient 时出错

您好,我正在尝试使用下面的代码对远程资源执行休息调用。在 vertx 3.3.3 上它与 defaulthttpclient (appache) 一起工作,但它不是异步的

我仍然收到错误:nov。2016 年 1 月 1 日上午 8:15:08 io.vertx.core.http.impl.HttpClientRequestImpl 严重:java.net.ConnectException:连接被拒绝:localhost/127.0.0.1:80

final HttpClient httpClient = vertx.createHttpClient();

        final HttpGet getRequest = new HttpGet(uri);

        httpClient.request(apiMethod.getHttpMethod(), uri, resultHandler -> {
            resultHandler.statusCode();
            if (resultHandler.statusCode() == 200) {
                environment.setStatus(ApiStatus.OK);
                apiMethod.setStatus(ApiStatus.OK);
            } else {
                environment.setStatus(ApiStatus.ERROR);
                apiMethod.setStatus(ApiStatus.ERROR);
            }
            resultHandler.bodyHandler(buffer -> {
                String message = "";
                logger.debug("Output from Server .... \n");
                logger.debug(buffer);
                message = buffer.toString();
                apiMethod.setCallingDate(new Date());
                apiMethod.setCallingResult(message);
            });
        }).putHeader("content-type", "application/json").end();
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮忙吗?

此致,

java rest networking vert.x

2
推荐指数
1
解决办法
2922
查看次数

如何根据选项值获得左/右

我正在尝试Either根据选项值返回值。我的目标是如果该选项存在则返回Either.right(),否则代码应返回Either.left()。我使用 Java 8 和 vavr 0.9.2

我想避免有条件的叠瓦

public Either<String, Integer> doSomething() {
    Optional<Integer> optionalInteger = Optional.of(Integer.MIN_VALUE);
    Option<Integer> integerOption = Option.ofOptional(optionalInteger);

    return integerOption.map(value -> {
      //some other actions here
      return Either.right(value);
    }).orElse(() -> {
      //some other checks her also 
      return Either.left("Error message");
    });
}
Run Code Online (Sandbox Code Playgroud)

编译器失败并显示此消息

Error:(58, 7) java: no suitable method found for orElse(()->Either[...]age"))
    method io.vavr.control.Option.orElse(io.vavr.control.Option<? extends io.vavr.control.Either<java.lang.Object,java.lang.Integer>>) is not applicable
      (argument mismatch; io.vavr.control.Option is not a functional interface
          multiple non-overriding abstract methods found in interface io.vavr.control.Option)
    method io.vavr.control.Option.orElse(java.util.function.Supplier<? …
Run Code Online (Sandbox Code Playgroud)

java either vavr

2
推荐指数
1
解决办法
1839
查看次数

标签 统计

java ×3

vavr ×2

either ×1

networking ×1

rest ×1

vert.x ×1

vue-test-utils ×1

vuetify.js ×1