-
Notifications
You must be signed in to change notification settings - Fork 213
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
Showing
9 changed files
with
1,146 additions
and
5 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 |
---|---|---|
|
@@ -10,6 +10,7 @@ npm-debug.log | |
|
||
# Typescript | ||
*.d.ts | ||
test/spec/typings/typingsSpec.js | ||
|
||
# compiled files | ||
src/*.js | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"spec_dir": "test", | ||
"spec_files": [ | ||
"**/*[sS]pec.js" | ||
"spec/*[sS]pec.js" | ||
], | ||
"helpers": [ | ||
"helpers/**/*.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,24 @@ | ||
const jsonpatch = require('../../..'); | ||
|
||
describe('CommonJS', function () { | ||
describe('require', function () { | ||
it('should have the expected structure', function () { | ||
expect(typeof jsonpatch).toEqual("object"); | ||
expect(typeof jsonpatch).not.toEqual("function"); | ||
expect(jsonpatch.applyOperation).toBeDefined(); | ||
expect(jsonpatch.applyPatch).toBeDefined(); | ||
expect(jsonpatch.applyReducer).toBeDefined(); | ||
expect(jsonpatch.getValueByPointer).toBeDefined(); | ||
expect(jsonpatch.validate).toBeDefined(); | ||
expect(jsonpatch.validator).toBeDefined(); | ||
expect(jsonpatch.JsonPatchError).toBeDefined(); | ||
expect(jsonpatch.deepClone).toBeDefined(); | ||
expect(jsonpatch.escapePathComponent).toBeDefined(); | ||
expect(jsonpatch.unescapePathComponent).toBeDefined(); | ||
expect(jsonpatch.unobserve).toBeDefined(); | ||
expect(jsonpatch.observe).toBeDefined(); | ||
expect(jsonpatch.generate).toBeDefined(); | ||
expect(jsonpatch.compare).toBeDefined(); | ||
}); | ||
}); | ||
}); |
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,22 @@ | ||
/** | ||
* Run using `npm run test-typings` | ||
* The sole fact that this file compiles means that typings work | ||
* This follows how DefinitelyTyped tests work | ||
* @see https://stackoverflow.com/questions/49296151/how-to-write-tests-for-typescript-typing-definition | ||
*/ | ||
|
||
// import jsonpatch from '../../..'; | ||
import * as jsonpatchStar from '../../..'; | ||
import { applyPatch, Operation } from '../../..'; | ||
|
||
const document = { firstName: "Albert", contactDetails: { phoneNumbers: [] } }; | ||
|
||
const typedPatch = new Array<Operation>({ op: "replace", path: "/firstName", value: "Joachim" }); | ||
const untypedPatch = [{ op: "replace", path: "/firstName", value: "Joachim" }]; | ||
|
||
// const test_jsonpatch = jsonpatch.applyPatch(document, typedPatch).newDocument; | ||
const test_jsonpatchStar = jsonpatchStar.applyPatch(document, typedPatch).newDocument; | ||
const test_applyPatch = applyPatch(document, typedPatch).newDocument; | ||
|
||
// the below line would NOT compile with TSC | ||
// const test_applyPatch = applyPatch(document, untypedPatch).newDocument; |
Oops, something went wrong.