Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
dustyo-O committed Mar 24, 2018
1 parent fc22e4f commit 2973570
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
"eslint": "^3.16.0",
"eslint-config-pedant": "^0.8.0",
"mocha": "^3.1.0",
"rimraf": "^2.5.4"
"proxyquire": "^2.0.1",
"rimraf": "^2.5.4",
"sinon": "^4.4.8"
}
}
67 changes: 67 additions & 0 deletions test/test1.js
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'
}]);
});
});
});

0 comments on commit 2973570

Please sign in to comment.