From cace2f6ebf1baf2c0744ff9e85c653104c40f4cb Mon Sep 17 00:00:00 2001 From: Borys Levytskyi Date: Sun, 12 Apr 2015 15:26:34 +0300 Subject: [PATCH] Added e2e test cases --- src/index.html | 4 +-- tests/e2e.chrome.conf.js | 1 + tests/e2e/spec.js | 59 +++++++++++++++++++++++++++++----------- 3 files changed, 46 insertions(+), 18 deletions(-) diff --git a/src/index.html b/src/index.html index be66084..110fdb0 100644 --- a/src/index.html +++ b/src/index.html @@ -142,12 +142,12 @@ - + - +
{m.operand1.input}{m.operand1Binary}{m.operand1.bin.padLeft(m.bitsSize, '0')} {m.operand1.other}
{m.sign}{m.operand1.input}={m.result.input}{m.resultBinary}{m.result.bin.padLeft(m.bitsSize, '0')} {m.result.other}
diff --git a/tests/e2e.chrome.conf.js b/tests/e2e.chrome.conf.js index 40f8348..55ca9b3 100644 --- a/tests/e2e.chrome.conf.js +++ b/tests/e2e.chrome.conf.js @@ -2,6 +2,7 @@ exports.config = { seleniumAddress: 'http://127.0.0.1:4444/wd/hub', specs: [ + './e2e/cmdDriver.js', './e2e/spec.js' ], diff --git a/tests/e2e/spec.js b/tests/e2e/spec.js index 1b8bf14..0c84fa7 100644 --- a/tests/e2e/spec.js +++ b/tests/e2e/spec.js @@ -62,14 +62,40 @@ describe('launch of application', function() { it('should do a shift operation', function() { - driver.get(appUrl) - .then(function() { - return assertOperation('1<<1', - [{ label: '1', bin:'00000001', other: '0x1'}, - { label: '1<<1=2', bin:'00000010', other: '0x2'}]) - }); + return assertOperation('1<<1', + [{ label: '1', bin:'00000001', other: '0x1'}, + { label: '1<<1=2', bin:'00000010', other: '0x2'}]) }); + it('should do a ignroe sign RIGHT shift operation', function() { + + return assertOperation('-1>>>1', + [{ label: '-1', bin:'11111111111111111111111111111111', other: '-0x1'}, + { label: '-1>>>1=2147483647', bin:'01111111111111111111111111111111', other: '0x7fffffff'}]) + }); + + it('should do NOT operation', function() { + + return assertOperation('~1', + [{ label: '1', bin:'00000000000000000000000000000001', other: '0x1'}, + { label: '~1=-2', bin:'11111111111111111111111111111110', other: '-0x2'}]) + }); + + it('should do OR operation', function() { + + return assertOperation('1|2', + [{ label: '1', bin:'00000001', other: '0x1'}, + { label: '2', bin:'00000010', other: '0x2'}, + { label: '3', bin:'00000011', other: '0x3'}]) + }); + + it('should do prefer hex result', function() { + + return assertOperation('1|0x2', + [{ label: '1', bin:'00000001', other: '0x1'}, + { label: '0x2', bin:'00000010', other: '2'}, + { label: '0x3', bin:'00000011', other: '3'}]) + }); xit('should emphasize bytes', function() { @@ -103,7 +129,6 @@ function assertNoErrors(cmd) { }); } - function assertBitwiseNumbersResults(contaier, array) { return contaier.findElement(By.css('.expression')).then(function (tableExpr){ @@ -118,11 +143,11 @@ function assertBitwiseNumbersResults(contaier, array) { } }); }); - } function assertSingleRowResult(row, label, bin, other) { - return row.findElement(by.css('.label')).then(function (tbLabel) { + + return row.findElement(by.css('.label')).then(function (tbLabel) { expect(tbLabel.getText()).toBe(label); }).then(function () { return row.findElement(by.css('.bin')).then(function (tdBin) { @@ -136,11 +161,13 @@ function assertSingleRowResult(row, label, bin, other) { } function assertOperation(op, expected) { - return sendCommand('clear') - .then(function() { return sendCommand(op)}) - .then(assertNoErrors) - .then(function() { - return assertBitwiseNumbersResults(driver, - expected) - }); + + return driver.get(appUrl).then(function() { + return sendCommand('clear') + .then(function() { return sendCommand(op)}) + .then(assertNoErrors) + .then(function() { + return assertBitwiseNumbersResults(driver, expected) + }); + }) } \ No newline at end of file