-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #236 from /issues/233-export-star-as-default
Export star as default
- Loading branch information
Showing
12 changed files
with
244 additions
and
38 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 | ||
|
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
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
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
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).withContext("result from require() should be an object").toEqual("object"); | ||
expect(typeof jsonpatch).withContext("result from require() should not be a function").not.toEqual("function"); | ||
expect(jsonpatch.applyOperation).withContext("applyOperation should be a method within the object").toBeDefined(); | ||
expect(jsonpatch.applyPatch).withContext("applyPatch should be a method within the object").toBeDefined(); | ||
expect(jsonpatch.applyReducer).withContext("applyReducer should be a method within the object").toBeDefined(); | ||
expect(jsonpatch.getValueByPointer).withContext("getValueByPointer should be a method within the object").toBeDefined(); | ||
expect(jsonpatch.validate).withContext("validate should be a method within the object").toBeDefined(); | ||
expect(jsonpatch.validator).withContext("validator should be a method within the object").toBeDefined(); | ||
expect(jsonpatch.JsonPatchError).withContext("JsonPatchError should be a method within the object").toBeDefined(); | ||
expect(jsonpatch.deepClone).withContext("deepClone should be a method within the object").toBeDefined(); | ||
expect(jsonpatch.escapePathComponent).withContext("escapePathComponent should be a method within the object").toBeDefined(); | ||
expect(jsonpatch.unescapePathComponent).withContext("unescapePathComponent should be a method within the object").toBeDefined(); | ||
expect(jsonpatch.unobserve).withContext("unobserve should be a method within the object").toBeDefined(); | ||
expect(jsonpatch.observe).withContext("observe should be a method within the object").toBeDefined(); | ||
expect(jsonpatch.generate).withContext("generate should be a method within the object").toBeDefined(); | ||
expect(jsonpatch.compare).withContext("compare should be a method within the object").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.