-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add failing test for adding multiple hashes in root level
- Loading branch information
Showing
1 changed file
with
110 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
'use strict'; | ||
|
||
import {expect} from 'chai'; | ||
import YAWN from '../src/index.js'; | ||
|
||
|
||
const input = ` | ||
swagger: '2.0' | ||
info: | ||
version: 0.0.0 | ||
title: Simple API | ||
paths: | ||
/: | ||
get: | ||
responses: | ||
'200': | ||
description: OK | ||
`; | ||
|
||
const output = ` | ||
swagger: '2.0' | ||
info: | ||
version: 0.0.0 | ||
title: Simple API | ||
paths: | ||
/: | ||
get: | ||
responses: | ||
'200': | ||
description: OK | ||
/new-models: | ||
post: | ||
description: Make a new \`NewModel\`. | ||
parameters: | ||
- name: body | ||
description: A new \`NewModel\` | ||
in: body | ||
schema: | ||
$ref: '#/definitions/NewModel' | ||
responses: | ||
'200': | ||
description: OK | ||
schema: | ||
$ref: '#/definitions/NewModel' | ||
definitions: | ||
NewModel: | ||
type: string | ||
`; | ||
|
||
// Using JSON.parse to get away from style checker! | ||
const newJson = JSON.parse(`{ | ||
"swagger": "2.0", | ||
"info": { | ||
"version": "0.0.0", | ||
"title": "Simple API" | ||
}, | ||
"paths": { | ||
"/": { | ||
"get": { | ||
"responses": { | ||
"200": { | ||
"description": "OK" | ||
} | ||
} | ||
} | ||
}, | ||
"/new-models": { | ||
"post": { | ||
"description": "Make a new \`NewModel\`.", | ||
"parameters": [ | ||
{ | ||
"name": "body", | ||
"description": "A new \`NewModel\`", | ||
"in": "body", | ||
"schema": { | ||
"$ref": "#/definitions/NewModel" | ||
} | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"schema": { | ||
"$ref": "#/definitions/NewModel" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"definitions": { | ||
"NewModel": { | ||
"type": "string" | ||
} | ||
} | ||
}`); | ||
|
||
describe('preserves comments and styling when', ()=> { | ||
|
||
describe('JSON is complex', ()=> { | ||
// debugger | ||
it('adds two new object hashes', ()=> { | ||
let yawn = new YAWN(input); | ||
|
||
yawn.json = newJson; | ||
|
||
expect(yawn.yaml).to.equal(output); | ||
}); | ||
}); | ||
}); |