diff options
author | Matěj Cepl <mcepl@redhat.com> | 2010-06-01 00:44:54 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2010-06-01 00:44:54 +0200 |
commit | 4ccc9580eed8269e376eaa671e42590ff095c890 (patch) | |
tree | 9dc9890128d11407a851b7737de852b3bd24de0b /tests | |
parent | 0aaaa4aca25a8842e92887fd15fa76ff8ed7923e (diff) | |
download | bugzilla-triage-4ccc9580eed8269e376eaa671e42590ff095c890.tar.gz |
Added test for util.heir
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-util.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/test-util.js b/tests/test-util.js index 552868f..2104a2e 100644 --- a/tests/test-util.js +++ b/tests/test-util.js @@ -48,6 +48,52 @@ var areArraysEqual = function areArraysEqual(array1, array2) { return true; }; +// testing util.heir +exports.ensureHeir = function (test) { + var fedlimid = {}, naoise = {}; + + function Father(x) { + this.family = x; + } + + Father.prototype.getFamily = function getFamily() { + return this.family; + }; + + function Son(x, w) { + Father.call(this, x); + this.wife = w; + } + + Son.prototype = util.heir(Father); + Son.prototype.constructor = Son; + + Son.prototype.getWife = function getWife() { + return this.wife; + }; + + Son.prototype.getFamily = function getFamily() { + var upFamily = + Father.prototype.getFamily.call(this); + return upFamily + ", " + this.wife; + }; + + // for curious and non-Celtic + // http://en.wikipedia.org/wiki/Deirdre :) + fedlimid = new Father("mac Daill"); + naoise = new Son("Usnech", "Deirdre"); + + test.assertEqual(fedlimid.getFamily(), "mac Daill", + "checking creation of new simple object"); + + test.assertEqual(naoise.getWife(), "Deirdre", + "checking creation of new daughter object"); + + test.assertEqual(naoise.getFamily(), "Usnech, Deirdre", + "checking creation of new overloaded method"); +}; + + // testing util.isInList exports.ensureIsInListTrue = function (test) { test.assert(util.isInList("a", ["a"]), |