-
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.
- Loading branch information
0 parents
commit 51c0ceb
Showing
11 changed files
with
4,013 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,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
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 @@ | ||
# My Awesome normalizr |
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,8 @@ | ||
{ | ||
"transform": { | ||
"^.+\\.(t|j)sx?$": "ts-jest" | ||
}, | ||
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", | ||
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"] | ||
} | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
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,39 @@ | ||
{ | ||
"name": "nomalize-tool", | ||
"version": "1.0.1", | ||
"description": "my normalizr tool", | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"scripts": { | ||
"build": "tsc", | ||
"test": "jest --config jestconfig.json", | ||
"format": "prettier --write \"src/**/*.ts\"", | ||
"lint": "tslint -p tsconfig.json", | ||
"prepare": "npm run build", | ||
"prepublishOnly": "npm run test && npm run lint", | ||
"preversion": "npm run lint", | ||
"version": "npm run format && git add -A src", | ||
"postversion": "git push && git push --tags" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://git.garena.com/yuqing.yang/my-awesome-normalizr.git" | ||
}, | ||
"keywords": [ | ||
"normalize" | ||
], | ||
"author": "yuqing.yang", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"@types/jest": "^27.0.2", | ||
"jest": "^27.2.4", | ||
"prettier": "^2.4.1", | ||
"ts-jest": "^27.0.5", | ||
"tslint": "^6.1.3", | ||
"tslint-config-prettier": "^1.18.0", | ||
"typescript": "^4.4.3" | ||
}, | ||
"files": [ | ||
"lib/**/*" | ||
] | ||
} |
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,163 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`denormalize denormalizes entities 1`] = ` | ||
Array [ | ||
Object { | ||
"id": 1, | ||
"type": "foo", | ||
}, | ||
Object { | ||
"id": 2, | ||
"type": "bar", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`denormalize denormalizes nested entities 1`] = ` | ||
Object { | ||
"author": Object { | ||
"id": "8472", | ||
"name": "Paul", | ||
}, | ||
"body": "This article is great.", | ||
"comments": Array [ | ||
Object { | ||
"comment": "I like it!", | ||
"id": "comment-123-4738", | ||
"user": Object { | ||
"id": "10293", | ||
"name": "Jane", | ||
}, | ||
}, | ||
], | ||
"id": "123", | ||
"title": "A Great Article", | ||
} | ||
`; | ||
|
||
exports[`denormalize set to undefined if schema key is not in entities 1`] = ` | ||
Object { | ||
"author": undefined, | ||
"comments": Array [ | ||
Object { | ||
"user": undefined, | ||
}, | ||
], | ||
"id": "123", | ||
} | ||
`; | ||
|
||
exports[`normalize ignores null values 1`] = ` | ||
Object { | ||
"entities": Object {}, | ||
"result": Array [ | ||
null, | ||
], | ||
} | ||
`; | ||
|
||
exports[`normalize ignores null values 2`] = ` | ||
Object { | ||
"entities": Object {}, | ||
"result": Array [ | ||
undefined, | ||
], | ||
} | ||
`; | ||
|
||
exports[`normalize ignores null values 3`] = ` | ||
Object { | ||
"entities": Object {}, | ||
"result": Array [ | ||
false, | ||
], | ||
} | ||
`; | ||
|
||
exports[`normalize normalizes entities 1`] = ` | ||
Object { | ||
"entities": Object { | ||
"tacos": Object { | ||
"1": Object { | ||
"id": 1, | ||
"type": "foo", | ||
}, | ||
"2": Object { | ||
"id": 2, | ||
"type": "bar", | ||
}, | ||
}, | ||
}, | ||
"result": Array [ | ||
1, | ||
2, | ||
], | ||
} | ||
`; | ||
|
||
exports[`normalize normalizes entities with circular references 1`] = ` | ||
Object { | ||
"entities": Object { | ||
"users": Object { | ||
"123": Object { | ||
"friends": Array [ | ||
123, | ||
], | ||
"id": 123, | ||
}, | ||
}, | ||
}, | ||
"result": 123, | ||
} | ||
`; | ||
|
||
exports[`normalize normalizes nested entities 1`] = ` | ||
Object { | ||
"entities": Object { | ||
"articles": Object { | ||
"123": Object { | ||
"author": "8472", | ||
"body": "This article is great.", | ||
"comments": Array [ | ||
"comment-123-4738", | ||
], | ||
"id": "123", | ||
"title": "A Great Article", | ||
}, | ||
}, | ||
"comments": Object { | ||
"comment-123-4738": Object { | ||
"comment": "I like it!", | ||
"id": "comment-123-4738", | ||
"user": "10293", | ||
}, | ||
}, | ||
"users": Object { | ||
"10293": Object { | ||
"id": "10293", | ||
"name": "Jane", | ||
}, | ||
"8472": Object { | ||
"id": "8472", | ||
"name": "Paul", | ||
}, | ||
}, | ||
}, | ||
"result": "123", | ||
} | ||
`; | ||
|
||
exports[`normalize passes over pre-normalized values 1`] = ` | ||
Object { | ||
"entities": Object { | ||
"articles": Object { | ||
"123": Object { | ||
"author": 1, | ||
"id": "123", | ||
"title": "normalizr is great!", | ||
}, | ||
}, | ||
}, | ||
"result": "123", | ||
} | ||
`; |
Oops, something went wrong.