Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

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

Merged
merged 2 commits into from about 2 years ago

3 participants

Matthew Schranz Jon Buckley Christopher De Cairos
test/io/cornfield.js
((6 lines not shown))
23 23
24 24 module( "Unauthenticated tests" );
25 25
26 26 test( "Sync API", 1, function() {
27   - ok( !butter.cornfield.user(), 'Username is ""' );
  27 + ok( !butter.cornfield.user(), "Username is \"\"" );
1
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))
105 104
106 105 start();
107 106 });
108 107 });
109 108 });
110 109 });
  110 +
  111 + var failSafe = setTimeout( function() {
1
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
Christopher De Cairos cadecairos closed this
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 1 changed file with 35 additions and 31 deletions. Show diff stats Hide diff stats

  1. +35 31 test/io/cornfield.js
66 test/io/cornfield.js
@@ -8,10 +8,10 @@
8 8
9 9 QUnit.config.reorder = false;
10 10
11   - document.addEventListener( "DOMContentLoaded", function( e ){
  11 + document.addEventListener( "DOMContentLoaded", function( e ) {
12 12 var b = new Butter({
13 13 config: "cornfield-test-config.json",
14   - ready: function( butter ){
  14 + ready: function( butter ) {
15 15 var filename = "test" + Date.now(),
16 16 data = {
17 17 name: filename,
@@ -19,25 +19,25 @@
19 19 data: { stuff: "derpherp" },
20 20 template: "pop"
21 21 },
22   - stringedData = JSON.stringify(data);
  22 + stringedData = JSON.stringify( data );
23 23
24 24 module( "Unauthenticated tests" );
25 25
26 26 test( "Sync API", 1, function() {
27   - ok( !butter.cornfield.user(), 'Username is ""' );
  27 + ok( !butter.cornfield.user(), "Username is undefined" );
28 28 });
29 29
30   - asyncTest("Async API", 4, function() {
31   - butter.cornfield.logout(function(res) {
32   - equal(res, true, "Cornfield server is active");
  30 + asyncTest( "Async API", 4, function() {
  31 + butter.cornfield.logout( function( res ) {
  32 + equal( res, true, "Cornfield server is active" );
33 33
34   - butter.cornfield.list(function(res) {
  34 + butter.cornfield.list(function( res ) {
35 35 deepEqual( res, { error: "unauthorized" }, "Not allowed to list projects" );
36 36
37   - butter.cornfield.load(filename, function(res) {
  37 + butter.cornfield.load( filename, function( res ) {
38 38 deepEqual( res, { error: "unauthorized" }, "Not allowed to get projects" );
39 39
40   - butter.cornfield.save(filename, stringedData, function(res) {
  40 + butter.cornfield.save( filename, stringedData, function( res ) {
41 41 deepEqual( res, { error: "unauthorized" }, "Not allowed to save projects" );
42 42
43 43 start();
@@ -49,36 +49,35 @@
49 49
50 50 asyncTest( "/api/whoami", 1, function() {
51 51 butter.cornfield.whoami( function( res ) {
52   - deepEqual( res, {
53   - error: 'unauthorized'
54   - }, "Response is unauthorized" );
  52 + deepEqual( res, { error: "unauthorized" }, "Response is unauthorized" );
55 53 start();
56 54 });
57 55 });
58 56
59 57 module( "Authentication tests" );
60 58
61   - asyncTest("Login (user input needed)", 4, function() {
62   - butter.cornfield.login(function(res) {
63   - clearTimeout(failSafe);
64   - ok(res, 'The login response has data');
65   - equal(res.status, 'okay', 'Login status is "okay"');
66   - ok(res.email, 'The login has an email: ' + res.email);
67   - equal(res.email, butter.cornfield.user(), "Email is stored");
  59 + asyncTest( "Login (user input needed)", 4, function() {
  60 + butter.cornfield.login( function( res ) {
  61 + clearTimeout( failSafe );
  62 + ok( res, "The login response has data" );
  63 + equal( res.status, "okay", "Login status is \"okay\"" );
  64 + ok( res.email, "The login has an email: " + res.email );
  65 + equal( res.email, butter.cornfield.user(), "Email is stored" );
68 66 start();
69 67 });
70 68
71   - var failSafe = setTimeout(function() {
  69 + var failSafe = setTimeout( function() {
  70 + clearTimeout( failSafe );
72 71 start();
73 72 }, 20000 );
74 73 });
75 74
76 75 module( "Authenticated tests" );
77 76
78   - asyncTest("Async API", 7, function() {
  77 + asyncTest( "Async API", 7, function() {
79 78 var foundProject = false;
80 79
81   - butter.cornfield.list( function( res ){
  80 + butter.cornfield.list( function( res ) {
82 81 ok(res, "The project list response has data" );
83 82 equal( res.error, "okay", "Project list status is \"okay\"" );
84 83 ok( res.projects, "There is a list of projects" );
@@ -92,22 +91,27 @@
92 91
93 92 equal( false, foundProject, filename + " is not present in the projects list" );
94 93
95   - butter.cornfield.load( filename, function( res ){
  94 + butter.cornfield.load( filename, function( res ) {
96 95 deepEqual( res, { error: "project not found" }, "The project load response is project not found" );
97 96
98   - butter.cornfield.save(filename, stringedData, function(res){
  97 + butter.cornfield.save( filename, stringedData, function( res ) {
99 98 equal( res.error, "okay", "The project save response is okay" );
100 99
101 100 filename = res.project._id;
102 101
103   - butter.cornfield.load(filename, function(res){
104   - deepEqual( JSON.parse(res.project), data.data, "The project is the same" );
  102 + butter.cornfield.load( filename, function( res ) {
  103 + deepEqual( JSON.parse( res.project ), data.data, "The project is the same" );
105 104
106 105 start();
107 106 });
108 107 });
109 108 });
110 109 });
  110 +
  111 + var failSafe = setTimeout( function() {
  112 + clearTimeout( failSafe );
  113 + start();
  114 + }, 20000 );
111 115 });
112 116
113 117 asyncTest( "/api/whoami", 1, function() {
@@ -116,14 +120,14 @@
116 120 email: butter.cornfield.user(),
117 121 name: butter.cornfield.user(),
118 122 username: butter.cornfield.user()
119   - }, "Response is unauthorized" );
  123 + }, "Response contains user information" );
120 124 start();
121 125 });
122 126 });
123 127
124   - asyncTest("Logout", 1, function() {
125   - butter.cornfield.logout(function(res) {
126   - equal(res, true, "Clean-up");
  128 + asyncTest( "Logout", 1, function() {
  129 + butter.cornfield.logout( function( res ) {
  130 + equal( res, true, "Clean-up" );
127 131
128 132 start();
129 133 });

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.