...
Constructs your tests in the following order
Iteration 1
Test 1
Code Block |
---|
var assert = require("chai").assert;
var expect = require("chai").expect;
// Put your CUT here
describe('Splitting a string', function() {
it('Input an empty string, return an empty array []', function() {
// arrange...
var cut = new StringSplitter();
var expectedResult = []
var emptyString = "";
// act...
var actualResult = cut.splitString( emptyString );
console.log( actualResult.length);
// assert...
assert.equal(actualResult.length, expectedResult.length );
expect(actualResult).to.eql(expectedResult);
});
}); |
...
Code Block |
---|
class StringSplitter
{
splitString( stringToSplit )
{
var result = [];
if( stringToSplit.length < 1 )
return result;
return result;
}
} |
Iteration 2
Test 2
Code Block |
---|
var assert = require("chai").assert;
var expect = require("chai").expect;
// put your CUT here
describe('Splitting a string', function() {
it('Input an empty string, return an empty array []', function() {
// arrange...
var cut = new StringSplitter();
var expectedResult = []
var emptyString = "";
// act...
var actualResult = cut.splitString( emptyString );
console.log( actualResult.length);
// assert...
assert.equal(actualResult.length, expectedResult.length );
expect(actualResult).to.eql(expectedResult);
});
it('Input one string, return array with one item', function() {
// arrange...
var cut = new StringSplitter();
var expectedResult = ["java"]
var emptyString = "java";
// act...
var actualResult = cut.splitString( emptyString );
console.log( actualResult.length);
// assert...
assert.equal(actualResult.length, expectedResult.length );
expect(actualResult).to.eql(expectedResult);
});
}); |
Implementation 2
Code Block |
---|
class StringSplitter
{
splitString( stringToSplit )
{
var result = [];
var tempResult = stringToSplit.split( ',' );
console.log( tempResult );
if( tempResult[0].length > 1 )
result = tempResult;
return result;
}
} |