-
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
Showing
12 changed files
with
288 additions
and
36 deletions.
There are no files selected for viewing
Binary file not shown.
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,27 @@ | ||
module.exports = { | ||
roots: ['<rootDir>/src'], | ||
projects: ['<rootDir>'], | ||
preset: 'ts-jest', | ||
moduleFileExtensions: ['js', 'ts'], | ||
transform: { | ||
'^.+\\.(ts|tsx)$': [ | ||
'ts-jest', | ||
{ | ||
tsconfig: 'tsconfig.json', | ||
}, | ||
], | ||
}, | ||
testMatch: ['**/__tests__/**/*.spec.(ts|js)'], | ||
testEnvironment: 'node', | ||
coverageThreshold: { | ||
global: { | ||
branches: 100, | ||
functions: 100, | ||
lines: 100, | ||
statements: 100, | ||
}, | ||
}, | ||
coverageDirectory: '<rootDir>/coverage/', | ||
collectCoverage: false, | ||
// verbose: true, | ||
} |
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
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 @@ | ||
const base = require('../../../jest.config.base') | ||
const packageJson = require('./package') | ||
import base from '../../../jest.config.base.js' | ||
import packageJson from './package.json' assert { type: "json" } | ||
|
||
module.exports = { | ||
export default { | ||
...base, | ||
displayName: packageJson.name, | ||
} |
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { diff, patch } from '../patch' | ||
|
||
test('patch', () => { | ||
const a: any = { | ||
a: 1, | ||
b: 'b', | ||
c: null, | ||
d: false, | ||
e: true, | ||
f: { | ||
a: 1, | ||
}, | ||
g: [1, { a: 1, b: 2 }], | ||
} | ||
|
||
{ | ||
// No change | ||
const b0 = clone(a) | ||
const d = diff(a, b0) | ||
expect(Object.keys(d)).toHaveLength(0) | ||
const b1 = patch(a, d) | ||
expect(b1).toEqual(b0) | ||
} | ||
{ | ||
const b0 = clone(a) | ||
b0.b = 'c' | ||
const d = diff(a, b0) | ||
const b1 = patch(a, d) | ||
expect(b1).toEqual(b0) | ||
} | ||
{ | ||
const b0 = clone(a) | ||
delete b0.b | ||
const d = diff(a, b0) | ||
const b1 = patch(a, d) | ||
expect(b1).toEqual(b0) | ||
} | ||
{ | ||
const b0 = clone(a) | ||
b0.g[1].a = 5 | ||
const d = diff(a, b0) | ||
const b1 = patch(a, d) | ||
expect(b1).toEqual(b0) | ||
} | ||
{ | ||
const b0 = clone(a) | ||
delete b0.g[1].b | ||
const d = diff(a, b0) | ||
const b1 = patch(a, d) | ||
expect(b1).toEqual(b0) | ||
} | ||
{ | ||
const b0 = clone(a) | ||
b0.f = [1, 2, 3] | ||
const d = diff(a, b0) | ||
const b1 = patch(a, d) | ||
expect(b1).toEqual(b0) | ||
} | ||
}) | ||
|
||
function clone<T>(o: T): T { | ||
return JSON.parse(JSON.stringify(o)) | ||
} |
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,3 +1,4 @@ | ||
export * from './model.js' | ||
export * from './patch.js' | ||
export * from './ProtectedString.js' | ||
export * from './client-server-api/index.js' |
Oops, something went wrong.