Skip to content

Commit

Permalink
Added atm.setFDKsActiveMask() test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
timgabets committed Nov 28, 2017
1 parent 72fdb38 commit 5622505
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 40 deletions.
40 changes: 0 additions & 40 deletions spec/controllers/AtmSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,46 +59,6 @@ describe("ATM", function() {
});


describe("setFDKsActiveMask()", function(){
it("FDK mask 000 should enable disable all the buttons", function(){
expect(atm.activeFDKs).toEqual([]);
atm.setFDKsActiveMask('000');
expect(atm.activeFDKs).toEqual([]);
});

it("FDK mask 060 should enable C, D, F and G buttons", function(){
expect(atm.activeFDKs).toEqual([]);
atm.setFDKsActiveMask('060');
expect(atm.activeFDKs).toEqual(['C', 'D', 'F', 'G']);
});

it("FDK mask 255 should enable all the buttons", function(){
expect(atm.activeFDKs).toEqual([]);
atm.setFDKsActiveMask('255');
expect(atm.activeFDKs).toEqual(['A', 'B', 'C', 'D', 'F', 'G', 'H', 'I']);
});

it("should leave the current FDK mask unchanged if new FDK mask is invalid", function(){
expect(atm.activeFDKs).toEqual([]);
atm.setFDKsActiveMask('129');
expect(atm.activeFDKs).toEqual(['A', 'I']);
atm.setFDKsActiveMask('666');
expect(atm.activeFDKs).toEqual(['A', 'I']);
});

it("FDK mask 0100010000 should enable buttons A, E (Cancel) and F", function(){
expect(atm.activeFDKs).toEqual([]);
atm.setFDKsActiveMask('0100011000');
expect(atm.activeFDKs).toEqual(['A', 'E', 'F']);
});

it("FDK mask 0111111111 should enable all the buttons", function(){
expect(atm.activeFDKs).toEqual([]);
atm.setFDKsActiveMask('0111111111');
expect(atm.activeFDKs).toEqual(['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I']);
});
});

describe("isFDKButtonActive()", function(){
it("should return undefined if button value is not provided", function(){
expect(atm.isFDKButtonActive()).toBeUndefined();
Expand Down
53 changes: 53 additions & 0 deletions tests/controllers/atm.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,57 @@ test('should respond with "Ready" message to "State Tables load" host message',
t.deepEqual(atm.processHostMessage(host_message), status_ready);
});

/**
* describe("setFDKsActiveMask()', t => {
*/
test('FDK mask 000 should enable disable all the buttons', t => {
const atm = new ATM(settings, log);

t.deepEqual(atm.activeFDKs, []);
atm.setFDKsActiveMask('000');
t.deepEqual(atm.activeFDKs, []);
});

test('FDK mask 060 should enable C, D, F and G buttons', t => {
const atm = new ATM(settings, log);

t.deepEqual(atm.activeFDKs, []);
atm.setFDKsActiveMask('060');
t.deepEqual(atm.activeFDKs, ['C', 'D', 'F', 'G']);
});

test('FDK mask 255 should enable all the buttons', t => {
const atm = new ATM(settings, log);

t.deepEqual(atm.activeFDKs, []);
atm.setFDKsActiveMask('255');
t.deepEqual(atm.activeFDKs, ['A', 'B', 'C', 'D', 'F', 'G', 'H', 'I']);
});

test('should leave the current FDK mask unchanged if new FDK mask is invalid', t => {
const atm = new ATM(settings, log);

t.deepEqual(atm.activeFDKs, []);
atm.setFDKsActiveMask('129');
t.deepEqual(atm.activeFDKs, ['A', 'I']);
atm.setFDKsActiveMask('666');
t.deepEqual(atm.activeFDKs, ['A', 'I']);
});

test('FDK mask 0100010000 should enable buttons A, E (Cancel) and F', t => {
const atm = new ATM(settings, log);

t.deepEqual(atm.activeFDKs, []);
atm.setFDKsActiveMask('0100011000');
t.deepEqual(atm.activeFDKs, ['A', 'E', 'F']);
});

test('FDK mask 0111111111 should enable all the buttons', t => {
const atm = new ATM(settings, log);

t.deepEqual(atm.activeFDKs, []);
atm.setFDKsActiveMask('0111111111');
t.deepEqual(atm.activeFDKs, ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I']);
});


0 comments on commit 5622505

Please sign in to comment.