Skip to content

Commit

Permalink
Add failing test for adding multiple hashes in root level
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsen1 committed Oct 22, 2015
1 parent 07096a3 commit 6b91d36
Showing 1 changed file with 110 additions and 0 deletions.
110 changes: 110 additions & 0 deletions test/end-to-end-multiple.js
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);
});
});
});

0 comments on commit 6b91d36

Please sign in to comment.