Skip to content

Commit

Permalink
Recupero la cobertura de los tests
Browse files Browse the repository at this point in the history
  • Loading branch information
emilioplatzer committed Jul 25, 2017
1 parent 27a48bc commit fcea800
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -3,7 +3,7 @@ node_js:
- "0.12"
- "4"
- "6"
- "7"
- "8"
matrix:
fast_finish: true
allow_failures:
Expand Down
25 changes: 15 additions & 10 deletions json4all.js
Expand Up @@ -135,13 +135,15 @@ json4all.replacer = function replacer(key, value){
var typeName = constructorName(realValue);
if(json4all.directTypes[typeName]){
return value;
}else if(types[typeName]){
var typeDef=types[typeName];
return {$special: typeDef.specialTag(realValue), $value: typeDef.deconstruct(realValue)};
// return {$special:'specialTag' in typeDef?typeDef.specialTag(realValue):typeName, $value: typeDef.deconstruct(realValue)};
}else{
console.log("JSON4all.stringify unregistered object type", typeName);
throw new Error("JSON4all.stringify unregistered object type");
var typeDef=types[typeName];
if(typeDef){
return {$special: typeDef.specialTag(realValue), $value: typeDef.deconstruct(realValue)};
// return {$special:'specialTag' in typeDef?typeDef.specialTag(realValue):typeName, $value: typeDef.deconstruct(realValue)};
}else{
console.log("JSON4all.stringify unregistered object type", typeName);
throw new Error("JSON4all.stringify unregistered object type");
}
}
};

Expand All @@ -157,11 +159,14 @@ json4all.reviver = function reviver(key, value){
return InternalValueForUndefined;
}else if(value.$special==='unset'){
return undefined;
}else if(types[value.$special]){
return new types[value.$special].construct(value.$value, types[value.$special].constructor);
}else{
console.log("JSON4all.parse invalid $special", value.$special);
throw new Error("JSON4all.parse invalid $special");
var typeDef=types[value.$special];
if(typeDef){
return new typeDef.construct(value.$value, typeDef.constructor);
}else{
console.log("JSON4all.parse invalid $special", value.$special);
throw new Error("JSON4all.parse invalid $special");
}
}
}else if(value!==null && value.$escape){
return value.$escape;
Expand Down
4 changes: 2 additions & 2 deletions test/test.js
Expand Up @@ -8,6 +8,8 @@ var JSON4all = require('../json4all.js')
var bestGlobals = require('best-globals');
var date = bestGlobals.date;

var PostgresIntervalParse = require('postgres-interval');

var deepEqual;

var runningInBrowser = typeof window !== 'undefined';
Expand Down Expand Up @@ -212,7 +214,6 @@ describe("JSON4all error conditions",function(){
});
});

/*
JSON4all.addType(PostgresIntervalParse,{
construct: JSON4all.nonymizate,
deconstruct: JSON4all.anonymizate
Expand Down Expand Up @@ -248,4 +249,3 @@ describe("addType", function(){
});
});
});
*/

0 comments on commit fcea800

Please sign in to comment.