UIZE JavaScript Framework

TO DO - Uize.Test.ClassTest

This is a proposal document for a Uize.Test.ClassTest module.

1. Uize.Test.ClassTest.derivedPropertyTest

SYNTAX

testCLASS = Uize.Test.ClassTest.derivedPropertyTest (
  widgetClassOBJorSTR,
  propretyNameSTR,
  casesARRAY,
  supplementalInstancePropertiesOBJ, // optional
  supplementalTestPropertiesOBJ,     // optional
  supplementalCaseTestPropertiesOBJ  // optional
);

1.1. casesArray

STRUCTURE

[
  titleSTR,              // the title of the test case
  propertiesOBJ,         // properties to set on instance to cause derivation
  expectedResultANYTYPE  // the expected derived value for the test case
]

EXAMPLE

Uize.Test.ClassTest.derivedPropertyTest (
  'Uize.Widget.Collection',
  'isEmpty',
  [
    ['No total items', {totalItems:0}, true],
    ['1 total items', {totalItems:1}, false],
    ['Many total items, {totalItems:2}, false]
  ]
);

2. Uize.Test.ClassTest.derivedPropertiesTest

SYNTAX

testCLASS = Uize.Test.ClassTest.derivedPropertiesTest (
  widgetClassOBJorSTR,
  derivedPropretyTestARRAYorOBJ
);

2.1. derivedPropretyTestARRAYorOBJ

STRUCTURE

[
  propertyNameSTR,                   // name of the derived state property
  casesARRAY,                        // array of test cases
  supplementalInstancePropertiesOBJ  // optional
]

EXAMPLE

Uize.Test.ClassTest.derivedPropertiesTest (
  'Uize.Widget.Collection',
  [
    [
      'isEmpty',
      [
        ['No total items', {totalItems:0}, true],
        ['1 total items', {totalItems:1}, false],
        ['Many total items, {totalItems:2}, false]
      ]
    ],
    [
      'oneSelected',
      [
        ['No total selected', {totalSelected:0}, false],
        ['1 total selected', {totalSelected:1}, true],
        ['Many total items, {totalSelected:2}, false]
      ]
    ],
    [
      'someSelected',
      [
        ['No total selected', {totalSelected:0}, false],
        ['1 total selected', {totalSelected:1}, true],
        ['Many total items, {totalSelected:2}, true]
      ]
    ]
  ]
);