From b6e27f694ac8558b6fdf0ced536a0d580bef153a Mon Sep 17 00:00:00 2001 From: Emilio Date: Tue, 22 Aug 2017 20:22:28 -0300 Subject: [PATCH] quito la dependencia con postgres --- karma.conf.js | 2 +- package.json | 1 - test/example-class.js | 29 +++++++++++++++++++++++++++++ test/test.js | 18 ++++++++++-------- 4 files changed, 40 insertions(+), 10 deletions(-) create mode 100644 test/example-class.js diff --git a/karma.conf.js b/karma.conf.js index 335f8ab..1ef6bf8 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -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', diff --git a/package.json b/package.json index 556df81..15393b2 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/example-class.js b/test/example-class.js new file mode 100644 index 0000000..3bf5dd1 --- /dev/null +++ b/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; + +}); \ No newline at end of file diff --git a/test/test.js b/test/test.js index c551cad..8a36e47 100644 --- a/test/test.js +++ b/test/test.js @@ -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; @@ -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){