Skip to content

Commit

Permalink
quito la dependencia con postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
emilioplatzer committed Aug 22, 2017
1 parent 2197a84 commit b6e27f6
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 10 deletions.
2 changes: 1 addition & 1 deletion karma.conf.js
Expand Up @@ -14,7 +14,7 @@ module.exports = function(config, preConfig) {
// list of files / patterns to load in the browser
files: [
'node_modules/require-bro/lib/require-bro.js',
'test/postgres-interval4client.js',
'test/example-class.js',
'node_modules/express-useragent/lib/express-useragent.js',
'node_modules/best-globals/best-globals.js',
'node_modules/discrepances/lib/discrepances.js',
Expand Down
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -32,7 +32,6 @@
"istanbul-middleware": "~0.2.2",
"mocha": "~3.5.0",
"phantomjs-prebuilt": "~2.1.15",
"postgres-interval": "~1.1.1",

"best-globals": "~0.9.16",
"discrepances": "~0.1.4",
Expand Down
29 changes: 29 additions & 0 deletions test/example-class.js
@@ -0,0 +1,29 @@
"use strict";

(function codenautasModuleDefinition(root, name, factory) {
/* global define */
/* istanbul ignore next */
if(typeof root.globalModuleName !== 'string'){
root.globalModuleName = name;
}
/* istanbul ignore next */
if(typeof exports === 'object' && typeof module === 'object'){
module.exports = factory();
}else if(typeof define === 'function' && define.amd){
define(factory);
}else if(typeof exports === 'object'){
exports[root.globalModuleName] = factory();
}else{
root[root.globalModuleName] = factory();
}
root.globalModuleName = null;
})(/*jshint -W040 */this, 'ExampleClass', function() {
/*jshint +W040 */

function ExampleClass(){};

ExampleClass["4client"]=true;

return ExampleClass;

});
18 changes: 10 additions & 8 deletions test/test.js
Expand Up @@ -2,7 +2,9 @@

var expect = require('expect.js')
var discrepances = require('discrepances')
var JSON4all = require('../json4all.js')
var JSON4all = require('../json4all.js');

var ExampleClass = ExampleClass = require('./example-class.js');

var bestGlobals = require('best-globals');
var date = bestGlobals.date;
Expand Down Expand Up @@ -193,29 +195,29 @@ describe("JSON4all error conditions",function(){
});
});

JSON4all.addType(PostgresIntervalParse,{
JSON4all.addType(ExampleClass,{
construct: JSON4all.nonymizate,
deconstruct: JSON4all.anonymizate
})

describe("addType", function(){
describe("PostgresInterval", function(){
describe("ExampleClass", function(){
[
{text: "1 day", o:{days: 1}, expectedJson:(
PostgresIntervalParse["4client"] ? '{"$special":"PostgresInterval","$value":{"days":1}}'
: '{"$special":"PostgresInterval","$value":{"days":1,"toPostgres":{"$special":"unset"},"toISO":{"$special":"unset"}}}'
ExampleClass["4client"] ? '{"$special":"ExampleClass","$value":{"days":1}}'
: '{"$special":"ExampleClass","$value":{"days":1,"toISO":{"$special":"unset"}}}'
)},
{text: "1 year 2 month 3 days 4:05:06", o:{years:1, months:2, days:3, hours:4, minutes:5, seconds:6}},
{text: "10:30", o:{hours: 10, minutes:30}},
].forEach(function(fixture){
it("handles interval "+fixture.text, function(){
if(PostgresIntervalParse["4client"]){
var interval = new PostgresIntervalParse();
if(ExampleClass["4client"]){
var interval = new ExampleClass();
for(var attr in fixture.o){
interval[attr] = fixture.o[attr];
}
}else{
var interval = PostgresIntervalParse(fixture.text);
var interval = ExampleClass(fixture.text);
}
var intervalJson = JSON4all.stringify(interval);
if(fixture.expectedJson){
Expand Down

0 comments on commit b6e27f6

Please sign in to comment.