Skip to content

Commit

Permalink
Add integration tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake Harding committed Jul 12, 2014
1 parent bc98cd6 commit f5af04b
Show file tree
Hide file tree
Showing 6 changed files with 576 additions and 27 deletions.
37 changes: 32 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
language: node_js
node_js:
- 0.10
before_script:
- npm install -g bower@1.2.8
- bower install
env:
matrix:
- TEST_SUITE=unit
- TEST_SUITE=integration BROWSER='firefox'
- TEST_SUITE=integration BROWSER='firefox:3.5'
- TEST_SUITE=integration BROWSER='firefox:3.6'
- TEST_SUITE=integration BROWSER='safari:5'
- TEST_SUITE=integration BROWSER='safari:6'
- TEST_SUITE=integration BROWSER='safari:7'
- TEST_SUITE=integration BROWSER='internet explorer:7'
- TEST_SUITE=integration BROWSER='internet explorer:8'
- TEST_SUITE=integration BROWSER='internet explorer:9'
- TEST_SUITE=integration BROWSER='internet explorer:10'
- TEST_SUITE=integration BROWSER='internet explorer:11'
#- TEST_SUITE=integration BROWSER='opera:11'
#- TEST_SUITE=integration BROWSER='opera:12'
- TEST_SUITE=integration BROWSER='chrome'
global:
- secure: VY4J2ERfrMEin++f4+UDDtTMWLuE3jaYAVchRxfO2c6PQUYgR+SW4SMekz855U/BuptMtiVMR2UUoNGMgOSKIFkIXpPfHhx47G5a541v0WNjXfQ2qzivXAWaXNK3l3C58z4dKxgPWsFY9JtMVCddJd2vQieAILto8D8G09p7bpo=
- secure: kehbNCoYUG2gLnhmCH/oKhlJG6LoxgcOPMCtY7KOI4ropG8qlypb+O2b/19+BWeO3aIuMB0JajNh3p2NL0UKgLmUK7EYBA9fQz+vesFReRk0V/KqMTSxHJuseM4aLOWA2Wr9US843VGltfODVvDN5sNrfY7RcoRx2cTK/k1CXa8=
node_js:
- 0.11
before_script:
- npm install -g grunt-cli@0.1.13
- npm install -g node-static@0.7.3
# until https://github.com/bower/bower/pull/1403 is merged
- npm install -g git://github.com/jharding/bower.git
- bower install
- grunt build
script: test/ci
addons:
sauce_connect: true
18 changes: 7 additions & 11 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ module.exports = function(grunt) {
jshintrc: '.jshintrc'
},
src: 'src/**/*.js',
test: ['test/*_spec.js'],
test: ['test/*_spec.js', 'test/integration/test.js'],
gruntfile: ['Gruntfile.js']
},

Expand Down Expand Up @@ -163,17 +163,13 @@ module.exports = function(grunt) {

connect: {
server: {
options: {
port: 8888, keepalive: true
}
options: { port: 8888, keepalive: true }
}
},

parallel: {
dev: [
{ grunt: true, args: ['server'] },
{ grunt: true, args: ['watch'] }
]
concurrent: {
options: { logConcurrentOutput: true },
dev: ['server', 'watch']
},

step: {
Expand Down Expand Up @@ -251,15 +247,15 @@ module.exports = function(grunt) {
grunt.registerTask('build', ['uglify', 'sed:version']);
grunt.registerTask('server', 'connect:server');
grunt.registerTask('lint', 'jshint');
grunt.registerTask('dev', 'parallel:dev');
grunt.registerTask('dev', 'concurrent:dev');

// load tasks
// ----------

grunt.loadNpmTasks('grunt-sed');
grunt.loadNpmTasks('grunt-exec');
grunt.loadNpmTasks('grunt-step');
grunt.loadNpmTasks('grunt-parallel');
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-uglify');
Expand Down
27 changes: 16 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,28 @@
}
],
"devDependencies": {
"chai": "^1.9.1",
"colors": "^0.6.2",
"grunt": "~0.4",
"karma": "~0.8.6",
"semver": "~1.1.3",
"grunt-sed": "~0.1",
"grunt-exec": "~0.4.5",
"grunt-contrib-watch": "~0.2",
"grunt-contrib-jshint": "~0.8",
"grunt-contrib-uglify": "~0.2.6",
"grunt-concurrent": "^0.5.0",
"grunt-contrib-clean": "~0.4.0",
"grunt-contrib-concat": "~0.1",
"grunt-contrib-connect": "~0.1",
"grunt-contrib-clean": "~0.4.0",
"grunt-parallel": "0.0.2",
"grunt-step": "~0.2.0"
"grunt-contrib-jshint": "~0.8",
"grunt-contrib-uglify": "~0.2.6",
"grunt-contrib-watch": "~0.2",
"grunt-exec": "~0.4.5",
"grunt-sed": "~0.1",
"grunt-step": "~0.2.0",
"karma": "~0.8.6",
"mocha": "^1.20.1",
"semver": "~1.1.3",
"underscore": "^1.6.0",
"yiewd": "^0.5.0"
},
"scripts": {
"test": "./node_modules/.bin/karma start --single-run --browsers PhantomJS"
},
"version": "0.10.2",
"main": "dist/typeahead.bundle.js"
}
}
12 changes: 12 additions & 0 deletions test/ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash -x

if [ "$TEST_SUITE" == "unit" ]; then
./node_modules/.bin/karma start --single-run --browsers PhantomJS
elif [ "$TRAVIS_SECURE_ENV_VARS" == "true" -a "$TEST_SUITE" == "integration" ]; then
static -p 8888 &
sleep 3
# integration tests are flaky, don't let them fail the build
./node_modules/mocha/bin/mocha --harmony -R spec ./test/integration/test.js || true
else
echo "Not running any tests"
fi
112 changes: 112 additions & 0 deletions test/integration/test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="../../bower_components/jquery/jquery.js"></script>
<script src="../../dist/typeahead.bundle.js"></script>

<style>
.container {
width: 800px;
margin: 50px auto;
}

.typeahead-wrapper {
display: block;
margin: 50px 0;
}

.tt-dropdown-menu {
background-color: #fff;
border: 1px solid #000;
}

.tt-suggestion.tt-cursor {
background-color: #ccc;
}
</style>
</head>

<body>
<div class="container">
<form action="/where" method="GET">
<div class="typeahead-wrapper">
<input id="states" name="states" type="text">
<input type="submit">
</div>
</form>
</div>

<script>
var states = new Bloodhound({
datumTokenizer: function(d) {
return Bloodhound.tokenizers.whitespace(d.val);
},
queryTokenizer: Bloodhound.tokenizers.whitespace,
local: [
{ val: 'Alabama' },
{ val: 'Alaska' },
{ val: 'Arizona' },
{ val: 'Arkansas' },
{ val: 'California' },
{ val: 'Colorado' },
{ val: 'Connecticut' },
{ val: 'Delaware' },
{ val: 'Florida' },
{ val: 'Georgia' },
{ val: 'Hawaii' },
{ val: 'Idaho' },
{ val: 'Illinois' },
{ val: 'Indiana' },
{ val: 'Iowa' },
{ val: 'Kansas' },
{ val: 'Kentucky' },
{ val: 'Louisiana' },
{ val: 'Maine' },
{ val: 'Maryland' },
{ val: 'Massachusetts' },
{ val: 'Michigan' },
{ val: 'Minnesota' },
{ val: 'Mississippi' },
{ val: 'Missouri' },
{ val: 'Montana' },
{ val: 'Nebraska' },
{ val: 'Nevada' },
{ val: 'New Hampshire' },
{ val: 'New Jersey' },
{ val: 'New Mexico' },
{ val: 'New York' },
{ val: 'North Carolina' },
{ val: 'North Dakota' },
{ val: 'Ohio' },
{ val: 'Oklahoma' },
{ val: 'Oregon' },
{ val: 'Pennsylvania' },
{ val: 'Rhode Island' },
{ val: 'South Carolina' },
{ val: 'South Dakota' },
{ val: 'Tennessee' },
{ val: 'Texas' },
{ val: 'Utah' },
{ val: 'Vermont' },
{ val: 'Virginia' },
{ val: 'Washington' },
{ val: 'West Virginia' },
{ val: 'Wisconsin' },
{ val: 'Wyoming' },
{ val: 'this is a very long value so deal with it' }
]
});

states.initialize();

$('#states').typeahead({
highlight: true
},
{
displayKey: 'val',
source: states.ttAdapter()
});
</script>
</body>
</html>
Loading

0 comments on commit f5af04b

Please sign in to comment.