间谍一个类变量

时间:2016-10-20 20:41:14

标签: angular angular2-testing

我有一个func makeRequest(request: URLRequest)->String{ let task = URLSession.shared.dataTask(with: request){data, response, error in guard let data = data, error == nil else{ print("error=\(error)") return } if let httpStatus = response as? HTTPURLResponse, httpStatus.statusCode != 200 { // check for http errors print("statusCode should be 200, but is \(httpStatus.statusCode)") print("response = \(response)") } print (data) do { let json = try JSONSerialization.jsonObject(with: data, options: .allowFragments) print(json) } catch { print("error serializing JSON: \(error)") } //print("responseString = \(responseString)") } task.resume() return "Something"//i need to return the json as String } 元素附加了一个<div>事件,它会切换一些类变量,如下所示:

(click)

首先测试点击事件我必须通过CSS类抓取<div (click)="some-variable-name = !some-variable-name"></div> 事件,如下所示:

div

有没有办法可以监视类变量let some-var = fixture.debugElement.query(By.css('.css-class-name')); 并检查测试时是否更改了click事件,如下所示:

some-variable-name

0 个答案:

没有答案