“它”是什么?函数在这段代码中做什么? [英] What does the "it" function do in this code?

查看:116
本文介绍了“它”是什么?函数在这段代码中做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有人可以向我解释一下AngularJS中的它(用于)或者只是普通的JavaScript(我不确定它是否特定于Angular)。事实证明,这对谷歌来说是一件困难的事情,被命名为它和所有。我已经看到它在整个AngularJS文档中使用过。我将从 ngShow 页面给出一个示例(隐藏/显示包含a的div的代码竖起大拇指或竖起大拇指)。

I'm hoping somebody could explain to me what "it" does (is used for) in AngularJS or just plain JavaScript (I'm not sure if it's specific to Angular). This, turns out, is a difficult thing to Google for, being named "it" and all. I've seen it used throughout the AngularJS docs. I'll give you an example from the ngShow page (it's code to hide/show a div containing a thumbs up or thumbs down).

var thumbsUp = element(by.css('span.glyphicon-thumbs-up'));
var thumbsDown = element(by.css('span.glyphicon-thumbs-down'));

it('should check ng-show / ng-hide', function() {
  expect(thumbsUp.isDisplayed()).toBeFalsy();
  expect(thumbsDown.isDisplayed()).toBeTruthy();

  element(by.model('checked')).click();

  expect(thumbsUp.isDisplayed()).toBeTruthy();
  expect(thumbsDown.isDisplayed()).toBeFalsy();
});


推荐答案

参见茉莉花测试框架



it(...)函数定义了一个测试用例(又名spec)。

See the Jasmine testing framework.

The it(...) function defines a test case (aka a "spec").

describe("A suite", function() {
  it("contains spec with an expectation", function() {
    expect(true).toBe(true);
  });
});

请注意 AngularJS E2E测试 ...


...使用Jasmine作为测试语法。

... uses Jasmine for its test syntax.

这篇关于“它”是什么?函数在这段代码中做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆