Implemented e2e tests

This commit is contained in:
Borys Levytskyi
2015-04-15 21:26:09 +03:00
parent 8e30d2f899
commit 1ed28a7bb0
4 changed files with 58 additions and 5 deletions

View File

@@ -17,7 +17,7 @@ code { font-size: 1.2em; font-weight: bold; }
.expression .label { font-weight: bold; padding-right: 5px; text-align: right; }
.expression .bin { letter-spacing: 3px; }
.expression .byte { margin: 0 3px; }
.expression .result td { border-top: dotted 1px gray; }
.expression-result td { border-top: dotted 1px gray; }
.expression { font-size: 1.5em; font-family: monospace }
.expression .prefix { font-weight: normal; display: none; font-size: 0.9em }
.expression .other { font-size: 0.9em}

View File

@@ -132,7 +132,7 @@
<td class="bin">{m.operand1.bin.padLeft(m.bitsSize, '0')}</td>
<td class="other">{m.operand1.other}</td>
</tr>
<tr class="result">
<tr class="expression-result">
<td class="label">{m.string.replace(/\s/g,'')}={m.result.input}</td>
<td class="bin">{m.result.bin.padLeft(m.bitsSize, '0')}</td>
<td class="other">{m.result.other}</td>
@@ -147,7 +147,7 @@
<td class="bin">{m.operand1.bin.padLeft(m.bitsSize, '0')}</td>
<td class="other">{m.operand1.other}</td>
</tr>
<tr class="result">
<tr class="expression-result">
<td class="label">{m.sign}{m.operand1.input}={m.result.input}</td>
<td class="bin">{m.result.bin.padLeft(m.bitsSize, '0')}</td>
<td class="other">{m.result.other}</td>
@@ -169,7 +169,7 @@
<td class="bin">{m.operand2.bin.padLeft(m.bitsSize, '0')}</td>
<td class="other">{m.operand2.other}</td>
</tr>
<tr class="result">
<tr class="expression-result">
<td>=</td>
<td class="label">{m.result.input}</td>
<td class="bin">{m.result.bin.padLeft(m.bitsSize, '0')}</td>

View File

@@ -79,6 +79,28 @@ describe('launch of application', function() {
{ label: '~1=-2', bin:'11111111111111111111111111111110', other: '-0x2'}])
});
it('should execute multiple expressions from hash arguments', function() {
var url = appUrl + "||16,15||16&15";
console.log('accessing url: ', url);
return driver.get(url)
.then(function() { return driver.navigate().refresh(); })
.then(assertNoErrors)
.then(function() {
return assertMultipleExpressionResults(driver, [
//16&15
[{ label: '16', bin:'00010000', other: '0x10'},
{ label: '15', bin:'00001111', other: '0xf'},
{ label: '0', bin:'00000000', other: '0x0'}],
//16 15
[{ label: '16', bin:'00010000', other: '0x10'},
{ label: '15', bin:'00001111', other: '0xf'}]
])
})
});
it('should do OR operation', function() {
return assertOperation('1|2',
@@ -87,6 +109,8 @@ describe('launch of application', function() {
{ label: '3', bin:'00000011', other: '0x3'}])
});
it('should do prefer hex result', function() {
return assertOperation('1|0x2',
@@ -95,6 +119,7 @@ describe('launch of application', function() {
{ label: '0x3', bin:'00000011', other: '3'}])
});
it('should create hashlink', function() {
var expected = [{ label: '1', bin:'00000001', other: '0x1'},
{ label: '0x2', bin:'00000010', other: '2'},
@@ -139,12 +164,27 @@ function sendCommand(cmd) {
});
}
function assertNoErrors(cmd) {
function assertNoErrors() {
return driver.findElements(By.css('.result .error')).then(function(els) {
expect(els.length).toBe(0, "There should be no errors");
});
}
function assertMultipleExpressionResults(contaier, array) {
return contaier.findElements(By.css('.result'))
.then(function (results){
expect(results.length).toBe(array.length, 'Expression results number mismatch');
var all= null, cur;
for(var i=0; i<results.length;i++) {
var expected = array[i];
cur = assertExpressionResult(results[i], expected);
all = all == null ? cur : all.then(cur);
}
return all;
});
}
function assertExpressionResult(contaier, array) {
return contaier.findElement(By.css('.expression'))
@@ -187,3 +227,7 @@ function assertOperation(op, expected) {
});
})
}
function refreshBrowser() {
return driver.navigate().refresh();
}

View File

@@ -22,6 +22,13 @@ describe('hash arguments parser', function() {
expect(args.commands).toEqual(['1|2', '1^2', '~2']);
});
it('should parse multiple commands with clear', function() {
var args = hash.getArgs('#clear||16,15||16&15');
expect(args).not.toBe(null);
expect(args).toBeDefined();
expect(args.commands).toEqual(['clear', '16 15', '16&15']);
});
it('should parse multiple commands url encoded', function() {
var args = hash.getArgs('#' + encodeURI('1|2||1^2||~2'));
expect(args).not.toBe(null);
@@ -47,4 +54,6 @@ describe('hash arguments parser', function() {
expect(args.debug).toBe(true);
});
});