小编hen*_*ick的帖子

如何在angular2中使用谓词

我已经创建了一个登录页面angular2.它有两个输入字段as userNamepassword.登录中有一个按钮.当我打算为此编写测试用例时loginComponent,不得不predicate用来识别button.这是我的测试用例.

import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { LoginComponent } from './login.component';


export class LoginComponentTest {
  constructor(public loginComponent: LoginComponent){
    this.loginComponent.logIn('Chathura', '1234');

  }
}

describe('LoginComponent', () => {
  beforeEach(() => {
    TestBed.configureTestingModule({
      declarations: [
        LoginComponent
      ],
    })
  });

  const fixture = TestBed.createComponent(LoginComponent);

  const button = fixture.query(predicate: Predicate<DebugElement>, scope?: Function) : DebugElement

});
Run Code Online (Sandbox Code Playgroud)

我将通过提供输入值进行测试,然后单击登录按钮,看看接下来会发生什么.

我无法找到正确使用谓词的正确教程.

testing typescript karma-jasmine angular

9
推荐指数
1
解决办法
2042
查看次数

Consul键值对用于Spring-boot中的配置

我试图将我的注册服务器从"Eureka"更改为"Consul",并将Consul更改为我的配置服务器.使用Consul进行服务发现是成功的.但我无法理解如何获取键/值对选项来引导我的应用程序.我有可能做到这一点吗?

我使用具有以下依赖性的弹簧靴

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-consul-config</artifactId>
</dependency>
<dependency>
        <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)

这是我的春季启动应用程序ConsuleDemoApplication.class

@EnableDiscoveryClient
@SpringBootApplication
@RestController
public class ConsuleDemoApplication {

    @RequestMapping("/")
    public String home() {
        return "Hello world";
    }

    public static void main(String[] args) {
        SpringApplication.run(ConsuleDemoApplication.class, args);
    }
}
Run Code Online (Sandbox Code Playgroud)

和我的bootstrap.yml是

spring:
  cloud:
    consul:
      discovery:
        healthCheckInterval: 15s
        instanceId: ${spring.application.name}:${spring.application.instance_id:${random.value}}

  application:
    name: consul_demo
Run Code Online (Sandbox Code Playgroud)

configuration spring-boot consul microservices spring-cloud-consul

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

docker-compose与nginx无法正常工作

这是我的docker-compose.yml

version: '2' 

services: 

nginx:

image: nginx:1.11.8-alpine
ports:
  - "8081:80"
volumes:
  - ./code:/usr/share/nginx/html
  - ./html:/myapp
  - ./site.conf:/etc/nginx/conf.d/site.conf
  - ./error.log:/var/log/nginx/error.log
  - ./nginx.conf:/etc/nginx/nginx.conf
Run Code Online (Sandbox Code Playgroud)

这是site.conf

server {

   listen 8081;
   index index.html index.php;
   server_name localhost;
   error_log  /var/log/nginx/error.log;

   location /html {
       root /myapp;
   }
}
Run Code Online (Sandbox Code Playgroud)

http://nginx-php-docker.local:8081 /这是工作,显示文件index.html里面/代码文件夹

但它无法使用http://nginx-php-docker.local:8081/html

错误日志是:2017/01/13 08:50:27 [错误] 7#7:*4打开()"/ usr/share/nginx/html/html"失败(2:没有这样的文件或目录),客户端:172.19.0.1,server:localhost,request:"GET/html HTTP/1.1",host:"nginx-php-docker.local:8081"

请告诉我哪里错了.

nginx docker alpine-linux

0
推荐指数
1
解决办法
7840
查看次数