Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

[#1267] Cornfield tests fail gracefully without manual input. Fixed Styl... #332

Merged
merged 2 commits into from

3 participants

Matthew Schranz Jon Buckley Christopher De Cairos
test/io/cornfield.js
((6 lines not shown))
module( "Unauthenticated tests" );
test( "Sync API", 1, function() {
- ok( !butter.cornfield.user(), 'Username is ""' );
+ ok( !butter.cornfield.user(), "Username is \"\"" );
Jon Buckley Owner
jbuck added a note

This looks ugly. And is wrong too; change it to Username is undefined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Jon Buckley jbuck commented on the diff
test/io/cornfield.js
((18 lines not shown))
start();
});
});
});
});
+
+ var failSafe = setTimeout( function() {
Jon Buckley Owner
jbuck added a note

There's no manual input required here, so why do we need the timeout?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Christopher De Cairos cadecairos merged commit b84bf5d into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 35 additions and 31 deletions.
  1. +35 −31 test/io/cornfield.js
66 test/io/cornfield.js
View
@@ -8,10 +8,10 @@
QUnit.config.reorder = false;
- document.addEventListener( "DOMContentLoaded", function( e ){
+ document.addEventListener( "DOMContentLoaded", function( e ) {
var b = new Butter({
config: "cornfield-test-config.json",
- ready: function( butter ){
+ ready: function( butter ) {
var filename = "test" + Date.now(),
data = {
name: filename,
@@ -19,25 +19,25 @@
data: { stuff: "derpherp" },
template: "pop"
},
- stringedData = JSON.stringify(data);
+ stringedData = JSON.stringify( data );
module( "Unauthenticated tests" );
test( "Sync API", 1, function() {
- ok( !butter.cornfield.user(), 'Username is ""' );
+ ok( !butter.cornfield.user(), "Username is undefined" );
});
- asyncTest("Async API", 4, function() {
- butter.cornfield.logout(function(res) {
- equal(res, true, "Cornfield server is active");
+ asyncTest( "Async API", 4, function() {
+ butter.cornfield.logout( function( res ) {
+ equal( res, true, "Cornfield server is active" );
- butter.cornfield.list(function(res) {
+ butter.cornfield.list(function( res ) {
deepEqual( res, { error: "unauthorized" }, "Not allowed to list projects" );
- butter.cornfield.load(filename, function(res) {
+ butter.cornfield.load( filename, function( res ) {
deepEqual( res, { error: "unauthorized" }, "Not allowed to get projects" );
- butter.cornfield.save(filename, stringedData, function(res) {
+ butter.cornfield.save( filename, stringedData, function( res ) {
deepEqual( res, { error: "unauthorized" }, "Not allowed to save projects" );
start();
@@ -49,36 +49,35 @@
asyncTest( "/api/whoami", 1, function() {
butter.cornfield.whoami( function( res ) {
- deepEqual( res, {
- error: 'unauthorized'
- }, "Response is unauthorized" );
+ deepEqual( res, { error: "unauthorized" }, "Response is unauthorized" );
start();
});
});
module( "Authentication tests" );
- asyncTest("Login (user input needed)", 4, function() {
- butter.cornfield.login(function(res) {
- clearTimeout(failSafe);
- ok(res, 'The login response has data');
- equal(res.status, 'okay', 'Login status is "okay"');
- ok(res.email, 'The login has an email: ' + res.email);
- equal(res.email, butter.cornfield.user(), "Email is stored");
+ asyncTest( "Login (user input needed)", 4, function() {
+ butter.cornfield.login( function( res ) {
+ clearTimeout( failSafe );
+ ok( res, "The login response has data" );
+ equal( res.status, "okay", "Login status is \"okay\"" );
+ ok( res.email, "The login has an email: " + res.email );
+ equal( res.email, butter.cornfield.user(), "Email is stored" );
start();
});
- var failSafe = setTimeout(function() {
+ var failSafe = setTimeout( function() {
+ clearTimeout( failSafe );
start();
}, 20000 );
});
module( "Authenticated tests" );
- asyncTest("Async API", 7, function() {
+ asyncTest( "Async API", 7, function() {
var foundProject = false;
- butter.cornfield.list( function( res ){
+ butter.cornfield.list( function( res ) {
ok(res, "The project list response has data" );
equal( res.error, "okay", "Project list status is \"okay\"" );
ok( res.projects, "There is a list of projects" );
@@ -92,22 +91,27 @@
equal( false, foundProject, filename + " is not present in the projects list" );
- butter.cornfield.load( filename, function( res ){
+ butter.cornfield.load( filename, function( res ) {
deepEqual( res, { error: "project not found" }, "The project load response is project not found" );
- butter.cornfield.save(filename, stringedData, function(res){
+ butter.cornfield.save( filename, stringedData, function( res ) {
equal( res.error, "okay", "The project save response is okay" );
filename = res.project._id;
- butter.cornfield.load(filename, function(res){
- deepEqual( JSON.parse(res.project), data.data, "The project is the same" );
+ butter.cornfield.load( filename, function( res ) {
+ deepEqual( JSON.parse( res.project ), data.data, "The project is the same" );
start();
});
});
});
});
+
+ var failSafe = setTimeout( function() {
Jon Buckley Owner
jbuck added a note

There's no manual input required here, so why do we need the timeout?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ clearTimeout( failSafe );
+ start();
+ }, 20000 );
});
asyncTest( "/api/whoami", 1, function() {
@@ -116,14 +120,14 @@
email: butter.cornfield.user(),
name: butter.cornfield.user(),
username: butter.cornfield.user()
- }, "Response is unauthorized" );
+ }, "Response contains user information" );
start();
});
});
- asyncTest("Logout", 1, function() {
- butter.cornfield.logout(function(res) {
- equal(res, true, "Clean-up");
+ asyncTest( "Logout", 1, function() {
+ butter.cornfield.logout( function( res ) {
+ equal( res, true, "Clean-up" );
start();
});
Something went wrong with that request. Please try again.