What does the quot;itquot; function do in this code?(“它是什么意思?这段代码中的功能是什么?)
问题描述
我希望有人可以向我解释它"在 AngularJS 或纯 JavaScript 中的作用(用于)什么(我不确定它是否特定于 Angular).事实证明,这对谷歌来说是一件困难的事情,被命名为它"等等.我已经看到它在整个 AngularJS 文档中使用.我会给你一个来自 ngShow 页面的例子(它是隐藏/显示包含大拇指或大拇指向下).
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();
});
推荐答案
参见 Jasmine 测试框架.
it(...)
函数定义了一个测试用例(又名规范").
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.
这篇关于“它"是什么意思?这段代码中的功能是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:“它"是什么意思?这段代码中的功能是什么


基础教程推荐
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01