-
Notifications
You must be signed in to change notification settings - Fork 4
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
2 changed files
with
70 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
const mkdirp = require('mkdirp'); | ||
const rimraf = require('rimraf'); | ||
const proxyquire = require('proxyquire'); | ||
const naming = require('@bem/naming'); | ||
const EOL = require('os').EOL; | ||
const assert = require('assert'); | ||
const stream = require('stream'); | ||
const sinon = require('sinon'); | ||
const createEntity = () => {}; | ||
|
||
const create = proxyquire('../lib/create', | ||
{ | ||
'./create-entity': createEntity | ||
} | ||
); | ||
|
||
|
||
const templates = { | ||
css: require('../lib/templates/css') | ||
}; | ||
|
||
function testEntityHelper(entities, levels, techs, options, expected) { | ||
var spy = sinon.spy(createEntity); | ||
|
||
return create(entities, levels, techs, options).then(created => { | ||
|
||
console.log(spy); | ||
assert(spy.callCount === entities.length); // вызвана столько-то раз | ||
|
||
expected.forEach(file => { | ||
spy.calledWith(file.name, file.content); // вызывалась с expected параметрам | ||
|
||
/* if (typeof file.content === 'undefined') { | ||
file.content = ''; | ||
}*/ | ||
}); | ||
|
||
if (created.length !== 0) { | ||
throw new Error(`${created} should not be created but it was`); | ||
} | ||
}); | ||
} | ||
|
||
describe('bem-tools-create', () => { | ||
describe('default scheme and default naming', () => { | ||
it('should create a block using `nested` scheme and default naming', () => { | ||
var spy = sinon.spy(createEntity); | ||
|
||
create({ block: 'b' }, ['/tmp'], ['css']).then(() => { | ||
assert(spy.calledOnce); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('default scheme and default naming', () => { | ||
it('should create a block using `nested` scheme and default naming', () => { | ||
return testEntityHelper([{ block: 'b' }], ['./'], ['css'], {}, [{ | ||
name: path.join('./', 'b', 'b.css'), | ||
content: 'b' | ||
}]); | ||
}); | ||
}); | ||
}); |