Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gwt

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gwt - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

158

gwt/lib/index.js
// Generated by CoffeeScript 1.9.1
(function() {
var I, Q, _, assert, buildDescription, deepPromiseResolve, describeScenario, getCounts, interpolate,
var I, Q, Result, _, assert, buildDescription, describeScenario, getCounts, interpolate, makeResult, resolveResultArgs, resolveResults, uuid,
slice = [].slice;

@@ -14,22 +14,27 @@

exports.result = function() {
var deferredBuilder;
deferredBuilder = Q.defer();
return {
resolve: function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return deferredBuilder.resolve.apply(deferredBuilder, args);
},
then: function() {
var args, ref;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return (ref = deferredBuilder.promise).then.apply(ref, args);
},
fail: function() {
var args, ref;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return (ref = deferredBuilder.promise).fail.apply(ref, args);
}
uuid = require('node-uuid');
Result = (function() {
function Result(id1) {
this.id = id1;
assert(this.id, 'Result id not given');
}
Result.prototype.get = function(context) {
return context[this.id];
};
Result.prototype.set = function(context, value) {
return context[this.id] = value;
};
return Result;
})();
exports.result = makeResult = function(id) {
if (id == null) {
id = uuid.v4();
}
return new Result(id);
};

@@ -83,17 +88,17 @@

return it('Verify that all descriptions in the specification have been covered', function() {
var description, hasUncalled, i, j, k, len, len1, len2, ref, ref1, ref2, uncovered;
var description, hasUncalled, j, k, l, len, len1, len2, ref, ref1, ref2, uncovered;
uncovered = counts.getUncovered();
ref = uncovered.GIVEN;
for (i = 0, len = ref.length; i < len; i++) {
description = ref[i];
for (j = 0, len = ref.length; j < len; j++) {
description = ref[j];
console.error('Uncovered GIVEN:', description);
}
ref1 = counts.getUncovered().WHEN;
for (j = 0, len1 = ref1.length; j < len1; j++) {
description = ref1[j];
for (k = 0, len1 = ref1.length; k < len1; k++) {
description = ref1[k];
console.error('Uncovered WHEN:', description);
}
ref2 = counts.getUncovered().THEN;
for (k = 0, len2 = ref2.length; k < len2; k++) {
description = ref2[k];
for (l = 0, len2 = ref2.length; l < len2; l++) {
description = ref2[l];
console.error('Uncovered THEN:', description);

@@ -194,55 +199,49 @@ }

deepPromiseResolve = function(object) {
return Q(object).then(function(object) {
var deferred, fn1, fn2, i, key, promise, ref, value;
if (!object) {
return;
resolveResultArgs = function(context, args) {
var argsCopy, i, j, ref;
argsCopy = _.clone(args);
for (i = j = 0, ref = argsCopy.length; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
argsCopy[i] = resolveResults(context, argsCopy[i]);
}
return argsCopy;
};
resolveResults = function(context, object) {
var i, j, key, objectCopy, ref, result;
if (!object) {
return;
}
if (typeof object !== 'object') {
return object;
}
if (object instanceof Date) {
return object;
}
if (object instanceof RegExp) {
return object;
}
objectCopy = _.clone(object);
if (Array.isArray(objectCopy)) {
for (i = j = 0, ref = objectCopy.length; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
result = objectCopy[i];
if (result instanceof Result) {
objectCopy[i] = result.get(context);
}
}
if (typeof object !== 'object') {
return object;
return objectCopy;
}
for (key in objectCopy) {
result = objectCopy[key];
if (result instanceof Result) {
objectCopy[key] = result.get(context);
}
if (object instanceof Date) {
return object;
}
if (object instanceof RegExp) {
return object;
}
deferred = Q.defer();
promise = deferred.promise;
if (Array.isArray(object)) {
fn1 = function(key, value) {
return promise = promise.then(function() {
return deepPromiseResolve(value).then(function(innerValue) {
return object[key] = innerValue;
});
});
};
for (key = i = 0, ref = object.length; 0 <= ref ? i < ref : i > ref; key = 0 <= ref ? ++i : --i) {
fn1(key, object[key]);
}
} else {
fn2 = function(key, value) {
return promise = promise.then(function() {
return deepPromiseResolve(value).then(function(innerValue) {
return object[key] = innerValue;
});
});
};
for (key in object) {
value = object[key];
fn2(key, value);
}
}
promise = promise.then(function() {
return object;
});
deferred.resolve();
return promise;
});
}
return objectCopy;
};
describeScenario = function(spec, arg) {
var DONE, GIVEN, THEN, WHEN, bdd, counts, getGiven, getThen, getWhen, getter, only, promiseBuilderFactory;
var DONE, GIVEN, THEN, WHEN, bdd, counts, getGiven, getThen, getWhen, getter, lastResult, only, promiseBuilderFactory;
only = arg.only, counts = arg.counts;
GIVEN = spec.GIVEN, WHEN = spec.WHEN, THEN = spec.THEN, DONE = spec.DONE;
lastResult = makeResult();
getter = function(name, collection) {

@@ -259,8 +258,7 @@ return function(description) {

newContext.updateContext();
return deepPromiseResolve(args).then(function(args) {
return Q(fn.apply(newContext, args)).then(function(result) {
newContext._last_result = result;
counts[name].called(description);
return newContext;
});
args = resolveResultArgs(context, args);
return Q(fn.apply(newContext, args)).then(function(result) {
lastResult.set(newContext, result);
counts[name].called(description);
return newContext;
});

@@ -304,3 +302,3 @@ };

return bdd(descriptionBuilder, promiseBuilder.then(function(context) {
result.resolve(context._last_result);
result.set(context, lastResult.get(context));
return context;

@@ -307,0 +305,0 @@ }));

{
"name": "gwt",
"version": "0.0.3",
"version": "0.0.4",
"description": "Given, when, then",

@@ -21,2 +21,3 @@ "main": "lib/index.js",

"lodash": "^3.5.0",
"node-uuid": "^1.4.3",
"q": ">=1.0.1"

@@ -23,0 +24,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc