Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
188 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Karma configuration | ||
// Generated on Wed Jun 11 2014 23:05:41 GMT+0100 (BST) | ||
|
||
module.exports = function(config) { | ||
config.set({ | ||
|
||
// base path that will be used to resolve all patterns (eg. files, exclude) | ||
basePath: '', | ||
|
||
|
||
// frameworks to use | ||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter | ||
frameworks: ['jasmine'], | ||
|
||
|
||
// list of files / patterns to load in the browser | ||
files: [ | ||
'src/qwerty-hancock.js', | ||
'tests/*.js' | ||
], | ||
|
||
|
||
// list of files to exclude | ||
exclude: [ | ||
|
||
], | ||
|
||
|
||
// preprocess matching files before serving them to the browser | ||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor | ||
preprocessors: { | ||
|
||
}, | ||
|
||
|
||
// test results reporter to use | ||
// possible values: 'dots', 'progress' | ||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter | ||
reporters: ['progress'], | ||
|
||
|
||
// web server port | ||
port: 9876, | ||
|
||
|
||
// enable / disable colors in the output (reporters and logs) | ||
colors: true, | ||
|
||
|
||
// level of logging | ||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG | ||
logLevel: config.LOG_INFO, | ||
|
||
|
||
// enable / disable watching file and executing tests whenever any file changes | ||
autoWatch: true, | ||
|
||
|
||
// start these browsers | ||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher | ||
browsers: ['Chrome', 'Firefox', 'ChromeCanary', 'Safari', 'PhantomJS', 'Opera'], | ||
|
||
|
||
// Continuous Integration mode | ||
// if true, Karma captures browsers, runs the tests and exits | ||
singleRun: false | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
'use strict'; | ||
|
||
describe('Qwerty Hancock tests', function () { | ||
var element; | ||
|
||
beforeEach(function () { | ||
element = document.createElement('div'); | ||
element.id = 'keyboard'; | ||
document.body.appendChild(element); | ||
}); | ||
|
||
it('Can create keyboard without any user settings', function () { | ||
var qh = new QwertyHancock(); | ||
|
||
expect(element.id).toBe('keyboard'); | ||
expect(element.offsetWidth).toBe(600); | ||
expect(element.offsetHeight).toBe(150); | ||
expect(element.querySelector('ul').offsetWidth).toBe(600); | ||
expect(element.querySelector('ul').offsetHeight).toBe(150); | ||
}); | ||
|
||
it('Can create keyboard with user specified dimensions', function () { | ||
var qh = new QwertyHancock({width: 500, height: 300}); | ||
|
||
expect(element.offsetWidth).toBe(500); | ||
expect(element.offsetHeight).toBe(300); | ||
}); | ||
|
||
it('White keys should be white by default', function () { | ||
var qh = new QwertyHancock(), | ||
white_keys = element.querySelectorAll('li[data-note-type="white"]'); | ||
|
||
for (var i = 0; i < white_keys.length; i++) { | ||
expect(white_keys[i].style.backgroundColor).toBe('rgb(255, 255, 255)'); | ||
} | ||
}); | ||
|
||
it('Black keys should be black by default', function () { | ||
var qh = new QwertyHancock(), | ||
black_keys = element.querySelectorAll('li[data-note-type="black"]'); | ||
|
||
for (var i = 0; i < black_keys.length; i++) { | ||
expect(black_keys[i].style.backgroundColor).toBe('rgb(0, 0, 0)'); | ||
} | ||
}); | ||
|
||
it('White keys should be user defined colour', function () { | ||
var qh = new QwertyHancock({whiteKeyColour: '#333'}), | ||
white_keys = element.querySelectorAll('li[data-note-type="white"]'); | ||
|
||
for (var i = 0; i < white_keys.length; i++) { | ||
expect(white_keys[i].style.backgroundColor).toBe('rgb(51, 51, 51)'); | ||
} | ||
}); | ||
|
||
it('Black keys should be user defined colour', function () { | ||
var qh = new QwertyHancock({blackKeyColour: 'red'}), | ||
black_keys = element.querySelectorAll('li[data-note-type="black"]'); | ||
|
||
for (var i = 0; i < black_keys.length; i++) { | ||
expect(black_keys[i].style.backgroundColor).toBe('red'); | ||
} | ||
}); | ||
|
||
afterEach(function () { | ||
document.body.removeChild(element); | ||
}); | ||
}); |