Conditions | 1 |
Paths | 1 |
Total Lines | 165 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | describe('Abe', function() { |
||
3 | describe('operations', function() { |
||
4 | |||
5 | before(function(client, done) { |
||
6 | done(); |
||
7 | }); |
||
8 | |||
9 | after(function(client, done) { |
||
10 | client.end(function() { |
||
11 | done(); |
||
12 | }); |
||
13 | }); |
||
14 | |||
15 | afterEach(function(client, done) { |
||
16 | done(); |
||
17 | }); |
||
18 | |||
19 | beforeEach(function(client, done) { |
||
20 | done(); |
||
21 | }); |
||
22 | |||
23 | it('Create a single article', function(client) { |
||
24 | client |
||
25 | .useXpath() |
||
26 | .url('http://localhost:3003/abe/editor') |
||
27 | .waitForElementVisible('//body') |
||
28 | .assert.title('Abe') |
||
29 | .click('//*[@id="level-1"]/option[2]') |
||
30 | .click('//*[@id="selectTemplate"]/option[10]') |
||
31 | .waitForElementVisible("//div[@data-precontrib-templates='single']//input[@id='name']", 1000) |
||
32 | .setValue("//div[@data-precontrib-templates='single']//input[@id='name']", 'ftest') |
||
33 | .click("//button[@type='submit']") |
||
34 | .waitForElementVisible("//*[@id='abeForm']", 2000) |
||
35 | .assert.urlEquals("http://localhost:3003/abe/editor/articles/ftest.html", "Clicked URL Matches with URL of the New Window"); |
||
36 | }); |
||
37 | |||
38 | it('The created single article is found in the manager', function(client) { |
||
39 | client |
||
40 | .useXpath() |
||
41 | .url('http://localhost:3003/abe/editor') |
||
42 | .waitForElementVisible("//body") |
||
43 | .pause(1000) |
||
44 | .assert.containsText("//table[@id='navigation-list']/tbody/tr[1]/td[2]/a", "/articles/ftest.html"); |
||
45 | }); |
||
46 | |||
47 | it('The created single article is edited and updated with no change', function(client) { |
||
48 | client |
||
49 | .useXpath() |
||
50 | .url('http://localhost:3003/abe/editor/articles/ftest.html#slug') |
||
51 | .waitForElementVisible('//body') |
||
52 | .assert.title('Abe') |
||
53 | .click("//button[@class='btn btn-primary'][2]") |
||
54 | .pause(2000) |
||
55 | .assert.urlEquals("http://localhost:3003/abe/editor/articles/ftest.html", "Clicked URL Matches with URL of the New Window"); |
||
56 | }); |
||
57 | |||
58 | it('The updated single article is found in the manager', function(client) { |
||
59 | client |
||
60 | .useXpath() |
||
61 | .url('http://localhost:3003/abe/editor') |
||
62 | .waitForElementVisible('//body') |
||
63 | .pause(1000) |
||
64 | .assert.containsText("//table[@id='navigation-list']/tbody/tr[1]/td[2]/a", "/articles/ftest.html"); |
||
65 | }); |
||
66 | |||
67 | it('The updated single article is edited once more with a new name', function(client) { |
||
68 | client |
||
69 | .useXpath() |
||
70 | .url('http://localhost:3003/abe/editor/articles/ftest.html#slug') |
||
71 | .waitForElementVisible('//body') |
||
72 | .assert.title('Abe') |
||
73 | .setValue("//div[@data-precontrib-templates='single']//input[@id='name']", 'updated') |
||
74 | .click("//button[@class='btn btn-primary'][2]") |
||
75 | .pause(2000) |
||
76 | .assert.urlEquals("http://localhost:3003/abe/editor/articles/ftestupdated.html", "Clicked URL Matches with URL of the New Window"); |
||
77 | }); |
||
78 | |||
79 | it('The updated single article is found in the manager', function(client) { |
||
80 | client |
||
81 | .useXpath() |
||
82 | .url('http://localhost:3003/abe/editor') |
||
83 | .waitForElementVisible('//body') |
||
84 | .pause(1000) |
||
85 | .assert.containsText("//table[@id='navigation-list']/tbody/tr[1]/td[2]/a", "/articles/ftestupdated.html"); |
||
86 | }); |
||
87 | |||
88 | it('The updated single article is duplicated', function(client) { |
||
89 | client |
||
90 | .useXpath() |
||
91 | .url('http://localhost:3003/abe/editor/articles/ftestupdated.html#slug') |
||
92 | .waitForElementVisible('//body') |
||
93 | .assert.title('Abe') |
||
94 | .clearValue("//div[@data-precontrib-templates='single']//input[@id='name']") |
||
95 | .setValue("//div[@data-precontrib-templates='single']//input[@id='name']", 'ftest') |
||
96 | .click("//button[@class='btn btn-primary'][1]") |
||
97 | .pause(2000) |
||
98 | .assert.urlEquals("http://localhost:3003/abe/editor/articles/ftest.html", "Clicked URL Matches with URL of the New Window"); |
||
99 | }); |
||
100 | |||
101 | it('The updated single article + duplicated are found in the manager', function(client) { |
||
102 | client |
||
103 | .useXpath() |
||
104 | .url('http://localhost:3003/abe/editor') |
||
105 | .waitForElementVisible('//body') |
||
106 | .pause(1000) |
||
107 | .assert.containsText("//table[@id='navigation-list']/tbody/tr[1]/td[2]/a", "/articles/ftest.html") |
||
108 | .assert.containsText("//table[@id='navigation-list']/tbody/tr[2]/td[2]/a", "/articles/ftestupdated.html"); |
||
109 | }); |
||
110 | |||
111 | it('The updated article is deleted in the manager', function(client) { |
||
112 | client |
||
113 | .useXpath() |
||
114 | .url('http://localhost:3003/abe/editor') |
||
115 | .waitForElementVisible('//body') |
||
116 | .pause(1000) |
||
117 | .click("//table[@id='navigation-list']/tbody/tr[2]/td[7]/div/a[last()]") |
||
118 | .pause(1000) |
||
119 | .acceptAlert() |
||
120 | .url('http://localhost:3003/abe/editor') |
||
121 | .pause(2000) |
||
122 | .expect.element("//table[@id='navigation-list']/tbody/tr[2]/td[2]/a").text.to.not.contain('/articles/ftestupdated.html'); |
||
123 | }); |
||
124 | |||
125 | // it('The duplicated single article is published', function(client) { |
||
126 | // client |
||
127 | // .useXpath() |
||
128 | // .url('http://localhost:3003/abe/editor/articles/ftest.html#slug') |
||
129 | // .waitForElementVisible('//body') |
||
130 | // .assert.title('Abe') |
||
131 | // .pause(1000) |
||
132 | // .click("//div[@class='btns']/button[3]") |
||
133 | // .pause(2000) |
||
134 | // .assert.containsText("//div[@class='display-status']/span", "publish") |
||
135 | // .url('http://localhost:3003/abe/editor') |
||
136 | // .waitForElementVisible('//body') |
||
137 | // .assert.cssClassPresent("//table[@id='navigation-list']/tbody/tr[1]/td[6]/a", "label-published"); |
||
138 | // }); |
||
139 | |||
140 | // it('The duplicated article is unpublished in the manager', function(client) { |
||
141 | // client |
||
142 | // .useXpath() |
||
143 | // .url('http://localhost:3003/abe/editor') |
||
144 | // .waitForElementVisible('//body') |
||
145 | // .pause(1000) |
||
146 | // .click("//table[@id='navigation-list']/tbody/tr[1]/td[7]/div/a") |
||
147 | // .pause(1000) |
||
148 | // .acceptAlert() |
||
149 | // .url('http://localhost:3003/abe/editor') |
||
150 | // .pause(2000) |
||
151 | // .assert.cssClassPresent("//table[@id='navigation-list']/tbody/tr[1]/td[5]/a", "label-draft"); |
||
152 | // }); |
||
153 | |||
154 | it('The duplicated article is deleted in the manager', function(client) { |
||
155 | client |
||
156 | .useXpath() |
||
157 | .url('http://localhost:3003/abe/editor') |
||
158 | .waitForElementVisible('//body') |
||
159 | .pause(1000) |
||
160 | .click("//table[@id='navigation-list']/tbody/tr[1]/td[7]/div/a") |
||
161 | .pause(1000) |
||
162 | .acceptAlert() |
||
163 | .url('http://localhost:3003/abe/editor') |
||
164 | .pause(2000) |
||
165 | .expect.element("//table[@id='navigation-list']/tbody/tr[1]/td[2]/a").text.to.not.contain('/articles/ftest.html'); |
||
166 | }); |
||
167 | }); |
||
168 | }); |