-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
269 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const test = require('ava'); | ||
const sinon = require('sinon'); | ||
const BemEntityName = require('@bem/entity-name'); | ||
|
||
const BemCell = require('../index'); | ||
|
||
const EOL = require('os').EOL; | ||
|
||
test.beforeEach(t => { | ||
t.context.stdoutWriteStub = sinon.stub(process.stdout, 'write'); | ||
}); | ||
|
||
test.afterEach(t => { | ||
t.context.stdoutWriteStub.restore(); | ||
}); | ||
|
||
test('should return entity object', t => { | ||
const cell = new BemCell({ | ||
entity: new BemEntityName({ block: 'block' }), | ||
tech: 'css' | ||
}); | ||
|
||
console.log(cell); | ||
|
||
const message = `BemCell { entity: { block: 'block' }, tech: 'css' }${EOL}`; | ||
|
||
t.true(t.context.stdoutWriteStub.calledWith(message)); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const test = require('ava'); | ||
const BemEntityName = require('@bem/entity-name'); | ||
|
||
const BemCell = require('../index'); | ||
|
||
test('should return stringified cell', t => { | ||
const cell = new BemCell({ | ||
entity: new BemEntityName({ block: 'button' }), | ||
tech: 'olala' | ||
}); | ||
|
||
t.is(JSON.stringify([cell]), '[{"entity":{"block":"button"},"tech":"olala"}]'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const test = require('ava'); | ||
const BemEntityName = require('@bem/entity-name'); | ||
|
||
const BemCell = require('../index'); | ||
|
||
test('should return string', t => { | ||
const cell = new BemCell({ | ||
entity: new BemEntityName({ block: 'block' }) | ||
}); | ||
|
||
t.truthy(typeof cell.toString() === 'string'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const test = require('ava'); | ||
const BemEntityName = require('@bem/entity-name'); | ||
|
||
const BemCell = require('../index'); | ||
|
||
test('should return cell with entity', t => { | ||
const cell = new BemCell({ | ||
entity: new BemEntityName({ block: 'block' }) | ||
}); | ||
|
||
t.deepEqual(cell.valueOf(), { entity: { block: 'block' } }); | ||
}); | ||
|
||
test('should return cell with entity and tech', t => { | ||
const cell = new BemCell({ | ||
entity: new BemEntityName({ block: 'block' }), | ||
tech: 'css' | ||
}); | ||
|
||
t.deepEqual(cell.valueOf(), { entity: { block: 'block' }, tech: 'css' }); | ||
}); | ||
|
||
test('should return cell with entity and layer', t => { | ||
const cell = new BemCell({ | ||
entity: new BemEntityName({ block: 'block' }), | ||
layer: 'desktop' | ||
}); | ||
|
||
t.deepEqual(cell.valueOf(), { entity: { block: 'block' }, layer: 'desktop' }); | ||
}); | ||
|
||
test('should return cell with entity and tech and layer', t => { | ||
const cell = new BemCell({ | ||
entity: new BemEntityName({ block: 'block' }), | ||
tech: 'css', | ||
layer: 'desktop' | ||
}); | ||
|
||
t.deepEqual(cell.valueOf(), { entity: { block: 'block' }, tech: 'css', layer: 'desktop' }); | ||
}); |