-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1142 - integration test for realm proxy changes to check for presenc…
…e of mandatory object fields
- Loading branch information
1 parent
2d04d0b
commit 00947bf
Showing
9 changed files
with
60 additions
and
19 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
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
30 changes: 30 additions & 0 deletions
30
packages/openchs-android/integrationTest/RealmProxyTest.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,30 @@ | ||
import BaseIntegrationTest from "./BaseIntegrationTest"; | ||
import {Observation} from "openchs-models"; | ||
import {assert} from "chai"; | ||
import TestObsFactory from "../test/model/TestObsFactory"; | ||
|
||
function shouldFail(baseIntegrationTest, obs, updateMode) { | ||
baseIntegrationTest.executeInWrite((db) => { | ||
try { | ||
db.create(Observation, obs, updateMode); | ||
assert.fail("Comment without subject and CommentThread should have failed to save."); | ||
} catch (error) { | ||
} | ||
}); | ||
} | ||
|
||
function shouldPass(baseIntegrationTest, obs, updateMode) { | ||
baseIntegrationTest.executeInWrite((db) => { | ||
db.create(Observation, obs, updateMode); | ||
}); | ||
} | ||
|
||
class RealmProxyTest extends BaseIntegrationTest { | ||
doNotAllowCreateWithMandatoryObjectTypePropertyAsNull() { | ||
shouldFail(this, TestObsFactory.create({valueJSON: "{}"}), false); | ||
shouldFail(this, TestObsFactory.create({concept: null, valueJSON: "{}"}), true); | ||
shouldPass(this, TestObsFactory.create({valueJSON: "{}"}), true); | ||
} | ||
} | ||
|
||
export default RealmProxyTest; |
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
1 change: 0 additions & 1 deletion
1
packages/openchs-android/test/model/comment/TestCommentFactory.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
12 changes: 12 additions & 0 deletions
12
packages/openchs-android/test/model/txn/TestObservationFactory.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,12 @@ | ||
import {Observation} from 'openchs-models'; | ||
|
||
class TestObservationFactory { | ||
static create({concept, valueJson}) { | ||
const observation = new Observation(); | ||
observation.concept = concept; | ||
observation.valueJSON = valueJson; | ||
return observation; | ||
} | ||
} | ||
|
||
export default TestObservationFactory; |