|
1 | 1 | import test from 'ava';
|
2 |
| -import sinon from 'sinon'; |
3 |
| -import proxyquire from 'proxyquire'; |
4 |
| - |
5 |
| -const spy = sinon.spy(); |
6 |
| -const BemEntityName = proxyquire('../lib/entity-name', { |
7 |
| - '@bem/naming': { |
8 |
| - stringify: spy |
9 |
| - } |
10 |
| -}); |
| 2 | +import BemEntityName from '..'; |
11 | 3 |
|
12 |
| -test('should use `naming.stringify()` for block', t => { |
| 4 | +test('should stringify block entity name', t => { |
13 | 5 | const entityName = new BemEntityName({ block: 'block' });
|
14 | 6 |
|
15 |
| - entityName.toString(); |
16 |
| - |
17 |
| - t.true(spy.calledWith({ block: 'block' })); |
| 7 | + t.is(entityName.toString(), 'block'); |
18 | 8 | });
|
19 | 9 |
|
20 |
| -test('should use `naming.stringify()` for elem', t => { |
| 10 | +test('should stringify elem entity name', t => { |
21 | 11 | const entityName = new BemEntityName({ block: 'block', elem: 'elem' });
|
22 | 12 |
|
23 |
| - entityName.toString(); |
| 13 | + t.is(entityName.toString(), 'block__elem'); |
| 14 | +}); |
| 15 | + |
| 16 | +test('should stringify block’s simple modifier entity name', t => { |
| 17 | + const entityName = new BemEntityName({ block: 'block', mod: { name: 'mod', val: true } }); |
24 | 18 |
|
25 |
| - t.true(spy.calledWith({ block: 'block', elem: 'elem' })); |
| 19 | + t.is(entityName.toString(), 'block_mod'); |
26 | 20 | });
|
27 | 21 |
|
28 |
| -test('should use `naming.stringify()` for block modifier', t => { |
| 22 | +test('should stringify block’s modifier entity name', t => { |
29 | 23 | const entityName = new BemEntityName({ block: 'block', mod: { name: 'mod', val: 'val' } });
|
30 | 24 |
|
31 |
| - entityName.toString(); |
| 25 | + t.is(entityName.toString(), 'block_mod_val'); |
| 26 | +}); |
| 27 | + |
| 28 | +test('should stringify element’s simple modifier entity name', t => { |
| 29 | + const entityName = new BemEntityName({ block: 'block', elem: 'elem', mod: { name: 'mod', val: true } }); |
32 | 30 |
|
33 |
| - t.true(spy.calledWith({ block: 'block', mod: { name: 'mod', val: 'val' } })); |
| 31 | + t.is(entityName.toString(), 'block__elem_mod'); |
34 | 32 | });
|
35 | 33 |
|
36 |
| -test('should use naming.stringify() for element modifier', t => { |
| 34 | +test('should stringify element’s modifier entity name', t => { |
37 | 35 | const entityName = new BemEntityName({ block: 'block', elem: 'elem', mod: { name: 'mod', val: 'val' } });
|
38 | 36 |
|
39 |
| - entityName.toString(); |
40 |
| - |
41 |
| - t.true(spy.calledWith({ block: 'block', elem: 'elem', mod: { name: 'mod', val: 'val' } })); |
| 37 | + t.is(entityName.toString(), 'block__elem_mod_val'); |
42 | 38 | });
|
0 commit comments