summaryrefslogtreecommitdiff
path: root/Data/DefaultContent/Libraries/middleclass/spec/class_spec.lua
blob: 144cb9f5523dfd1d3a5717f1242681d1abb54380 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
local class = require 'middleclass'

describe('class()', function()

  describe('when given no params', function()
    it('it throws an error', function()
      assert.error(class)
    end)
  end)

  describe('when given a name', function()
    it('the resulting class has the correct name and Object as its superclass', function()
      local TheClass = class('TheClass')
      assert.equal(TheClass.name, 'TheClass')
      assert.is_nil(TheClass.super)
    end)
  end)

  describe('when given a name and a superclass', function()
    it('the resulting class has the correct name and superclass', function()
      local TheSuperClass = class('TheSuperClass')
      local TheSubClass = class('TheSubClass', TheSuperClass)
      assert.equal(TheSubClass.name, 'TheSubClass')
      assert.equal(TheSubClass.super, TheSuperClass)
    end)
  end)

end)