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

Commit 325fbb3

Browse files
committed
refactor the tests
1 parent 314c8b9 commit 325fbb3

File tree

2 files changed

+72
-55
lines changed

2 files changed

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

docs/app/e2e/usage.scenario.js

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)