Skip to content

Commit 72f0c90

Browse files
committed
ttt
1 parent c2bfa78 commit 72f0c90

File tree

1 file changed

+62
-62
lines changed

1 file changed

+62
-62
lines changed

school/regexp.spec.js

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,211 +1,211 @@
11
var expect = require('chai').expect;
22

3-
describe('Regexp', function() {
3+
describe.only('Regexp', function () {
44

5-
describe('matching beginning of a string', function() {
5+
describe('matching beginning of a string', function () {
66

77
var pattern = /^players/;
88

9-
it('passes with a matching string', function() {
9+
it('passes with a matching string', function () {
1010
expect(pattern.test('players')).to.equal(true);
1111
});
1212

13-
it('fails with a non-matching string', function() {
13+
it('fails with a non-matching string', function () {
1414
expect(pattern.test('the players')).to.equal(false);
1515
});
1616
});
1717

18-
describe('matching extension', function() {
18+
describe('matching extension', function () {
1919

2020
var pattern = /\.js$/;
2121

22-
it('passes with a matching filename', function() {
22+
it('passes with a matching filename', function () {
2323
expect(pattern.test('any-file.js')).to.equal(true);
2424
});
2525

26-
it('fails with a non-matching extension', function() {
26+
it('fails with a non-matching extension', function () {
2727
expect(pattern.test('another.extension')).to.equal(false);
2828
});
2929

30-
it('fails with a mal-formed extension', function() {
30+
it('fails with a mal-formed extension', function () {
3131
expect(pattern.test('hiddenjs')).to.equal(false);
3232
});
3333
});
3434

35-
describe('matching /players', function() {
35+
describe('matching /players', function () {
3636

3737
var pattern = /^\/players/;
3838

39-
it('passes with a matching string', function() {
39+
it('passes with a matching string', function () {
4040
expect(pattern.test('/players')).to.equal(true);
4141
});
4242

43-
it('fails with a non-matching string', function() {
43+
it('fails with a non-matching string', function () {
4444
expect(pattern.test('/the players')).to.equal(false);
4545
});
4646

4747
});
4848

49-
describe('matching /players/{login}', function() {
49+
describe('matching /players/{login}', function () {
5050

5151
var pattern = /^\/players\/[A-z]+$/;
5252

53-
it('passes with a matching string', function() {
53+
it('passes with a matching string', function () {
5454
expect(pattern.test('/players/any')).to.equal(true);
5555
});
5656

57-
it('fails with a non-matching string', function() {
57+
it('fails with a non-matching string', function () {
5858
expect(pattern.test('/players/any/thing')).to.equal(false);
5959
});
6060

6161
});
6262

63-
describe('matching /players/{login} with a dot in the login', function() {
63+
describe('matching /players/{login} with a dot in the login', function () {
6464

6565
var pattern = /^\/players\/[A-z|\.]+$/;
6666

67-
it('passes with a matching string', function() {
67+
it('passes with a matching string', function () {
6868
expect(pattern.test('/players/any.name')).to.equal(true);
6969
});
7070

71-
it('fails with a non-matching string', function() {
71+
it('fails with a non-matching string', function () {
7272
expect(pattern.test('/players/any:name')).to.equal(false);
7373
});
7474

7575
});
7676

77-
describe('matching /players/{login} with a dash in the login', function() {
77+
describe('matching /players/{login} with a dash in the login', function () {
7878

7979
var pattern = /^\/players\/[A-z|\.|\-]+$/;
8080

81-
it('passes with a matching string', function() {
81+
it('passes with a matching string', function () {
8282
expect(pattern.test('/players/any-name')).to.equal(true);
8383
});
8484

85-
it('fails with a non-matching string', function() {
85+
it('fails with a non-matching string', function () {
8686
expect(pattern.test('/players/any:name')).to.equal(false);
8787
});
8888

8989
});
9090

91-
describe('matching /players/{login} with a number in the login', function() {
91+
describe('matching /players/{login} with a number in the login', function () {
9292

9393
var pattern = /^\/players\/[A-z|\.|\-|0-9]+$/;
9494

95-
it('passes with a matching string', function() {
95+
it('passes with a matching string', function () {
9696
expect(pattern.test('/players/any-name-42')).to.equal(true);
9797
});
9898

99-
it('fails with a non-matching string', function() {
99+
it('fails with a non-matching string', function () {
100100
expect(pattern.test('/players/any:name')).to.equal(false);
101101
});
102102

103103
});
104104

105-
describe('matching /players/{login} with a @ in the login', function() {
105+
describe('matching /players/{login} with a @ in the login', function () {
106106

107107
var pattern = /^\/players\/[A-z|\.|\-|@]+$/;
108108

109-
it('passes with a matching string', function() {
109+
it('passes with a matching string', function () {
110110
expect(pattern.test('/players/any@name')).to.equal(true);
111111
});
112112

113-
it('fails with a non-matching string', function() {
113+
it('fails with a non-matching string', function () {
114114
expect(pattern.test('/players/any:name')).to.equal(false);
115115
});
116116

117117
});
118118

119-
describe('matching /players/{login}/play/world/{id}', function() {
119+
describe('matching /players/{login}/play/world/{id}', function () {
120120

121121
var pattern = /^\/players\/[A-z]+\/play\/world\/[0-9]+$/;
122122

123-
it('passes with a matching string', function() {
123+
it('passes with a matching string', function () {
124124
expect(pattern.test('/players/any/play/world/42')).to.equal(true);
125125
});
126126

127-
it('fails with a non-matching string', function() {
127+
it('fails with a non-matching string', function () {
128128
expect(pattern.test('/players/any/play/world/3/any')).to.equal(false);
129129
});
130130

131131
});
132132

133-
describe('matching /any-route', function() {
133+
describe('matching /any-route', function () {
134134

135135
var pattern = /^\/any-route$/;
136136

137-
it('passes with a matching string', function() {
137+
it('passes with a matching string', function () {
138138
expect(pattern.test('/any-route')).to.equal(true);
139139
});
140140

141-
it('fails with a non-matching string', function() {
141+
it('fails with a non-matching string', function () {
142142
expect(pattern.test('/any-route/more')).to.equal(false);
143143
});
144144

145145
});
146146

147-
describe('matching all', function() {
147+
describe('matching all', function () {
148148

149149
var pattern = /.*/;
150150

151-
it('passes with a matching string', function() {
151+
it('passes with a matching string', function () {
152152
expect(pattern.test('/-42any/thing')).to.equal(true);
153153
});
154154

155155
});
156156

157-
describe('Data extraction', function() {
157+
describe('Data extraction', function () {
158158

159159
var pattern = /^\/players\/(.*)\/play\/world\/(.*)/;
160160

161-
it('is built-in', function() {
161+
it('is built-in', function () {
162162
expect(pattern.exec('/players/ericminio/play/world/1')[1]).to.equal('ericminio');
163163
});
164164

165-
it('can extract second parameter', function() {
165+
it('can extract second parameter', function () {
166166
expect(pattern.exec('/players/ericminio/play/world/42')[2]).to.equal('42');
167167
});
168168

169-
it('returns null when not found', function() {
169+
it('returns null when not found', function () {
170170
expect(pattern.exec('/non/matching')).to.equal(null);
171171
});
172172

173-
it('can extract a parameter with a dot', function() {
173+
it('can extract a parameter with a dot', function () {
174174
expect(pattern.exec('/players/eric.mignot/play/world/1')[1]).to.equal('eric.mignot');
175175
});
176176
});
177177

178-
describe('Regex concatanation', function() {
178+
describe('Regex concatanation', function () {
179179

180-
it('works', function() {
181-
var start = /\/any/;
182-
var end = /\/route/;
183-
var pattern = /^/ && start && end && /$/;
180+
it('works', function () {
181+
var start = /\/any/;
182+
var end = /\/route/;
183+
var pattern = /^/ && start && end && /$/;
184184

185-
expect(pattern.test('/any/route')).to.equal(true);
186-
});
185+
expect(pattern.test('/any/route')).to.equal(true);
186+
});
187187

188-
it('works inline', function() {
189-
var pattern = /^/ && /\/any/ && /\/route/ && /$/;
188+
it('works inline', function () {
189+
var pattern = /^/ && /\/any/ && /\/route/ && /$/;
190190

191-
expect(pattern.test('/any/route')).to.equal(true);
192-
});
191+
expect(pattern.test('/any/route')).to.equal(true);
192+
});
193193
});
194194

195-
describe('Regex string spliting', function() {
195+
describe('Regex string spliting', function () {
196196

197-
it('can be used to split a string at each space', function() {
198-
expect('Hello world'.split(/\s/)).to.deep.equal(['Hello', 'world']);
199-
});
197+
it('can be used to split a string at each space', function () {
198+
expect('Hello world'.split(/\s/)).to.deep.equal(['Hello', 'world']);
199+
});
200200

201-
it('can be used to split a string at each 2 characters', function() {
202-
expect('Helo'.match(/.{2}/g)).to.deep.equal(['He', 'lo']);
203-
});
201+
it('can be used to split a string at each 2 characters', function () {
202+
expect('Helo'.match(/.{2}/g)).to.deep.equal(['He', 'lo']);
203+
});
204204

205-
it('can be used with a variable', function() {
206-
var length = 2;
207-
var regex = new RegExp('.{' + length + '}', 'g');
208-
expect('Helo'.match(regex)).to.deep.equal(['He', 'lo']);
209-
});
205+
it('can be used with a variable', function () {
206+
var length = 2;
207+
var regex = new RegExp('.{' + length + '}', 'g');
208+
expect('Helo'.match(regex)).to.deep.equal(['He', 'lo']);
209+
});
210210
});
211211
});

0 commit comments

Comments
 (0)