UNPKG

1.79 kBMarkdownView Raw
1* [transform](transform)
2 * [shouldToBoolean()](shouldtoboolean())
3 * [stringToVariableName()](stringtovariablename())
4 * [elementTypeToVariableName()](elementtypetovariablename())
5# transform
6 transform should exist on the World
7
8```
9var world;
10world = new World(function() {});
11return expect(world.transform).to.be.an.instanceOf(Transform);
12```
13
14
15## shouldToBoolean()
16 shouldToBoolean() should convert the string "should" to true
17
18```
19expect(transform.shouldToBoolean('should')).to.equal(true);
20```
21
22
23 shouldToBoolean() should convert the string "should not" to false
24
25```
26expect(transform.shouldToBoolean('should not')).to.equal(false);
27```
28
29
30## stringToVariableName()
31 stringToVariableName() should make the first letter of a string lower case
32
33```
34expect(transform.stringToVariableName('Test')).to.equal('test');
35```
36
37
38 stringToVariableName() should not affect letters after the first letter
39
40```
41expect(transform.stringToVariableName('TEST')).to.equal('tEST');
42```
43
44
45 stringToVariableName() should remove spaces
46
47```
48expect(transform.stringToVariableName('Test String')).to.equal('testString');
49```
50
51
52 stringToVariableName() should replace "&" with "And"
53
54```
55expect(transform.stringToVariableName('Tom & Jerry')).to.equal('tomAndJerry');
56```
57
58
59## elementTypeToVariableName()
60 elementTypeToVariableName() should convert the string "drop down list" to "Select"
61
62```
63expect(transform.elementTypeToVariableName('drop down list')).to.equal('Select');
64```
65
66
67 elementTypeToVariableName() should capitalize the first letter of other strings and pass them through
68
69```
70expect(transform.elementTypeToVariableName('button')).to.equal('Button');
71```
72
73
74 elementTypeToVariableName() should trim white space
75
76```
77expect(transform.elementTypeToVariableName(' button ')).to.equal('Button');
78```