Skip to content

Commit

Permalink
added tests for updated poly rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
daveshanley committed Jul 8, 2024
1 parent 84d379a commit 721e869
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions renderer/schema_renderer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,22 @@ dependentSchemas:
assert.True(t, journeyMap["pb33f"].(map[string]interface{})["fishCake"].(map[string]interface{})["bones"].(bool))
}

func TestRenderExample_String_AllOf(t *testing.T) {
testObject := `type: object
allOf:
- type: string`

compiled := getSchema([]byte(testObject))

journeyMap := make(map[string]any)
wr := createSchemaRenderer()
wr.DiveIntoSchema(compiled, "pb33f", journeyMap, 0)

assert.NotNil(t, journeyMap["pb33f"])
assert.Len(t, journeyMap["pb33f"], 1)
assert.Greater(t, len(journeyMap["pb33f"].(map[string]interface{})["allOf"].(string)), 0)
}

func TestRenderExample_Object_OneOf(t *testing.T) {
testObject := `type: object
oneOf:
Expand All @@ -683,6 +699,22 @@ oneOf:
assert.Greater(t, len(journeyMap["pb33f"].(map[string]interface{})["bones"].(string)), 0)
}

func TestRenderExample_String_OneOf(t *testing.T) {
testObject := `type: object
oneOf:
- type: string`

compiled := getSchema([]byte(testObject))

journeyMap := make(map[string]any)
wr := createSchemaRenderer()
wr.DiveIntoSchema(compiled, "pb33f", journeyMap, 0)

assert.NotNil(t, journeyMap["pb33f"])
assert.Len(t, journeyMap["pb33f"], 1)
assert.Greater(t, len(journeyMap["pb33f"].(map[string]interface{})["oneOf"].(string)), 0)
}

func TestRenderExample_Object_AnyOf(t *testing.T) {
testObject := `type: object
anyOf:
Expand All @@ -707,6 +739,22 @@ anyOf:
assert.Greater(t, len(journeyMap["pb33f"].(map[string]interface{})["bones"].(string)), 0)
}

func TestRenderExample_String_AnyOf(t *testing.T) {
testObject := `type: object
anyOf:
- type: string`

compiled := getSchema([]byte(testObject))

journeyMap := make(map[string]any)
wr := createSchemaRenderer()
wr.DiveIntoSchema(compiled, "pb33f", journeyMap, 0)

assert.NotNil(t, journeyMap["pb33f"])
assert.Len(t, journeyMap["pb33f"], 1)
assert.Greater(t, len(journeyMap["pb33f"].(map[string]interface{})["anyOf"].(string)), 0)
}

func TestRenderExample_TestGiftshopProduct_UsingExamples(t *testing.T) {
testObject := `type: [object]
properties:
Expand Down

0 comments on commit 721e869

Please sign in to comment.