@nodeteam/nestjs-pipes
Advanced tools
Comparing version 1.2.3 to 1.2.4
@@ -19,3 +19,3 @@ "use strict"; | ||
const [key, order] = rule.split(':'); | ||
const orderLowerCase = order.toLocaleLowerCase(); | ||
const orderLowerCase = order.trim().toLocaleLowerCase(); | ||
if (!['asc', 'desc'].includes(orderLowerCase)) { | ||
@@ -22,0 +22,0 @@ throw new common_1.BadRequestException(`Invalid order: ${orderLowerCase}`); |
@@ -8,11 +8,27 @@ "use strict"; | ||
describe('parseObjectLiteral', () => { | ||
it('should parse a string like "a: 1, b: 2" to [["a", "1"], ["b", "2"]]', () => { | ||
const obj = 'a: 1, b: 2'; | ||
const result = (0, parse_object_literal_1.default)(obj); | ||
expect(result).toEqual([['a', '1'], ['b', '2']]); | ||
it('should parse a string with one key-value pair', () => { | ||
const input = 'a: 1'; | ||
const expectedOutput = [['a', '1']]; | ||
const actualOutput = (0, parse_object_literal_1.default)(input); | ||
expect(actualOutput).toEqual(expectedOutput); | ||
}); | ||
it('should be defined', () => { | ||
expect(parse_object_literal_1.default).toBeDefined(); | ||
it('should parse a string with multiple key-value pairs', () => { | ||
const input = 'a: 1, b: 2, c: 3'; | ||
const expectedOutput = [['a', '1'], ['b', '2'], ['c', '3']]; | ||
const actualOutput = (0, parse_object_literal_1.default)(input); | ||
expect(actualOutput).toEqual(expectedOutput); | ||
}); | ||
it('should parse a string with a single-quoted value', () => { | ||
const input = 'a: \'1\''; | ||
const expectedOutput = [['a', '\'1\'']]; | ||
const actualOutput = (0, parse_object_literal_1.default)(input); | ||
expect(actualOutput).toEqual(expectedOutput); | ||
}); | ||
it('should parse a string with a double-quoted value', () => { | ||
const input = 'a: "1"'; | ||
const expectedOutput = [['a', '"1"']]; | ||
const actualOutput = (0, parse_object_literal_1.default)(input); | ||
expect(actualOutput).toEqual(expectedOutput); | ||
}); | ||
}); | ||
//# sourceMappingURL=parse-object-literal.spec.js.map |
@@ -24,2 +24,10 @@ "use strict"; | ||
}); | ||
it('should convert values correctly when input contains a space before "asc" or "desc" ("name: asc, address: desc")', () => { | ||
const value = 'name: asc, address: desc'; | ||
const result = pipe.transform(value); | ||
expect(result).toEqual({ | ||
name: 'asc', | ||
address: 'desc', | ||
}); | ||
}); | ||
it('should throw error if value is empty', () => { | ||
@@ -26,0 +34,0 @@ expect.assertions(1); |
{ | ||
"name": "@nodeteam/nestjs-pipes", | ||
"version": "1.2.3", | ||
"version": "1.2.4", | ||
"description": "Pipes collection for Nest.JS app", | ||
@@ -5,0 +5,0 @@ "main": "./dist/src/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1106
159627