Skip to content
This repository has been archived by the owner on Mar 26, 2018. It is now read-only.

Commit

Permalink
fixes #7 | start working
Browse files Browse the repository at this point in the history
  • Loading branch information
prisis committed Oct 8, 2015
1 parent bf1ec7b commit bfe6c69
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 1 deletion.
18 changes: 18 additions & 0 deletions dist/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,24 @@ function extractTestsFromString(string) {
return _lodash2['default'].map(_lodash2['default'].reject(string.split(/.*@it\s?/), _utils.isEmpty), extractTestFromString);
}

function getDescribe(string, nummber) {
var describe = string.match(/@describe.*/g).map(_utils.trimNewlines);

if (describe[nummber] !== '') {
return describe[nummber].replace('@describe ', '');
}

return '';
}

function extractMainDescribeFromTest(testString) {
var describe = getDescribe(testString, 0);
}

function extractDescribeFromTest(string) {
var describe = getDescribe(testString, 1);
}

exports['default'] = function (file) {
return extractTestsFromString(getFile(file));
};
Expand Down
20 changes: 20 additions & 0 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,26 @@ function extractTestsFromString(string) {
);
}

function getDescribe(string, nummber) {
const describe = string.match(/@describe.*/g).map(trimNewlines);

if (describe[nummber] !== '') {
return describe[nummber].replace('@describe ', '');
}

return '';
}

function extractMainDescribeFromTest(testString) {
const describe = getDescribe(testString, 0);

}

function extractDescribeFromTest(string) {
const describe = getDescribe(testString, 1);

}

export default function(file) {
return extractTestsFromString(getFile(file));
}
4 changes: 4 additions & 0 deletions tests/fixture/describe.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* @describe test
* @describe test2
*/
18 changes: 18 additions & 0 deletions tests/specs/parser.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/specs/parser.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions tests/src/parser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,14 @@ describe('#parser:extractTestFromString', function() {
// assert.equal(extractTestFromString('./tests/fixture/textFile.txt'), 'dasdada');
});
});

describe('#parser:getDescribe', function() {
it('get describe', function() {
var getDescribe = utils.__get__('getDescribe');
var getFile = utils.__get__('getFile');
var string = getFile('./tests/fixture/describe.styl');

assert.equal(getDescribe(string, 0), 'test');
assert.equal(getDescribe(string, 1), 'test2');
});
});

0 comments on commit bfe6c69

Please sign in to comment.