Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 8e32f98

Browse files
committed
refactor the tests
1 parent 314c8b9 commit 8e32f98

File tree

2 files changed

+58
-55
lines changed

2 files changed

+58
-55
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
'use strict';
2+
3+
describe('directives', function() {
4+
5+
describe('parameter section', function() {
6+
7+
it('should show the directive name only if it is a param (attribute) with a value', function() {
8+
browser.get('build/docs/index.html#!/api/ng/directive/ngInclude');
9+
expect(getParamNames().getText()).toContain('ngInclude | src');
10+
11+
browser.get('build/docs/index.html#!/api/ngRoute/directive/ngView');
12+
expect(getParamNames().getText()).not.toContain('ngView');
13+
});
14+
});
15+
16+
describe('usage section', function() {
17+
18+
it('should show the directive name if it is a param (attribute) with a value', function() {
19+
browser.get('build/docs/index.html#!/api/ng/directive/ngInclude');
20+
21+
expect(getUsageAs('element', 'ng-include').isPresent()).toBe(true);
22+
expect(getUsageAs('attribute', 'ng-include').isPresent()).toBe(true);
23+
expect(getUsageAs('CSS class', 'ng-include').isPresent()).toBe(true);
24+
});
25+
26+
it('should show the directive name if it is a void param (attribute)', function() {
27+
browser.get('build/docs/index.html#!/api/ngRoute/directive/ngView');
28+
29+
expect(getUsageAs('element', 'ng-view').isPresent()).toBe(true);
30+
expect(getUsageAs('attribute', 'ng-view').isPresent()).toBe(true);
31+
expect(getUsageAs('CSS class', 'ng-view').isPresent()).toBe(true);
32+
});
33+
});
34+
});
35+
36+
function getParamNames() {
37+
var argsSection = element(by.className('input-arguments'));
38+
39+
var paramNames = argsSection.all(by.css('tr td:nth-child(1)'));
40+
41+
return paramNames;
42+
}
43+
44+
// Based on the type of directive usage, the directive name will show up in the code block
45+
// with a specific class
46+
var typeClassMap = {
47+
element: 'tag',
48+
attribute: 'atn',
49+
'CSS class': 'atv'
50+
};
51+
52+
function getUsageAs(type, directiveName) {
53+
var usage = element(by.className('usage'));
54+
55+
var as = usage.element(by.cssContainingText('li', 'as ' + type));
56+
57+
return as.element(by.cssContainingText('span.' + typeClassMap[type], directiveName));
58+
}

docs/app/e2e/usage.scenario.js

-55
This file was deleted.

0 commit comments

Comments
 (0)