Skip to content

Commit

Permalink
feat(dumping): support noRefs (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
P0lip authored and marbemac committed Sep 26, 2019
1 parent d7732df commit eff0088
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
"test.watch": "yarn test --watch"
},
"dependencies": {
"@stoplight/types": "^11.1.0",
"lodash": "^4.17.15",
"@stoplight/yaml-ast-parser": "0.0.43"
"@stoplight/types": "^11.1.1",
"@stoplight/yaml-ast-parser": "0.0.44",
"lodash": "^4.17.15"
},
"devDependencies": {
"@stoplight/scripts": "3.1.0",
Expand Down
19 changes: 19 additions & 0 deletions src/__tests__/safeStringify.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,25 @@ ${description
.split('\n')
.map(part => ` ${part}`)
.join('\n')}
`);
});

test('should use anchors for same objects by default', () => {
const obj = { foo: 'bar' };

expect(safeStringify({ a: obj, b: obj })).toEqual(`a: &ref_0
foo: bar
b: *ref_0
`);
});

test('should not use anchors for same objects if noRefs is truthy', () => {
const obj = { foo: 'bar' };

expect(safeStringify({ a: obj, b: obj }, { noRefs: true })).toEqual(`a:
foo: bar
b:
foo: bar
`);
});
});
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1575,17 +1575,17 @@
typedoc "0.13.x"
typescript-plugin-styled-components "1.0.x"

"@stoplight/types@^11.1.0":
version "11.1.0"
resolved "https://registry.yarnpkg.com/@stoplight/types/-/types-11.1.0.tgz#b29ecd8c8ad27bb564c7820c99f93c27f1d11bf1"
integrity sha512-z4VqnYIDTcj9R0f8AIDitBWkiAKKJ4W/Z5GJz/3fnBZBa/TD9Oak0xHbicXFXUvqTVCv/7D32PjPYiUX6W/EfQ==
"@stoplight/types@^11.1.1":
version "11.1.1"
resolved "https://registry.yarnpkg.com/@stoplight/types/-/types-11.1.1.tgz#a92d1833adb580a72439f42ba73de8f560fd68b4"
integrity sha512-IU8U9y/uO548z15DX/Jl053u9VQG8gCwNtypuD4RtskUA7pvHZl4+zzGK3klgIcO6Ql3Jk4/fcrFaN9vjmdEWg==
dependencies:
"@types/json-schema" "^7.0.3"

"@stoplight/[email protected].43":
version "0.0.43"
resolved "https://registry.yarnpkg.com/@stoplight/yaml-ast-parser/-/yaml-ast-parser-0.0.43.tgz#c39cf86e98e48d73c483be96622b2b622cc56b0c"
integrity sha512-3buZXhav0Uc4pD7QWCTfysDTW0syyf1Nj/F73fgAfhO9+Fd6Q6IVB0k1ApcHFQgIPTHQAq9Lu8+ngvlGIjG6ZQ==
"@stoplight/[email protected].44":
version "0.0.44"
resolved "https://registry.yarnpkg.com/@stoplight/yaml-ast-parser/-/yaml-ast-parser-0.0.44.tgz#ed3c962564283e9983f7895a6effc3994286df5e"
integrity sha512-PdY8p2Ufgtorf4d2DbKMfknILMa8KwuyyMMR/2lgK1mLaU8F5PKWYc+h9hIzC+ar0bh7m9h2rINo32m7ADfVyA==

"@storybook/[email protected]":
version "4.0.11"
Expand Down

0 comments on commit eff0088

Please sign in to comment.