-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
1 parent
b037a5f
commit 70b3424
Showing
5 changed files
with
42 additions
and
33 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
|
@@ -129,15 +129,14 @@ describe('SCIM PATCH', () => { | |
}); | ||
|
||
it('REPLACE: nested object do not exists', done => { | ||
scimUser.surName = [{value: 'toto', primary: true}]; | ||
const expected = '[email protected]'; | ||
const patch1: ScimPatchAddReplaceOperation = { | ||
// empty the surName fields. | ||
scimUser.surName = []; | ||
const patch: ScimPatchAddReplaceOperation = { | ||
op: 'replace', | ||
value: {value: expected, primary: false}, | ||
path: 'surName[primary eq false]' | ||
path: 'surName[value eq "bogus"]', | ||
value: 'this value should not be added', | ||
}; | ||
const afterPatch = scimPatch(scimUser, [patch1]); | ||
expect(afterPatch.surName?.length).to.be.eq(2); | ||
expect(() => scimPatch(scimUser, [patch])).to.throw(NoTarget); | ||
return done(); | ||
}); | ||
|
||
|
@@ -185,26 +184,6 @@ describe('SCIM PATCH', () => { | |
return done(); | ||
}); | ||
|
||
it('REPLACE: should not modify anything if element not found', done => { | ||
scimUser.name.nestedArray = [{primary: true, value: 'value1'}]; | ||
const patch1: ScimPatchAddReplaceOperation = { | ||
op: 'replace', value: { | ||
newProperty1: 'toto' | ||
}, path: 'name.nestedArray[toto eq true]' | ||
}; | ||
const afterPatch = scimPatch(scimUser, [patch1]); | ||
expect(afterPatch.name.nestedArray).to.be.eq(scimUser.name.nestedArray); | ||
return done(); | ||
}); | ||
|
||
it('REPLACE: XXX', done => { | ||
const patch1: ScimPatchRemoveOperation = {op: 'remove', path: 'emails[primary eq true].value'}; | ||
const afterPatch = scimPatch(scimUser, [patch1]); | ||
expect(afterPatch.emails[0].value).not.to.exist; | ||
expect(afterPatch.emails[0].primary).to.eq(true); | ||
return done(); | ||
}); | ||
|
||
it('REPLACE: with capital first letter for operation', done => { | ||
const expected = false; | ||
const patch: ScimPatchAddReplaceOperation = {op: 'Replace', value: {active: expected}}; | ||
|
@@ -251,6 +230,35 @@ describe('SCIM PATCH', () => { | |
return done(); | ||
}); | ||
|
||
it("REPLACE: replace add fields in complex object", (done) => { | ||
const expected = [ {primary: true, value: "bogus", additional:"additional"} ]; | ||
// empty the surName fields. | ||
scimUser.surName = [{primary: true, value: "bogus"}]; | ||
const patch: ScimPatchAddReplaceOperation = { | ||
op: 'replace', | ||
path: 'surName[value eq "bogus"]', | ||
value: {additional:"additional"}, | ||
}; | ||
|
||
const afterPatch = scimPatch(scimUser, [patch]); | ||
expect(afterPatch.surName).to.be.deep.eq(expected); | ||
return done(); | ||
}); | ||
|
||
it("REPLACE: replace add and update fields in complex object", (done) => { | ||
const expected = [ {primary: true, value: "bogus2", additional:"additional"} ]; | ||
// empty the surName fields. | ||
scimUser.surName = [{primary: true, value: "bogus"}]; | ||
const patch: ScimPatchAddReplaceOperation = { | ||
op: 'replace', | ||
path: 'surName[value eq "bogus"]', | ||
value: {additional:"additional", value: "bogus2"}, | ||
}; | ||
|
||
const afterPatch = scimPatch(scimUser, [patch]); | ||
expect(afterPatch.surName).to.be.deep.eq(expected); | ||
return done(); | ||
}); | ||
}); | ||
|
||
describe('add', () => { | ||
|
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