diff --git a/test/id.test.js b/test/id.test.js new file mode 100644 index 0000000..73375d1 --- /dev/null +++ b/test/id.test.js @@ -0,0 +1,46 @@ +const test = require('ava'); +const BemEntityName = require('@bem/entity-name'); + +const BemCell = require('../index'); + +test('should provide `id` field', t => { + const cell = new BemCell({ + entity: new BemEntityName({ block: 'block' }), + layer: 'desktop', + tech: 'css' + }); + + t.is(cell.id, 'block@desktop.css'); +}); + +test('should provide `id` field for cell with tech', t => { + const cell = new BemCell({ + entity: new BemEntityName({ block: 'block' }), + tech: 'css' + }); + + t.is(cell.id, 'block.css'); +}); + +test('should provide `id` field for cell with layer', t => { + const cell = new BemCell({ + entity: new BemEntityName({ block: 'block' }), + layer: 'desktop', + }); + + t.is(cell.id, 'block@desktop'); +}); + +test('should provide `id` field for cell with layer', t => { + const cell = new BemCell({ + entity: new BemEntityName({ block: 'block' }), + layer: 'desktop', + tech: 'css' + }); + const id = cell.id; + + cell._tech = 'js'; + cell._layer = 'common'; + + t.is(cell.id, id); +});