Skip to content

tests: add fixtures #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
build
coverage
File renamed without changes.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
build
yarn.lock
coverage
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": true
}
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
language: node_js
node_js:
- 12
before_script:
- yarn
script:
- yarn check:all
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 YeonJuan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
# parse-git-diff

## Installation

```bash
npm install parse-git-diff
```

## Usage

```js
import parseGitDiff from 'parse-git-diff';
parseGitDiff('...');
```

## License

- [MIT](./LICENSE)
4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
preset: 'ts-jest',
testEnvironment: 'node',
};
20 changes: 16 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "parse-git-diff",
"version": "0.0.1",
"description": "",
"version": "0.0.4",
"description": "Parse git diff",
"main": "build/index.js",
"types": "build/index.d.ts",
"scripts": {
"prepublish": "yarn build",
"build": "rimraf build && tsc",
"format": "prettier . --write",
"test": "jest",
"postinstall": "yarn husky install",
"check:all": "prettier --check . && tsc --noEmit && yarn test"
},
"repository": {
Expand All @@ -28,5 +29,16 @@
"rimraf": "^3.0.2",
"ts-jest": "^27.0.5",
"typescript": "^4.4.3"
}
},
"files": [
"build",
"tsconfig.json",
"README.md",
"yarn.lock",
"package.json"
],
"keywords": [
"git",
"git diff"
]
}
7 changes: 7 additions & 0 deletions src/__fixtures__/delete-line-diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
diff --git a/rename.md b/rename.md
index 0e05564..aa39060 100644
--- a/rename.md
+++ b/rename.md
@@ -1,2 +1 @@
newfile
-newline
7 changes: 7 additions & 0 deletions src/__fixtures__/deleted-file-diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
diff --git a/newfile.md b/newfile.md
deleted file mode 100644
index aa39060..0000000
--- a/newfile.md
+++ /dev/null
@@ -1 +0,0 @@
-newfile
7 changes: 7 additions & 0 deletions src/__fixtures__/new-file-diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
diff --git a/newfile.md b/newfile.md
new file mode 100644
index 0000000..aa39060
--- /dev/null
+++ b/newfile.md
@@ -0,0 +1 @@
+newfile
7 changes: 7 additions & 0 deletions src/__fixtures__/new-line-diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
diff --git a/rename.md b/rename.md
index aa39060..0e05564 100644
--- a/rename.md
+++ b/rename.md
@@ -1 +1,2 @@
newfile
+newline
4 changes: 4 additions & 0 deletions src/__fixtures__/rename-file-diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
diff --git a/newfile.md b/rename.md
similarity index 100%
rename from newfile.md
rename to rename.md
7 changes: 0 additions & 7 deletions src/__tests__/parse-git-diff.test.ts

This file was deleted.

2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import parseGitDiff from './parser/parse-git-diff';
export = parseGitDiff;
3 changes: 0 additions & 3 deletions src/parse-git-diff.ts

This file was deleted.

8 changes: 8 additions & 0 deletions src/parser/__snapshots__/parse-change-markers.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`parseChangeMarkers should parse change markers. 1`] = `
Object {
"added": "src/tests/addition.test.ts",
"deleted": "src/tests/addition.test.ts",
}
`;
30 changes: 30 additions & 0 deletions src/parser/__snapshots__/parse-changes.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`parseChanges should parse changes. 1`] = `
Array [
Object {
"content": "unchanged",
"lineAfter": 1,
"lineBefore": 1,
"type": "UnchangedLine",
},
Object {
"content": "-deleted line",
"lineAfter": 2,
"lineBefore": 2,
"type": "UnchangedLine",
},
Object {
"content": "+added line",
"lineAfter": 3,
"lineBefore": 3,
"type": "UnchangedLine",
},
Object {
"content": "unchanged",
"lineAfter": 4,
"lineBefore": 4,
"type": "UnchangedLine",
},
]
`;
40 changes: 40 additions & 0 deletions src/parser/__snapshots__/parse-chunk-header.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`parseChunkHeader should parse chunk header. 1`] = `
Object {
"rangeAfter": Object {
"lines": 4,
"start": 3,
},
"rangeBefore": Object {
"lines": 71,
"start": 3,
},
}
`;

exports[`parseChunkHeader should parse concise chunk header 1`] = `
Object {
"rangeAfter": Object {
"lines": 1,
"start": 1,
},
"rangeBefore": Object {
"lines": 1,
"start": 1,
},
}
`;

exports[`parseChunkHeader should parse normal chunk header. 1`] = `
Object {
"rangeAfter": Object {
"lines": 4,
"start": 3,
},
"rangeBefore": Object {
"lines": 71,
"start": 3,
},
}
`;
Loading