Conditions | 1 |
Paths | 1 |
Total Lines | 108 |
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 | var assert = require('chai').assert, |
||
4 | describe('AtomFeed', function(){ |
||
5 | |||
6 | var json = { |
||
7 | authors: [ |
||
8 | { |
||
9 | name: 'author', |
||
10 | email: '[email protected]' |
||
11 | } |
||
12 | ], |
||
13 | contributors: [ |
||
14 | { |
||
15 | name: 'contributor', |
||
16 | email: '[email protected]' |
||
17 | } |
||
18 | ], |
||
19 | generator: { |
||
20 | uri: 'uri', |
||
21 | version: 'version', |
||
22 | value: 'value' |
||
23 | }, |
||
24 | icon: 'icon', |
||
25 | id: 'id', |
||
26 | results: 5, |
||
27 | links: { |
||
28 | rel: { |
||
29 | href: 'href' |
||
30 | } |
||
31 | }, |
||
32 | logo: 'logo', |
||
33 | rights: 'rights', |
||
34 | subtitle: 'subtitle', |
||
35 | title: 'title', |
||
36 | updated: 123456789, |
||
37 | entries: [ |
||
38 | { |
||
39 | title: 'Entry title', |
||
40 | summary: 'Summary' |
||
41 | } |
||
42 | ], |
||
43 | facets: [ |
||
44 | { |
||
45 | type: 'fieldType' |
||
46 | } |
||
47 | ] |
||
48 | }; |
||
49 | |||
50 | it('Create plain', function(){ |
||
51 | assert.instanceOf(new GedcomX.AtomFeed(), GedcomX.AtomFeed, 'An instance of AtomFeed is not returned when calling the constructor with new.'); |
||
52 | assert.instanceOf(GedcomX.AtomFeed(), GedcomX.AtomFeed, 'An instance of AtomFeed is not returned when calling the constructor without new.'); |
||
53 | }); |
||
54 | |||
55 | it('Create with JSON', function(){ |
||
56 | tests(GedcomX.AtomFeed(json)); |
||
57 | }); |
||
58 | |||
59 | it('Build', function(){ |
||
60 | tests(GedcomX.AtomFeed() |
||
61 | .addAuthor( |
||
62 | GedcomX.AtomPerson() |
||
63 | .setName('author') |
||
64 | .setEmail('[email protected]') |
||
65 | ) |
||
66 | .addContributor( |
||
67 | GedcomX.AtomPerson() |
||
68 | .setName('contributor') |
||
69 | .setEmail('[email protected]') |
||
70 | ) |
||
71 | .setGenerator( |
||
72 | GedcomX.AtomGenerator() |
||
73 | .setUri('uri') |
||
74 | .setVersion('version') |
||
75 | .setValue('value') |
||
76 | ) |
||
77 | .setIcon('icon') |
||
78 | .setId('id') |
||
79 | .setResults(5) |
||
80 | .addLink( |
||
81 | GedcomX.Link() |
||
82 | .setRel('rel') |
||
83 | .setHref('href') |
||
84 | ) |
||
85 | .setLogo('logo') |
||
86 | .setRights('rights') |
||
87 | .setSubtitle('subtitle') |
||
88 | .setTitle('title') |
||
89 | .setUpdated(123456789) |
||
90 | .addEntry( |
||
91 | GedcomX.AtomEntry() |
||
92 | .setTitle('Entry title') |
||
93 | .setSummary('Summary') |
||
94 | ) |
||
95 | .addFacet( |
||
96 | GedcomX.Field().setType('fieldType') |
||
97 | ) |
||
98 | ); |
||
99 | }); |
||
100 | |||
101 | it('toJSON', function(){ |
||
102 | assert.deepEqual(GedcomX.AtomFeed(json).toJSON(), json); |
||
103 | }); |
||
104 | |||
105 | it('constructor does not copy instances', function(){ |
||
106 | var obj1 = GedcomX.AtomFeed(); |
||
107 | var obj2 = GedcomX.AtomFeed(obj1); |
||
108 | assert.strictEqual(obj1, obj2); |
||
109 | }); |
||
110 | |||
111 | }); |
||
112 | |||
145 | } |