Skip to content

Commit

Permalink
refactor(test): change from e2e to unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
glowcloud committed Mar 13, 2024
1 parent 1d169bd commit 1827876
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 25 deletions.
24 changes: 0 additions & 24 deletions test/e2e-cypress/e2e/features/plugins/spec/validation-errors.cy.js

This file was deleted.

55 changes: 54 additions & 1 deletion test/unit/core/plugins/spec/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
parameterInclusionSettingFor,
consumesOptionsFor,
taggedOperations,
isMediaTypeSchemaPropertiesEqual
isMediaTypeSchemaPropertiesEqual,
validationErrors
} from "core/plugins/spec/selectors"

import Petstore from "./assets/petstore.json"
Expand Down Expand Up @@ -1380,3 +1381,55 @@ describe("isMediaTypeSchemaPropertiesEqual", () => {
})
})
})
describe("validationErrors", function() {
const state = fromJS({
meta: {
paths: {
"/": {
get: {
parameters: {
id: {
errors: [
"Value must be an integer"
]
}
}
},
post: {
parameters: {
body: {
errors: [
{
error: "Value must be an integer",
propKey: "id"
},
{
error: "Value must be a string",
propKey: "name"
}
]
}
}
}
}
}
}
})

it("should return validation errors without formatting them", function () {
const result = validationErrors(state, ["/", "get"])

expect(result).toEqual([
"Value must be an integer"
])
})

it("should return formatted validation errors", function () {
const result = validationErrors(state, ["/", "post"])

expect(result).toEqual([
"id: Value must be an integer",
"name: Value must be a string"
])
})
})

0 comments on commit 1827876

Please sign in to comment.