Skip to content

Commit

Permalink
Add more tabs keyboard tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ediblecode committed Sep 26, 2016
1 parent b1009a9 commit 954eeda
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Welcome to NICE Experience. Your source for creating beautiful, consistent exper
- [Grunt](#grunt)
- [npm](#npm)
- [Node](#node)
- [Test](#tests)
- [Installation](#installation)
- [CDN](#cdn)
- [Install with npm](#install-with-npm)
Expand Down Expand Up @@ -157,14 +158,18 @@ There are a set of npm scripts within package.json, for convenience. However, it
| ---- | ----------- |
| `npm start` | Simply runs `grunt` under the hood |
| `npm test` | Runs JS tests |
| `npm run test:watch` | Runs JS test tests and watches for changes. Useful to run in development alongside grunt. |
| `npm run test:watch` | Runs JS test tests (with [min reporter](https://github.com/mochajs/mocha/blob/master/lib/reporters/min.js)) and watches for changes. Useful to run in development alongside grunt. |
| `npm run lint` | Lints SASS and JS (uses `grunt lint` under the hood) |
| `npm run serve` | Spins up an express server through Node directly (NOT via Grunt) on port *54321* |

#### Node

Once the app (CSS/JS etc) has been built, the express app can be run via Node directly e.g. `node web/server`. This isn't really useful for development as it just runs on port 3000, doesn't build assets, watch for changes etc - use `grunt` instead for deveopment.

## Tests

We use [Mocha](http://mochajs.org/) for our JS testing, see the [test folder](test/) for more information.

## Installation

### NICE CDN
Expand Down
48 changes: 47 additions & 1 deletion test/unit/tabs.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const KeyCodes = {
DownArrow: 40
};


describe("Tabs", function() {

var $,
Expand Down Expand Up @@ -232,5 +231,52 @@ describe("Tabs", function() {
t.getCurrentIndex().should.equal(2);
});

it("end keydown on tab selects last tab", function() {
var $el = $(tabsHTML);
var t = new Tabs($el);

t.getCurrentIndex().should.equal(0);

$("[role='tab']:eq(0)", $el)
.focus()
.trigger($.Event("keydown", { which: KeyCodes.End } ));

t.getCurrentIndex().should.equal(2);
});

it("home keydown on tab selects last tab", function() {
var $el = $(tabsHTML);
var t = new Tabs($el);

t.last()

t.getCurrentIndex().should.equal(2);

$("[role='tab']:eq(2)", $el)
.focus()
.trigger($.Event("keydown", { which: KeyCodes.Home } ));

t.getCurrentIndex().should.equal(0);
});

it("enter/space keydown on selects focussed tab", function() {
var $el = $(tabsHTML);
var t = new Tabs($el);

t.getCurrentIndex().should.equal(0);

$("[role='tab']:eq(1)", $el)
.focus()
.trigger($.Event("keydown", { which: KeyCodes.Space } ));

t.getCurrentIndex().should.equal(1);

$("[role='tab']:eq(2)", $el)
.focus()
.trigger($.Event("keydown", { which: KeyCodes.Enter } ));

t.getCurrentIndex().should.equal(2);
});

});
});

0 comments on commit 954eeda

Please sign in to comment.