YahooArchive / arrow

FE Test framework designed to promote TDD
http://yahoo.github.io/arrow/arrow_intro.html
BSD 3-Clause "New" or "Revised" License
55 stars 59 forks source link

Add Lib's to facilitate testing of modular markup components and expand Asserts library available for Arrow #43

Closed akshayp closed 11 years ago

akshayp commented 11 years ago

New Asserts added:

Writing tests for a modular HTML component can be done using expressive JSON. Only requirements are to declare html-module, dom, common as Common Libs in your descriptor

YUI.add("MyAwesomeModule-tests", function (Y) {
  'use strict';

  var suite = new Y.Test.Suite("MyAwesomeModule Tests");

  suite.add(new Y.Test.Module({
    "name" : "MyAwesomeModule",
    "id" : "myawesomemodule",
    "asserts" : {
      "Title" : ".hd h3",
      "Body" : ".bd",
      "Footer Link" : ".ft li",
      "Test Equal To" : {
        "locator" : ".bd ul li",
        "type" : "nodeCount",
        "expected" : "=4",
        "message" : "There should be 4 Table Headers"
      },
      "Test Less Than" : {
        "locator" : ".bd ul li.foo",
        "type" : "nodeCount",
        "expected" : ">30",
        "message" : "There should be more than 30 list items with class foo"
      },
      "Test Greater Than" : {
        "locator" : ".bd ul li.bar",
        "type" : "nodeCount",
        "expected" : "<10",
        "message" : "There should be less than 10 list items with class bar"
      },
      "Test Node Contains" : {
        "locator" : ".hd h3",
        "type" : "nodeContains",
        "expected" : "My Module Header"
      },
      "Test Node Text Exists" : {
        "locator" : ".hd h3",
        "type" : "nodeTextExists"
      },
      "Test Node" : {
        "locator" : ".hd h3",
        "type" : "isNode"
      },
      "Test Anchor" : {
        "locator" : ".ft a",
        "type" : "isAnchor"
      },
      "Test Image" : {
        "locator" : ".bd ul li.logo img",
        "type" : "isImage"
      }
    }
  }));

  Y.Test.Runner.add(suite);

}, "0.1", {requires : ["test", "node", "html-module-lib", "dom-lib"]});