-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: porting the library over from
@readme/oas-to-har
- Loading branch information
0 parents
commit 7001f22
Showing
14 changed files
with
14,252 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@types/ | ||
coverage/ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": [ | ||
"@readme/eslint-config", | ||
"@readme/eslint-config/typescript" | ||
], | ||
"root": true, | ||
"rules": { | ||
"@typescript-eslint/no-explicit-any": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@types/ | ||
coverage/ | ||
dist/ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npx commitlint --edit $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
__tests__/ | ||
.github/ | ||
.husky/ | ||
coverage/ | ||
.eslint* | ||
.prettier* | ||
jest.*.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@types/ | ||
coverage/ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "@readme/eslint-config/testing" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import removeUndefinedObjects from '../src'; | ||
|
||
test('should leave primitives alone', () => { | ||
expect(removeUndefinedObjects(1234)).toBe(1234); | ||
expect(removeUndefinedObjects('1234')).toBe('1234'); | ||
expect(removeUndefinedObjects(null)).toBeNull(); | ||
expect(removeUndefinedObjects()).toBeUndefined(); | ||
expect(removeUndefinedObjects(undefined)).toBeUndefined(); | ||
}); | ||
|
||
test('should remove empty objects with only empty properties', () => { | ||
const obj = { | ||
a: { | ||
b: {}, | ||
c: { | ||
d: {}, | ||
}, | ||
}, | ||
}; | ||
|
||
expect(removeUndefinedObjects(obj)).toBeUndefined(); | ||
}); | ||
|
||
test('should remove empty objects with only undefined properties', () => { | ||
const obj = { | ||
a: { | ||
b: undefined, | ||
c: { | ||
d: undefined, | ||
}, | ||
}, | ||
}; | ||
|
||
expect(removeUndefinedObjects(obj)).toBeUndefined(); | ||
}); | ||
|
||
test('should remove empty arrays from within object', () => { | ||
const obj = { | ||
a: { | ||
b: undefined, | ||
c: { | ||
d: undefined, | ||
}, | ||
}, | ||
d: [1234, undefined], | ||
e: [], | ||
}; | ||
|
||
expect(removeUndefinedObjects(obj)).toStrictEqual({ | ||
d: [1234], | ||
}); | ||
}); | ||
|
||
test('should remove undefined and null values from arrays', () => { | ||
expect(removeUndefinedObjects([undefined, undefined])).toBeUndefined(); | ||
expect(removeUndefinedObjects([null])).toBeUndefined(); | ||
expect(removeUndefinedObjects(['1234', null, undefined, { a: null, b: undefined }, ' ', ''])).toStrictEqual([ | ||
'1234', | ||
{ | ||
a: null, | ||
}, | ||
' ', | ||
'', | ||
]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"module": "es6", | ||
"moduleResolution": "node", | ||
"noImplicitAny": false | ||
}, | ||
"include": ["../src/**/*", "*.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = { | ||
coveragePathIgnorePatterns: ['/dist', '/node_modules'], | ||
globals: { | ||
'ts-jest': { | ||
tsconfig: '__tests__/tsconfig.json', | ||
}, | ||
}, | ||
modulePaths: ['<rootDir>'], | ||
preset: 'ts-jest/presets/js-with-ts', | ||
roots: ['<rootDir>'], | ||
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(js?|ts?)$', | ||
transform: {}, | ||
}; |
Oops, something went wrong.