|
| 1 | +/******************************************************************************* |
| 2 | + * Copyright 2019 IBM Corp. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + *******************************************************************************/ |
| 16 | + |
| 17 | +const chai = require('chai'); |
| 18 | +const path = require('path'); |
| 19 | + |
| 20 | +const chaiResponseValidator = require('../..'); |
| 21 | + |
| 22 | +const dirContainingApiSpec = path.resolve('test/resources/exampleOpenApiFiles/valid/bugRecreationTemplate'); |
| 23 | +const { expect } = chai; |
| 24 | + |
| 25 | +describe('Recreate bug (issue #46)', function () { |
| 26 | + |
| 27 | + before(function () { |
| 28 | + const pathToApiSpec = path.join(dirContainingApiSpec, 'openapi.yml'); |
| 29 | + chai.use(chaiResponseValidator(pathToApiSpec)); |
| 30 | + }); |
| 31 | + |
| 32 | + const res = { |
| 33 | + status: 200, |
| 34 | + req: { |
| 35 | + method: 'GET', |
| 36 | + path: '/test', |
| 37 | + }, |
| 38 | + body: { |
| 39 | + expectedProperty1: 'foo', |
| 40 | + expectedProperty2: 'bar', |
| 41 | + }, |
| 42 | + }; |
| 43 | + |
| 44 | + it('passes', function () { |
| 45 | + expect(res).to.satisfyApiSpec; |
| 46 | + }); |
| 47 | + |
| 48 | + it('fails when using .not', function () { |
| 49 | + const assertion = () => expect(res).to.not.satisfyApiSpec; |
| 50 | + expect(assertion).to.throw(); |
| 51 | + }); |
| 52 | +}); |
0 commit comments