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

pg-minify

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pg-minify - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

4

package.json
{
"name": "pg-minify",
"version": "0.0.1",
"version": "0.0.2",
"description": "Minify PostgreSQL scripts",

@@ -36,4 +36,2 @@ "main": "lib/index.js",

},
"dependencies": {
},
"devDependencies": {

@@ -40,0 +38,0 @@ "coveralls": "2.x",

@@ -6,21 +6,4 @@ 'use strict';

var parser = require('../lib/parser');
var errorLib = require('../lib/error');
describe("EOL", function () {
it("must detect empty text correctly", function () {
expect(parser.getEOL("")).toBe(LB);
expect(parser.getEOL(" ")).toBe(LB);
});
it("must detect Unix correctly", function () {
expect(parser.getEOL("\n")).toBe("\n");
expect(parser.getEOL("\r\n\n\n")).toBe("\n");
});
it("must detect Windows correctly", function () {
expect(parser.getEOL("\r\n")).toBe("\r\n");
expect(parser.getEOL("\r\n\n\r\n")).toBe("\r\n");
});
});
describe("Minify/Positive", function () {

@@ -31,2 +14,4 @@

expect(minify("--comment")).toBe("");
expect(minify("--comment" + LB)).toBe("");
expect(minify(LB + "--comment")).toBe("");
});

@@ -38,5 +23,16 @@ });

expect(minify("text--comment")).toBe("text");
expect(minify(" text --comment")).toBe("text");
expect(minify("text" + LB + "--comment")).toBe("text");
expect(minify(" text " + LB + "--comment")).toBe("text");
expect(minify("text--comment" + LB)).toBe("text");
});
});
describe("single-line comment with a suffix", function () {
it("must return the suffix", function () {
expect(minify("--comment" + LB + "text")).toBe("text");
expect(minify("--comment" + LB + " text ")).toBe("text");
});
});
describe("comments in strings", function () {

@@ -55,2 +51,3 @@ it("must be skipped", function () {

});
describe("quotes in strings", function () {

@@ -65,3 +62,2 @@ it("must be ignored", function () {

it("must be ignored", function () {
expect(minify("--comment" + LB + "text")).toBe("text");
expect(minify("--comment" + LB + LB + "text")).toBe("text");

@@ -72,6 +68,5 @@ expect(minify("/*start" + LB + "end*/")).toBe("");

expect(minify("start/*comment*/" + LB + "end")).toBe("start end");
expect(minify("start/*comment*/" + LB + " end")).toBe("start end");
expect(minify("/*comment*/end " + LB)).toBe("end");
expect(minify("/*start" + LB + "end*/" + LB + "text")).toBe("text");
});

@@ -95,7 +90,16 @@ });

try {
minify("'''text");
} catch (e) {
//expect(e.inspect()).toBe(e.message + LB + LB + e.stack);
}
expect(function () {
minify("'''");
}).toThrow(new errorLib.SQLParsingError(errorLib.parsingErrorCode.unclosedText, "Unclosed text block.", {
line: 1,
column: 1
}));
expect(function () {
minify("/*");
}).toThrow(new errorLib.SQLParsingError(errorLib.parsingErrorCode.unclosedMLC, "Unclosed multi-line comment.", {
line: 1,
column: 1
}));
});

@@ -119,2 +123,20 @@ });

describe("EOL", function () {
it("must detect empty text correctly", function () {
expect(parser.getEOL("")).toBe(LB);
expect(parser.getEOL(" ")).toBe(LB);
});
it("must detect Unix correctly", function () {
expect(parser.getEOL("\n")).toBe("\n");
expect(parser.getEOL("\r\n\n\n")).toBe("\n");
});
it("must detect Windows correctly", function () {
expect(parser.getEOL("\r\n")).toBe("\r\n");
expect(parser.getEOL("\r\n\n\r\n")).toBe("\r\n");
});
});
describe("Index Position:", function () {

@@ -126,19 +148,23 @@

describe("", function () {
it("", function () {
expect(pos("123\r\n456", 0)).toEqual({
line: 1,
column: 1
});
expect(pos("123\r\n456", 5)).toEqual({
line: 2,
column: 1
});
expect(pos("123\r\n", 3)).toEqual({
line: 1,
column: 3
});
it("must work from the start", function () {
expect(pos("123\r\n456", 0)).toEqual({
line: 1,
column: 1
});
});
it("step over lines correctly", function () {
expect(pos("123\r\n456", 5)).toEqual({
line: 2,
column: 1
});
});
it("must step back from a line break", function () {
expect(pos("123\r\n", 3)).toEqual({
line: 1,
column: 3
});
});
});
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