All Downloads are FREE. Search and download functionalities are using the official Maven repository.

crystal.model_test.mustache Maven / Gradle / Ivy

There is a newer version: 7.7.0
Show newest version
# {{#lambdaPrefixWithHash}}{{> api_info}}{{/lambdaPrefixWithHash}}

require "../spec_helper"
require "json"
require "time"

# Unit tests for {{moduleName}}::{{classname}}
# Automatically generated by openapi-generator (https://openapi-generator.tech)
# Please update as you see appropriate
{{#models}}
{{#model}}
describe {{moduleName}}::{{classname}} do
{{^oneOf}}

  describe "test an instance of {{classname}}" do
    it "should create an instance of {{classname}}" do
      #instance = {{moduleName}}::{{classname}}.new
      #expect(instance).to be_instance_of({{moduleName}}::{{classname}})
    end
  end
{{#vars}}
  describe "test attribute '{{{name}}}'" do
    it "should work" do
      {{#isEnum}}
      # assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
      # validator = Petstore::EnumTest::EnumAttributeValidator.new("{{{dataType}}}", [{{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}])
      # validator.allowable_values.each do |value|
      #   expect { instance.{{name}} = value }.not_to raise_error
      # end
      {{/isEnum}}
      {{^isEnum}}
      # assertion here. ref: https://crystal-lang.org/reference/guides/testing.html
      {{/isEnum}}
    end
  end

{{/vars}}
{{/oneOf}}
{{#oneOf}}
{{#-first}}
  describe ".openapi_one_of" do
    it "lists the items referenced in the oneOf array" do
      expect(described_class.openapi_one_of).to_not be_empty
    end
  end

  {{#discriminator}}
  {{#propertyName}}
  describe ".openapi_discriminator_name" do
    it "returns the value of the "discriminator" property" do
      expect(described_class.openapi_discriminator_name).to_not be_empty
    end
  end

  {{/propertyName}}
  {{#mappedModels}}
  {{#-first}}
  describe ".openapi_discriminator_mapping" do
    it "returns the key/values of the "mapping" property" do
      expect(described_class.openapi_discriminator_mapping.values.sort).to eq(described_class.openapi_one_of.sort)
    end
  end

  {{/-first}}
  {{/mappedModels}}
  {{/discriminator}}
  describe ".build" do
    it "returns the correct model" do
    end
  end
{{/-first}}
{{/oneOf}}
end
{{/model}}
{{/models}}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy