fix(i18n): chinese test suite (#38220)
* fix: Chinese test suite Add localeTiltes, descriptions, and adjust test text and testStrings to get the automated test suite working. * fix: ran script, updated testStrings and solutions
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
6a7a7e6d7d
commit
b3213fc892
@ -25,11 +25,11 @@ localeTitle: 给表单添加提交按钮
|
||||
```yml
|
||||
tests:
|
||||
- text: '表单内部应该有一个按钮。'
|
||||
testString: assert($("form").children("button").length > 0, '表单内部应该有一个按钮。');
|
||||
testString: assert($("form").children("button").length > 0);
|
||||
- text: '按钮的<code>type</code>属性值应该为<code>submit</code>。'
|
||||
testString: assert($("button").attr("type") === "submit");
|
||||
- text: '提交按钮的文本应该为<code>提交</code>。'
|
||||
testString: assert($("button").text().match(/^\s*提交\s*$/gi));
|
||||
testString: assert($("button").text().match(/^\s*submit\s*$/gi));
|
||||
- text: '确保按钮有结束标记。'
|
||||
testString: assert(code.match(/<\/button>/g) && code.match(/<button/g) && code.match(/<\/button>/g).length === code.match(/<button/g).length);
|
||||
|
||||
|
@ -35,11 +35,11 @@ localeTitle: 给网站添加图片
|
||||
```yml
|
||||
tests:
|
||||
- text: '网页应该有一张图片。'
|
||||
testString: assert($("img").length > 0);
|
||||
testString: assert($("img").length);
|
||||
- text: '图片 src 属性应该为 https://bit.ly/fcc-relaxing-cat。'
|
||||
testString: assert(/^https:\/\/bit\.ly\/fcc-relaxing-cat$/i.test($("img").attr("src")));
|
||||
- text: '图片必须有<code>alt</code>属性。'
|
||||
testString: assert(code.match(/alt\s*?=\s*?(\"|\').*(\"|\')/));
|
||||
testString: assert($("img").attr("alt") && $("img").attr("alt").length && /<img\S*alt=(['"])(?!\1|>)\S+\1\S*\/?>/.test(code.replace(/\s/g,'')));
|
||||
|
||||
```
|
||||
|
||||
|
@ -32,7 +32,7 @@ tests:
|
||||
- text: '确保每一个注释都以<code>--></code>结尾。'
|
||||
testString: assert(code.match(/[^fc]-->/g).length > 1);
|
||||
- text: '不要更改<code>h1</code>元素、<code>h2</code> 元素、<code>p</code>元素的顺序。'
|
||||
testString: assert((code.match(/<([a-z0-9]){1,2}>/g)[0]==="<h1>" && code.match(/<([a-z0-9]){1,2}>/g)[1]==="<h2>" && code.match(/<([a-z0-9]){1,2}>/g)[2]==="<p>"));
|
||||
testString: assert((code.match(/<([a-z0-9]){1,2}>/g)[0]==="<h1>" && code.match(/<([a-z0-9]){1,2}>/g)[1]==="<h2>" && code.match(/<([a-z0-9]){1,2}>/g)[2]==="<p>") );
|
||||
|
||||
```
|
||||
|
||||
|
@ -31,11 +31,11 @@ tests:
|
||||
- text: '表单应该有三个复选框。'
|
||||
testString: assert($('input[type="checkbox"]').length > 2);
|
||||
- text: '每个复选框都应该被嵌套进<code>label</code>元素中。'
|
||||
testString: 'assert($(''label > input[type="checkbox"]:only-child'').length > 2);'
|
||||
testString: assert($('label > input[type="checkbox"]:only-child').length > 2);
|
||||
- text: '确保<code>label</code>元素有结束标记。'
|
||||
testString: assert(code.match(/<\/label>/g) && code.match(/<label/g) && code.match(/<\/label>/g).length === code.match(/<label/g).length);
|
||||
- text: '设置复选框的<code>name</code>属性均为<code>personality</code>。'
|
||||
testString: assert($('label > input[type="checkbox"]').filter("[name='personality']").length > 2);
|
||||
testString: assert($('label > input[type="checkbox"]').filter('[name="personality"]').length > 2);
|
||||
- text: '每个复选框都应该在 <code>form</code> 标签内。'
|
||||
testString: assert($('label').parent().get(0).tagName.match('FORM'));
|
||||
|
||||
|
@ -44,9 +44,9 @@ tests:
|
||||
- text: '页面上应该有两个单选按钮元素。'
|
||||
testString: assert($('input[type="radio"]').length > 1);
|
||||
- text: '设置单选按钮的<code>name</code>属性为<code>indoor-outdoor</code>。'
|
||||
testString: assert($('label > input[type="radio"]').filter("[name='indoor-outdoor']").length > 1);
|
||||
testString: assert($('input[type="radio"]').filter("[name='indoor-outdoor']").length > 1);
|
||||
- text: '每一个单选按钮都应该嵌套进它自己的<code>label</code>元素中。'
|
||||
testString: 'assert($(''label > input[type="radio"]:only-child'').length > 1);'
|
||||
testString: assert($('label > input[type="radio"]:only-child').length > 1);
|
||||
- text: '每一个<code>label</code>元素都有结束标记。'
|
||||
testString: assert((code.match(/<\/label>/g) && code.match(/<label/g) && code.match(/<\/label>/g).length === code.match(/<label/g).length));
|
||||
- text: '其中一个<code>label</code>元素的文本为<code>indoor</code>。'
|
||||
|
@ -35,9 +35,9 @@ HTML 有一个特定的元素用于创建有序列表<code>ordered lists(缩
|
||||
```yml
|
||||
tests:
|
||||
- text: '页面应该有一个无序列表,内容是猫咪最喜欢的三件东西。'
|
||||
testString: assert((/猫咪最喜欢的三件东西:/i).test($("ul").prev().text()));
|
||||
testString: assert((/Top 3 things cats hate:/i).test($("ol").prev().text()));
|
||||
- text: '页面应该有一个有序列表,内容是猫咪最讨厌的三件东西。'
|
||||
testString: assert((/猫咪最讨厌的三件东西:/i).test($("ol").prev().text()));
|
||||
testString: assert((/Things cats love:/i).test($("ul").prev().text()));
|
||||
- text: '页面应该只有一个<code>ul</code>元素。'
|
||||
testString: assert.equal($("ul").length, 1);
|
||||
- text: '页面应该只有一个<code>ol</code>元素。'
|
||||
|
@ -48,7 +48,7 @@ tests:
|
||||
- text: '<code>title</code>应该是<code>head</code>的子元素。'
|
||||
testString: assert(code.match(/<head>\s*?<title>\s*?.*?\s*?<\/title>\s*?<\/head>/gi));
|
||||
- text: '<code>h1</code>和<code>p</code>都应该是<code>body</code>的子元素。'
|
||||
testString: assert($('body').children('h1').length == 1 && $('body').children('p').length == 1);
|
||||
testString: assert(code.match(/<body>\s*?(((<h1>\s*?.*?\s*?<\/h1>\s*?)(<p>(.*\s*)*?<\/p>\s*?))|((<p>\s*?.*?\s*?<\/p>\s*?)(<h1>(.*\s*)*?<\/h1>\s*?)))<\/body>/gi));
|
||||
|
||||
```
|
||||
|
||||
|
@ -24,11 +24,11 @@ localeTitle: 删除 HTML 元素
|
||||
```yml
|
||||
tests:
|
||||
- text: '删除<code>h1</code>元素。'
|
||||
testString: assert(($("h1").length == 0));
|
||||
testString: assert(!code.match(/<h1>/gi) && !code.match(/<\/h1>/gi));
|
||||
- text: '保留<code>h2</code>元素。'
|
||||
testString: assert(($("h2").length > 0));
|
||||
testString: assert(code.match(/<h2>[\w\W]*<\/h2>/gi));
|
||||
- text: '保留<code>p</code>元素。'
|
||||
testString: assert(($("p").length > 0));
|
||||
testString: assert(code.match(/<p>[\w\W]*<\/p>/gi));
|
||||
|
||||
```
|
||||
|
||||
|
@ -29,7 +29,7 @@ tests:
|
||||
- text: '<code>h2</code>元素应该有结束标记。'
|
||||
testString: assert(code.match(/<\/h2>/g) && code.match(/<\/h2>/g).length === code.match(/<h2>/g).length);
|
||||
- text: '<code>h2</code>元素的内容应为:<code>CatPhotoApp</code>。'
|
||||
testString: assert.isTrue((/CatPhotoApp/gi).test($("h2").text()));
|
||||
testString: assert.isTrue((/cat(\s)?photo(\s)?app/gi).test($("h2").text()));
|
||||
- text: '<code>h1</code>元素的内容应为:<code>Hello World</code>。'
|
||||
testString: assert.isTrue((/hello(\s)+world/gi).test($("h1").text()));
|
||||
|
||||
|
@ -36,11 +36,11 @@ HTML5 引入了很多更具描述性的 HTML 元素,例如:<code>header</cod
|
||||
```yml
|
||||
tests:
|
||||
- text: '页面中应该有两个段落。'
|
||||
testString: assert($("p").length > 1, '页面中应该有两个段落。');
|
||||
testString: assert($("p").length > 1);
|
||||
- text: '确保每个段落都有结束标记。'
|
||||
testString: assert(code.match(/<\/p>/g) && code.match(/<\/p>/g).length === code.match(/<p/g).length);
|
||||
- text: '新建的段落应该包含关键词:猫咪。'
|
||||
testString: assert.isTrue((/猫咪/).test($("p").text()));
|
||||
testString: assert.isTrue((/Purr\s+jump\s+eat/gi).test($("p").text()));
|
||||
- text: '代码中应该包含<code>main</code>元素。'
|
||||
testString: assert($('main').length === 1);
|
||||
- text: '<code>main</code>元素应有两个 <code>p</code>元素作为它的子元素。'
|
||||
|
@ -28,7 +28,7 @@ tests:
|
||||
- text: '<code>a</code>元素的 <code>a</code> 文本应为:<code>cat photos</code>。'
|
||||
testString: assert((/cat photos/gi).test($("a").text()));
|
||||
- text: '<code>a</code>元素的<code>href</code>属性应为:"<code>http://freecatphotoapp<wbr>.com</code>"。'
|
||||
testString: 'assert(/http:\/\/(www\.)?freecatphotoapp\.com/gi.test($("a").attr("href")));'
|
||||
testString: assert(/http:\/\/(www\.)?freecatphotoapp\.com/gi.test($("a").attr("href")));
|
||||
- text: '确保<code>a</code>元素有结束标记。'
|
||||
testString: assert(code.match(/<\/a>/g) && code.match(/<\/a>/g).length === code.match(/<a/g).length);
|
||||
|
||||
|
@ -39,15 +39,15 @@ localeTitle: 将 a 嵌套在段落中
|
||||
```yml
|
||||
tests:
|
||||
- text: '你需要一个指向 "http://freecatphotoapp.com" 的 <code>a</code> 。'
|
||||
testString: 'assert(($("a[href=\"http://freecatphotoapp.com\"]").length > 0 || $("a[href=\"http://www.freecatphotoapp.com\"]").length > 0));'
|
||||
testString: assert(($("a[href=\"http://freecatphotoapp.com\"]").length > 0 || $("a[href=\"http://www.freecatphotoapp.com\"]").length > 0));
|
||||
- text: '<code>a</code> 的文本应为:cat photos。'
|
||||
testString: assert($("a").text().match(/cat\sphotos/gi));
|
||||
- text: '在 <code>a</code> 的外部创建一个新段落,这样页面就有 3 个段落了。'
|
||||
testString: assert($("p") && $("p").length > 2);
|
||||
- text: '<code>a</code> 应嵌套在新段落内。'
|
||||
testString: 'assert(($("a[href=\"http://freecatphotoapp.com\"]").parent().is("p") || $("a[href=\"http://www.freecatphotoapp.com\"]").parent().is("p")));'
|
||||
testString: assert(($("a[href=\"http://freecatphotoapp.com\"]").parent().is("p") || $("a[href=\"http://www.freecatphotoapp.com\"]").parent().is("p")));
|
||||
- text: '段落应该包含文本 View more(记得 more 后面有一个空格)。'
|
||||
testString: 'assert(($("a[href=\"http://freecatphotoapp.com\"]").parent().text().match(/View\smore\s/gi) || $("a[href=\"http://www.freecatphotoapp.com\"]").parent().text().match(/View\smore\s/gi)));'
|
||||
testString: assert(($("a[href=\"http://freecatphotoapp.com\"]").parent().text().match(/View\smore\s/gi) || $("a[href=\"http://www.freecatphotoapp.com\"]").parent().text().match(/View\smore\s/gi)));
|
||||
- text: '<code>a</code> 不应该包含文本 View more。'
|
||||
testString: assert(!$("a").text().match(/View\smore/gi));
|
||||
- text: '确保每个段落有结束标记。'
|
||||
|
@ -30,7 +30,7 @@ HTML 是英文 Hyper Text Markup Language(超文本标记语言)的缩写。
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>h1</code>元素的内容应该为:<code>Hello World</code>。'
|
||||
testString: assert.isTrue((/^hello(\s)+world$/gi).test($('h1').text()));
|
||||
testString: assert.isTrue((/hello(\s)+world/gi).test($('h1').text()));
|
||||
|
||||
```
|
||||
|
||||
|
@ -31,7 +31,7 @@ tests:
|
||||
- text: '确保网页中能看到<code>p</code>元素。'
|
||||
testString: assert($("p").length > 0);
|
||||
- text: '确保删除了注释的结束标记<code>--></code>。'
|
||||
testString: assert(!/[^fc]-->/gi.test(code.replace(/ *<!--[^fc]*\n/g,'')));
|
||||
testString: assert(!$('*:contains("-->")')[1]);
|
||||
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user