Skip to content

Commit d5b735f

Browse files
author
blond
committed
test: use functions without context
1 parent 81cac31 commit d5b735f

14 files changed

+108
-94
lines changed

test/presets/original/is-block-mod.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
const test = require('ava');
44
const naming = require('../../../index')('origin');
5+
const isBlockMod = naming.isBlockMod;
56

67
test('should detect mod of block', t => {
7-
t.true(naming.isBlockMod('block_mod_val'));
8+
t.true(isBlockMod('block_mod_val'));
89
});
910

1011
test('should detect boolean mod of block', t => {
11-
t.true(naming.isBlockMod('block_mod'));
12+
t.true(isBlockMod('block_mod'));
1213
});

test/presets/original/is-elem-mod.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
const test = require('ava');
44
const naming = require('../../../index')('origin');
5+
const isElemMod = naming.isElemMod;
56

67
test('should detect mod of elem', t => {
7-
t.true(naming.isElemMod('block__elem_mod_val'));
8+
t.true(isElemMod('block__elem_mod_val'));
89
});
910

1011
test('should detect boolean mod of elem', t => {
11-
t.true(naming.isElemMod('block__elem_mod'));
12+
t.true(isElemMod('block__elem_mod'));
1213
});

test/presets/original/is-elem.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
const test = require('ava');
44
const naming = require('../../../index')('origin');
5+
const isElem = naming.isElem;
56

67
test('should detect elem', t => {
7-
t.true(naming.isElem('block__elem'));
8+
t.true(isElem('block__elem'));
89
});

test/presets/original/parse.test.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,60 @@
22

33
const test = require('ava');
44
const naming = require('../../../index')('origin');
5+
const parse = naming.parse;
56

67
test('should not parse not valid string', t => {
7-
const obj = naming.parse('(*)_(*)');
8+
const obj = parse('(*)_(*)');
89

910
t.is(obj, undefined);
1011
});
1112

1213
test('should have one filed if parse block', t => {
13-
const obj = naming.parse('block');
14+
const obj = parse('block');
1415

1516
t.is(Object.keys(obj).length, 1);
1617
});
1718

1819
test('should have three filed if parse mod of block', t => {
19-
const obj = naming.parse('block_mod_val');
20+
const obj = parse('block_mod_val');
2021

2122
t.is(Object.keys(obj).length, 3);
2223
});
2324

2425
test('should have three filed if parse boolean mod of block', t => {
25-
const obj = naming.parse('block_mod');
26+
const obj = parse('block_mod');
2627

2728
t.is(Object.keys(obj).length, 3);
2829
});
2930

3031
test('should have two filed if parse elem of block', t => {
31-
const obj = naming.parse('block__elem');
32+
const obj = parse('block__elem');
3233

3334
t.is(Object.keys(obj).length, 2);
3435
});
3536

3637
test('should have four filed if parse mod of elem', t => {
37-
const obj = naming.parse('block__elem_mod_val');
38+
const obj = parse('block__elem_mod_val');
3839

3940
t.is(Object.keys(obj).length, 4);
4041
});
4142

4243
test('should have four filed if parse boolean mod of elem', t => {
43-
const obj = naming.parse('block__elem_mod');
44+
const obj = parse('block__elem_mod');
4445

4546
t.is(Object.keys(obj).length, 4);
4647
});
4748

4849
test('should parse block', t => {
49-
const obj = naming.parse('block');
50+
const obj = parse('block');
5051

5152
t.is(obj.block, 'block');
5253
});
5354

5455
test('should parse mod of block', t => {
5556
t.plan(3);
5657

57-
const obj = naming.parse('block_mod_val');
58+
const obj = parse('block_mod_val');
5859

5960
t.is(obj.block, 'block');
6061
t.is(obj.modName, 'mod');
@@ -64,7 +65,7 @@ test('should parse mod of block', t => {
6465
test('should parse boolean mod of block', t => {
6566
t.plan(3);
6667

67-
const obj = naming.parse('block_mod');
68+
const obj = parse('block_mod');
6869

6970
t.is(obj.block, 'block');
7071
t.is(obj.modName, 'mod');
@@ -75,7 +76,7 @@ test('should parse boolean mod of block', t => {
7576
test('should parse elem', t => {
7677
t.plan(2);
7778

78-
const obj = naming.parse('block__elem');
79+
const obj = parse('block__elem');
7980

8081
t.is(obj.block, 'block');
8182
t.is(obj.elem, 'elem');
@@ -84,7 +85,7 @@ test('should parse elem', t => {
8485
test('should parse mod of elem', t => {
8586
t.plan(4);
8687

87-
const obj = naming.parse('block__elem_mod_val');
88+
const obj = parse('block__elem_mod_val');
8889

8990
t.is(obj.block, 'block');
9091
t.is(obj.elem, 'elem');
@@ -95,7 +96,7 @@ test('should parse mod of elem', t => {
9596
test('should parse boolean mod of elem', t => {
9697
t.plan(4);
9798

98-
const obj = naming.parse('block__elem_mod');
99+
const obj = parse('block__elem_mod');
99100

100101
t.is(obj.block, 'block');
101102
t.is(obj.elem, 'elem');

test/presets/original/stringify.test.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22

33
const test = require('ava');
44
const naming = require('../../../index')('origin');
5+
const stringify = naming.stringify;
56

67
test('should stringify block', t => {
7-
const str = naming.stringify({ block: 'block' });
8+
const str = stringify({ block: 'block' });
89

910
t.is(str, 'block');
1011
});
1112

1213
test('should stringify mod of block', t => {
13-
const str = naming.stringify({
14+
const str = stringify({
1415
block: 'block',
1516
modName: 'mod',
1617
modVal: 'val'
@@ -20,7 +21,7 @@ test('should stringify mod of block', t => {
2021
});
2122

2223
test('should stringify boolean mod of block', t => {
23-
const str = naming.stringify({
24+
const str = stringify({
2425
block: 'block',
2526
modName: 'mod'
2627
});
@@ -29,7 +30,7 @@ test('should stringify boolean mod of block', t => {
2930
});
3031

3132
test('should stringify boolean mod of block by strict notation', t => {
32-
const str = naming.stringify({
33+
const str = stringify({
3334
block: 'block',
3435
modName: 'mod',
3536
modVal: true
@@ -39,7 +40,7 @@ test('should stringify boolean mod of block by strict notation', t => {
3940
});
4041

4142
test('should stringify block if `modVal` filed is `undefined`', t => {
42-
const str = naming.stringify({
43+
const str = stringify({
4344
block: 'block',
4445
modName: 'mod',
4546
modVal: undefined
@@ -49,7 +50,7 @@ test('should stringify block if `modVal` filed is `undefined`', t => {
4950
});
5051

5152
test('should stringify elem', t => {
52-
const str = naming.stringify({
53+
const str = stringify({
5354
block: 'block',
5455
elem: 'elem'
5556
});
@@ -58,7 +59,7 @@ test('should stringify elem', t => {
5859
});
5960

6061
test('should stringify mod of elem', t => {
61-
const str = naming.stringify({
62+
const str = stringify({
6263
block: 'block',
6364
elem: 'elem',
6465
modName: 'mod',
@@ -69,7 +70,7 @@ test('should stringify mod of elem', t => {
6970
});
7071

7172
test('should stringify boolean mod of elem', t => {
72-
const str = naming.stringify({
73+
const str = stringify({
7374
block: 'block',
7475
elem: 'elem',
7576
modName: 'mod'
@@ -79,7 +80,7 @@ test('should stringify boolean mod of elem', t => {
7980
});
8081

8182
test('should stringify boolean mod of elem by strict notation', t => {
82-
const str = naming.stringify({
83+
const str = stringify({
8384
block: 'block',
8485
elem: 'elem',
8586
modName: 'mod',
@@ -90,7 +91,7 @@ test('should stringify boolean mod of elem by strict notation', t => {
9091
});
9192

9293
test('should stringify elem if `modVal` filed is `undefined`', t => {
93-
const str = naming.stringify({
94+
const str = stringify({
9495
block: 'block',
9596
elem: 'elem',
9697
modName: 'mod',

test/presets/original/type-of.test.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,46 @@
22

33
const test = require('ava');
44
const naming = require('../../../index')('origin');
5+
const typeOf = naming.typeOf;
56

67
test('should not determine not valid string', t => {
7-
const type = naming.typeOf('(*)_(*)');
8+
const type = typeOf('(*)_(*)');
89

910
t.is(type, undefined);
1011
});
1112

1213
test('should determine block', t => {
13-
const type = naming.typeOf('block');
14+
const type = typeOf('block');
1415

1516
t.is(type, 'block');
1617
});
1718

1819
test('should determine mod of block', t => {
19-
const type = naming.typeOf('block_mod_val');
20+
const type = typeOf('block_mod_val');
2021

2122
t.is(type, 'blockMod');
2223
});
2324

2425
test('should determine boolean mod of block', t => {
25-
const type = naming.typeOf('block_mod');
26+
const type = typeOf('block_mod');
2627

2728
t.is(type, 'blockMod');
2829
});
2930

3031
test('should determine elem', t => {
31-
const type = naming.typeOf('block__elem');
32+
const type = typeOf('block__elem');
3233

3334
t.is(type, 'elem');
3435
});
3536

3637
test('should determine mod of elem', t => {
37-
const type = naming.typeOf('block__elem_mod_val');
38+
const type = typeOf('block__elem_mod_val');
3839

3940
t.is(type, 'elemMod');
4041
});
4142

4243
test('should determine boolean mod of elem', t => {
43-
const type = naming.typeOf('block__elem_mod');
44+
const type = typeOf('block__elem_mod');
4445

4546
t.is(type, 'elemMod');
4647
});

test/presets/original/validate.test.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,63 +2,64 @@
22

33
const test = require('ava');
44
const naming = require('../../../index')('origin');
5+
const validate = naming.validate;
56

67
test('should validate block', t => {
7-
t.true(naming.validate('block'));
8+
t.true(validate('block'));
89
});
910

1011
test('should validate mod of block', t => {
11-
t.true(naming.validate('block_mod_val'));
12+
t.true(validate('block_mod_val'));
1213
});
1314

1415
test('should validate boolean mod of block', t => {
15-
t.true(naming.validate('block_mod'));
16+
t.true(validate('block_mod'));
1617
});
1718

1819
test('should validate elem', t => {
19-
t.true(naming.validate('block__elem'));
20+
t.true(validate('block__elem'));
2021
});
2122

2223
test('should validate mod of elem', t => {
23-
t.true(naming.validate('block__elem_mod_value'));
24+
t.true(validate('block__elem_mod_value'));
2425
});
2526

2627
test('should validate boolean mod of elem', t => {
27-
t.true(naming.validate('block__elem_mod'));
28+
t.true(validate('block__elem_mod'));
2829
});
2930

3031
test('should not validate elem without block', t => {
31-
t.false(naming.validate('__elem'));
32+
t.false(validate('__elem'));
3233
});
3334

3435
test('should not validate boolean mod without block', t => {
35-
t.false(naming.validate('_mod'));
36+
t.false(validate('_mod'));
3637
});
3738

3839
test('should not validate mod without block', t => {
39-
t.false(naming.validate('_mod_val'));
40+
t.false(validate('_mod_val'));
4041
});
4142

4243
test('should not validate mod of elem without block', t => {
43-
t.false(naming.validate('__elem_mod_val'));
44+
t.false(validate('__elem_mod_val'));
4445
});
4546

4647
test('should not validate boolean mod of elem without block', t => {
47-
t.false(naming.validate('__elem_mod'));
48+
t.false(validate('__elem_mod'));
4849
});
4950

5051
test('should not validate nested elem', t => {
51-
t.false(naming.validate('block__elem1__elem2'));
52+
t.false(validate('block__elem1__elem2'));
5253
});
5354

5455
test('should not validate multi mod', t => {
55-
t.false(naming.validate('block_mod_val__elem_mod_val'));
56+
t.false(validate('block_mod_val__elem_mod_val'));
5657
});
5758

5859
test('should not validate block name with illegal literals', t => {
59-
t.false(naming.validate('^_^'));
60+
t.false(validate('^_^'));
6061
});
6162

6263
test('should support CamelCase', t => {
63-
t.true(naming.validate('BlockName'));
64+
t.true(validate('BlockName'));
6465
});

test/presets/two-dashes/is-block-mod.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
const test = require('ava');
44
const naming = require('../../../index')('two-dashes');
5+
const isBlockMod = naming.isBlockMod;
56

67
test('should detect mod of block', t => {
7-
t.true(naming.isBlockMod('block--mod_val'));
8+
t.true(isBlockMod('block--mod_val'));
89
});
910

1011
test('should detect boolean mod of block', t => {
11-
t.true(naming.isBlockMod('block--mod'));
12+
t.true(isBlockMod('block--mod'));
1213
});

0 commit comments

Comments
 (0)