Skip to content

Commit 96ca9b1

Browse files
committed
Maintain multiple graphs.
Adapted from: "Make sure multiple objects with `@container: @graph` are maintained as multiple graphs." ruby-rdf/json-ld@b2675a1
1 parent feca3ca commit 96ca9b1

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
### Fixed
44
- Use rdf-canonize to compare n-quads test results.
5+
- Multiple graph tests.
56

67
### Changed
78
- Use JSON-LD WG tests.

lib/expand.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -660,11 +660,10 @@ function _expandObject({
660660
// and value is not, itself, a graph
661661
// index cases handled above
662662
if(container.includes('@graph') &&
663-
!container.some(key => key === '@id' || key === '@index') &&
664-
!_isGraph(expandedValue)) {
665-
// ensure expanded value is an array
666-
expandedValue = [].concat(expandedValue);
667-
expandedValue = {'@graph': expandedValue};
663+
!container.some(key => key === '@id' || key === '@index')) {
664+
// ensure expanded values are arrays
665+
expandedValue = [].concat(expandedValue)
666+
.map(v => _isGraph(v) ? v : {'@graph': [].concat(v)});
668667
}
669668

670669
// FIXME: can this be merged with code above to simplify?

tests/test-common.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ const TEST_TYPES = {
4747
// scoped context on type
4848
/^#tc012/,
4949
// rel iri
50-
/^#t0095/,
51-
// graphs
52-
/^#t0092/,
53-
/^#t0093/
50+
/^#t0095/
5451
]
5552
},
5653
fn: 'compact',
@@ -81,12 +78,6 @@ const TEST_TYPES = {
8178
/^#tp002/,
8279
// scoped context on type
8380
/^#tc011/,
84-
// graph
85-
/^#t0093/,
86-
/^#t0094/,
87-
/^#t0095/,
88-
/^#t0103/,
89-
/^#t0104/,
9081
// rel iri
9182
/^#t0092/,
9283
// remote

0 commit comments

Comments
 (0)