-
Notifications
You must be signed in to change notification settings - Fork 2
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 #1866 from DISSINET/1854-bugs-in-data-validation
1854 bugs in data validation
- Loading branch information
Showing
5 changed files
with
354 additions
and
72 deletions.
There are no files selected for viewing
84 changes: 84 additions & 0 deletions
84
packages/server/src/models/statement/PositionRules.test.ts
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,84 @@ | ||
import { EntityEnums } from "@shared/enums"; | ||
import "ts-jest"; | ||
import { PositionRules } from "./PositionRules"; | ||
|
||
describe("models/statement/PositionRules", function () { | ||
test("test PositionRules.intersectRules", function () { | ||
// undefined rules - without intersection | ||
expect(PositionRules.hasIntersection([undefined, undefined])).toEqual( | ||
false | ||
); | ||
|
||
// no actions - should return true | ||
expect(PositionRules.hasIntersection([])).toEqual(true); | ||
|
||
// single action with single rule -> true | ||
expect( | ||
PositionRules.hasIntersection([[EntityEnums.Extension.Empty]]) | ||
).toEqual(true); | ||
|
||
// two actions both with empty | ||
expect( | ||
PositionRules.hasIntersection([ | ||
[EntityEnums.Extension.Empty], | ||
[EntityEnums.Extension.Empty], | ||
]) | ||
).toEqual(true); | ||
|
||
// two actions both with empty intersected | ||
expect( | ||
PositionRules.hasIntersection([ | ||
[EntityEnums.Extension.Empty], | ||
[EntityEnums.Extension.Empty, EntityEnums.Class.Statement], | ||
]) | ||
).toEqual(true); | ||
|
||
expect( | ||
PositionRules.hasIntersection([ | ||
[EntityEnums.Class.Concept], | ||
[EntityEnums.Class.Concept], | ||
]) | ||
).toEqual(true); | ||
|
||
expect( | ||
PositionRules.hasIntersection([ | ||
[EntityEnums.Class.Concept, EntityEnums.Class.Action], | ||
[EntityEnums.Class.Concept, EntityEnums.Class.Action], | ||
]) | ||
).toEqual(true); | ||
|
||
expect( | ||
PositionRules.hasIntersection([ | ||
[EntityEnums.Class.Resource, EntityEnums.Class.Action], | ||
[EntityEnums.Class.Location, EntityEnums.Class.Concept], | ||
]) | ||
).toEqual(false); | ||
|
||
expect( | ||
PositionRules.hasIntersection([ | ||
[EntityEnums.Extension.Empty], | ||
[EntityEnums.Class.Action], | ||
[EntityEnums.Class.Location], | ||
[EntityEnums.Class.Concept], | ||
[EntityEnums.Class.Concept], | ||
]) | ||
).toEqual(false); | ||
}); | ||
|
||
test("test PositionRules.allowsOnlyEmpty", function () { | ||
expect(PositionRules.allowsOnlyEmpty([])).toEqual(false); | ||
expect(PositionRules.allowsOnlyEmpty(undefined)).toEqual(false); | ||
expect(PositionRules.allowsOnlyEmpty([EntityEnums.Class.Concept])).toEqual( | ||
false | ||
); | ||
expect( | ||
PositionRules.allowsOnlyEmpty([ | ||
EntityEnums.Class.Concept, | ||
EntityEnums.Extension.Empty, | ||
]) | ||
).toEqual(false); | ||
expect( | ||
PositionRules.allowsOnlyEmpty([EntityEnums.Extension.Empty]) | ||
).toEqual(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
Oops, something went wrong.