diff --git a/bower.json b/bower.json index fd0a0a5..2d0402a 100644 --- a/bower.json +++ b/bower.json @@ -30,11 +30,12 @@ "zepto.js": "1.*" }, "devDependencies": { + "jquery": "*", "action": "0.3.2", "underscore-template": "0.3.0", "underscore.string": "2.*", "mocha.css": "0.1.0", "mocha": "1.*", - "chai": "1.*" + "expect.js": "^0.3.1" } } diff --git a/test/_sandbox.html b/test/_sandbox.html new file mode 100644 index 0000000..b472c09 --- /dev/null +++ b/test/_sandbox.html @@ -0,0 +1,45 @@ + + + + +Testing Sandbox - UT - Gearbox + + + +

Testing Sandbox

+ + + + + + diff --git a/test/test-action.js b/test/test-action.js index 02088c2..6cd2c2e 100644 --- a/test/test-action.js +++ b/test/test-action.js @@ -64,7 +64,7 @@ describe('Action', function () { $wrapper.remove() }) beforeEach(function () { - actionName = Date.now().toString(36) + actionName = new Date().getTime().toString(36) randomKey = Math.random().toString(36) }) it('gets action name from `href`', function (done) { diff --git a/test/test-dev.html b/test/test-dev.html index 3e885c7..f05999f 100644 --- a/test/test-dev.html +++ b/test/test-dev.html @@ -18,11 +18,10 @@

UT (Dev) - Gearbox

- + diff --git a/test/test-dist-trad-jquery.html b/test/test-dist-trad-jquery.html new file mode 100644 index 0000000..b725e08 --- /dev/null +++ b/test/test-dist-trad-jquery.html @@ -0,0 +1,45 @@ + + + + +UT (Trad) (jQuery) - Gearbox + + + + + +
+

UT (Trad) (jQuery) - Gearbox

+

View on GitHub

+
+
+ + + + + + + + + + + + + + + + + + + + + + diff --git a/test/test-dist-trad.html b/test/test-dist-trad.html index 59eb283..1d61e79 100644 --- a/test/test-dist-trad.html +++ b/test/test-dist-trad.html @@ -18,11 +18,10 @@

UT (Trad) - Gearbox

- + diff --git a/test/test-dom.js b/test/test-dom.js index 22edeb3..445135e 100644 --- a/test/test-dom.js +++ b/test/test-dom.js @@ -2,20 +2,20 @@ describe('DOM', function () { describe('Shortcuts', function () { describe('_.dom.$win', function () { it('is $collection of `window` object', function () { - expect(_.dom.is$Element(_.dom.$win)).to.be.true + expect(_.dom.is$Element(_.dom.$win)).to.equal(true) expect(_.dom.$win[0]).to.equal(window) }) }) describe('_.dom.$root', function () { it('is a $collection of `document.documentElement` object', function () { - expect(_.dom.is$Element(_.dom.$root)).to.be.true + expect(_.dom.is$Element(_.dom.$root)).to.equal(true) expect(_.dom.$root[0]).to.equal(document.documentElement) expect(_.dom.$root[0].tagName.toUpperCase()).to.equal('HTML') }) }) describe('_.dom.$body', function () { it('is a $collection of `document.body` object', function () { - expect(_.dom.is$Element(_.dom.$body)).to.be.true + expect(_.dom.is$Element(_.dom.$body)).to.equal(true) expect(_.dom.$body[0]).to.equal(document.body) }) }) @@ -26,26 +26,26 @@ describe('DOM', function () { it('checks if it\'s $collection', function () { var arg arg = $() - expect(_.dom.is$Element(arg)).to.be.true + expect(_.dom.is$Element(arg)).to.equal(true) arg = $(window) - expect(_.dom.is$Element(arg)).to.be.true + expect(_.dom.is$Element(arg)).to.equal(true) }) it('returns `false` if bad type of param', function () { var arg arg = undefined - expect(_.dom.is$Element(arg)).to.be.false + expect(_.dom.is$Element(arg)).to.equal(false) arg = null - expect(_.dom.is$Element(arg)).to.be.false + expect(_.dom.is$Element(arg)).to.equal(false) arg = 0 - expect(_.dom.is$Element(arg)).to.be.false + expect(_.dom.is$Element(arg)).to.equal(false) arg = true - expect(_.dom.is$Element(arg)).to.be.false + expect(_.dom.is$Element(arg)).to.equal(false) arg = {} - expect(_.dom.is$Element(arg)).to.be.false + expect(_.dom.is$Element(arg)).to.equal(false) arg = [] - expect(_.dom.is$Element(arg)).to.be.false + expect(_.dom.is$Element(arg)).to.equal(false) arg = document.documentElement - expect(_.dom.is$Element(arg)).to.be.false + expect(_.dom.is$Element(arg)).to.equal(false) }) }) }) diff --git a/test/test-root.js b/test/test-root.js index 9e4730e..a695750 100644 --- a/test/test-root.js +++ b/test/test-root.js @@ -1,47 +1,47 @@ describe('(Root)', function () { describe('_.isPlainObject()', function () { it('is an alias of $\'s same api', function () { - expect($.isPlainObject === _.isPlainObject).to.be.true + expect($.isPlainObject === _.isPlainObject).to.equal(true) }) it('does basic functionality', function () { var arg arg = {} - expect(_.isPlainObject(arg)).to.be.true + expect(_.isPlainObject(arg)).to.equal(true) arg = {foo: 1, bar: 2} - expect(_.isPlainObject(arg)).to.be.true + expect(_.isPlainObject(arg)).to.equal(true) arg = new Object() - expect(_.isPlainObject(arg)).to.be.true + expect(_.isPlainObject(arg)).to.equal(true) arg = /foobar/i - expect(_.isPlainObject(arg)).to.be.false + expect(_.isPlainObject(arg)).to.equal(false) arg = new Date() - expect(_.isPlainObject(arg)).to.be.false + expect(_.isPlainObject(arg)).to.equal(false) arg = new String('foobar') - expect(_.isPlainObject(arg)).to.be.false + expect(_.isPlainObject(arg)).to.equal(false) arg = window - expect(_.isPlainObject(arg)).to.be.false + expect(_.isPlainObject(arg)).to.equal(false) arg = document.documentElement - expect(_.isPlainObject(arg)).to.be.false + expect(_.isPlainObject(arg)).to.equal(false) }) it('returns `false` if input other types', function () { var arg arg = undefined - expect(_.isPlainObject(arg)).to.be.false + expect(_.isPlainObject(arg)).to.equal(false) arg = null - expect(_.isPlainObject(arg)).to.be.false + expect(_.isPlainObject(arg)).to.equal(false) arg = 0 - expect(_.isPlainObject(arg)).to.be.false + expect(_.isPlainObject(arg)).to.equal(false) arg = 'foobar' - expect(_.isPlainObject(arg)).to.be.false + expect(_.isPlainObject(arg)).to.equal(false) arg = true - expect(_.isPlainObject(arg)).to.be.false + expect(_.isPlainObject(arg)).to.equal(false) arg = [] - expect(_.isPlainObject(arg)).to.be.false + expect(_.isPlainObject(arg)).to.equal(false) arg = it - expect(_.isPlainObject(arg)).to.be.false + expect(_.isPlainObject(arg)).to.equal(false) arg = String - expect(_.isPlainObject(arg)).to.be.false + expect(_.isPlainObject(arg)).to.equal(false) arg = Date - expect(_.isPlainObject(arg)).to.be.false + expect(_.isPlainObject(arg)).to.equal(false) }) }) @@ -49,7 +49,7 @@ describe('(Root)', function () { it('does basic functionality same as $()', function () { var elem = document.getElementById('mocha') var obj = _.$(elem) - expect(obj).to.deep.equal($(elem)) + expect(obj).to.eql($(elem)) }) it('returns directly if already $collection', function () { var obj = $('#mocha') diff --git a/test/test-str-alt.js b/test/test-str-alt.js index ac3b81a..5694118 100644 --- a/test/test-str-alt.js +++ b/test/test-str-alt.js @@ -45,7 +45,7 @@ describe('String - Alternative to Underscore.string', function () { expect(_.str.ltrim('ffooff', 'f'), 'ooff') expect(_.str.ltrim('_-foobar-_', '_-'), 'foobar-_') - + expect(_.str.ltrim(123, 1), '23') }) it('doesn\'t remove inner spaces', function () { @@ -78,96 +78,96 @@ describe('String - Alternative to Underscore.string', function () { describe('_.str.contains()', function () { it('does basic functionality', function () { - expect(_.str.contains('foobar', 'bar')).to.be.true - expect(!_.str.contains('foobar', 'buzz')).to.be.true - expect(_.str.contains(12345, 34)).to.be.true - expect(!_.str.contains(12345, 6)).to.be.true - expect(!_.str.contains('', 34)).to.be.true - expect(!_.str.contains(null, 34)).to.be.true - expect(_.str.contains(null, '')).to.be.true + expect(_.str.contains('foobar', 'bar')).to.equal(true) + expect(!_.str.contains('foobar', 'buzz')).to.equal(true) + expect(_.str.contains(12345, 34)).to.equal(true) + expect(!_.str.contains(12345, 6)).to.equal(true) + expect(!_.str.contains('', 34)).to.equal(true) + expect(!_.str.contains(null, 34)).to.equal(true) + expect(_.str.contains(null, '')).to.equal(true) }) it('supports additional param - position', function () { - expect(_.str.contains('foobar', 'bar', 1)).to.be.true - expect(_.str.contains('foobar', 'bar', 2)).to.be.true - expect(_.str.contains('foobar', 'bar', 3)).to.be.true - expect(_.str.contains('foobar', 'bar', 4)).to.be.false + expect(_.str.contains('foobar', 'bar', 1)).to.equal(true) + expect(_.str.contains('foobar', 'bar', 2)).to.equal(true) + expect(_.str.contains('foobar', 'bar', 3)).to.equal(true) + expect(_.str.contains('foobar', 'bar', 4)).to.equal(false) }) }) describe('_.str.startsWith()', function () { it('does basic functionality', function () { - expect(_.str.startsWith('foobar', 'foo')).to.be.true - expect(!_.str.startsWith('oobar', 'foo')).to.be.true - expect(_.str.startsWith('oobar', 'o')).to.be.true - expect(_.str.startsWith(12345, 123)).to.be.true - expect(!_.str.startsWith(2345, 123)).to.be.true - expect(_.str.startsWith('', '')).to.be.true - expect(_.str.startsWith(null, '')).to.be.true - expect(!_.str.startsWith(null, 'foo')).to.be.true - - expect(_.str.startsWith('-foobar', 'foo', 1)).to.be.true - expect(_.str.startsWith('foobar', 'foo', 0)).to.be.true - expect(!_.str.startsWith('foobar', 'foo', 1)).to.be.true - - expect(_.str.startsWith('Äpfel', 'Ä')).to.be.true - - expect(_.str.startsWith('hello', 'hell')).to.be.true - expect(_.str.startsWith('HELLO', 'HELL')).to.be.true - expect(_.str.startsWith('HELLO', 'hell')).to.be.false - expect(_.str.startsWith('HELLO', 'hell')).to.be.false - expect(_.str.startsWith('hello', 'hell', 0)).to.be.true - expect(_.str.startsWith('HELLO', 'HELL', 0)).to.be.true - expect(_.str.startsWith('HELLO', 'hell', 0)).to.be.false - expect(_.str.startsWith('HELLO', 'hell', 0)).to.be.false - expect(_.str.startsWith('HELLO')).to.be.false - expect(_.str.startsWith('undefined')).to.be.true - expect(_.str.startsWith('null', null)).to.be.true - expect(_.str.startsWith('hello', 'hell', -20)).to.be.true - expect(_.str.startsWith('hello', 'hell', 1)).to.be.false - expect(_.str.startsWith('hello', 'hell', 2)).to.be.false - expect(_.str.startsWith('hello', 'hell', 3)).to.be.false - expect(_.str.startsWith('hello', 'hell', 4)).to.be.false - expect(_.str.startsWith('hello', 'hell', 5)).to.be.false - expect(_.str.startsWith('hello', 'hell', 20)).to.be.false + expect(_.str.startsWith('foobar', 'foo')).to.equal(true) + expect(!_.str.startsWith('oobar', 'foo')).to.equal(true) + expect(_.str.startsWith('oobar', 'o')).to.equal(true) + expect(_.str.startsWith(12345, 123)).to.equal(true) + expect(!_.str.startsWith(2345, 123)).to.equal(true) + expect(_.str.startsWith('', '')).to.equal(true) + expect(_.str.startsWith(null, '')).to.equal(true) + expect(!_.str.startsWith(null, 'foo')).to.equal(true) + + expect(_.str.startsWith('-foobar', 'foo', 1)).to.equal(true) + expect(_.str.startsWith('foobar', 'foo', 0)).to.equal(true) + expect(!_.str.startsWith('foobar', 'foo', 1)).to.equal(true) + + expect(_.str.startsWith('Äpfel', 'Ä')).to.equal(true) + + expect(_.str.startsWith('hello', 'hell')).to.equal(true) + expect(_.str.startsWith('HELLO', 'HELL')).to.equal(true) + expect(_.str.startsWith('HELLO', 'hell')).to.equal(false) + expect(_.str.startsWith('HELLO', 'hell')).to.equal(false) + expect(_.str.startsWith('hello', 'hell', 0)).to.equal(true) + expect(_.str.startsWith('HELLO', 'HELL', 0)).to.equal(true) + expect(_.str.startsWith('HELLO', 'hell', 0)).to.equal(false) + expect(_.str.startsWith('HELLO', 'hell', 0)).to.equal(false) + expect(_.str.startsWith('HELLO')).to.equal(false) + expect(_.str.startsWith('undefined')).to.equal(true) + expect(_.str.startsWith('null', null)).to.equal(true) + expect(_.str.startsWith('hello', 'hell', -20)).to.equal(true) + expect(_.str.startsWith('hello', 'hell', 1)).to.equal(false) + expect(_.str.startsWith('hello', 'hell', 2)).to.equal(false) + expect(_.str.startsWith('hello', 'hell', 3)).to.equal(false) + expect(_.str.startsWith('hello', 'hell', 4)).to.equal(false) + expect(_.str.startsWith('hello', 'hell', 5)).to.equal(false) + expect(_.str.startsWith('hello', 'hell', 20)).to.equal(false) }); }) describe('_.str.endsWith()', function () { it('does basic functionality', function () { - expect(_.str.endsWith('foobar', 'bar')).to.be.true - expect(_.str.endsWith('foobarfoobar', 'bar')).to.be.true - expect(_.str.endsWith('foo', 'o')).to.be.true - expect(_.str.endsWith('foobar', 'bar')).to.be.true - expect(_.str.endsWith('00018-0000062.Plone.sdh264.1a7264e6912a91aa4a81b64dc5517df7b8875994.mp4', 'mp4')).to.be.true - expect(!_.str.endsWith('fooba', 'bar')).to.be.true - expect(_.str.endsWith(12345, 45)).to.be.true - expect(!_.str.endsWith(12345, 6)).to.be.true - expect(_.str.endsWith('', '')).to.be.true - expect(_.str.endsWith(null, '')).to.be.true - expect(!_.str.endsWith(null, 'foo')).to.be.true - - expect(_.str.endsWith('foobar?', 'bar', 6)).to.be.true - expect(_.str.endsWith(12345, 34, 4)).to.be.true - expect(!_.str.endsWith(12345, 45, 4)).to.be.true - - expect(_.str.endsWith('foobä', 'ä')).to.be.true - - expect(_.str.endsWith('vader', 'der')).to.be.true - expect(_.str.endsWith('VADER', 'DER')).to.be.true - expect(_.str.endsWith('VADER', 'der')).to.be.false - expect(_.str.endsWith('VADER', 'DeR')).to.be.false - expect(_.str.endsWith('VADER')).to.be.false - expect(_.str.endsWith('undefined')).to.be.true - expect(_.str.endsWith('null', null)).to.be.true - expect(_.str.endsWith('vader', 'der', 5)).to.be.true - expect(_.str.endsWith('VADER', 'DER', 5)).to.be.true - expect(_.str.endsWith('VADER', 'der', 5)).to.be.false - expect(_.str.endsWith('VADER', 'DER', 5)).to.be.true - expect(_.str.endsWith('VADER', 'der', 5)).to.be.false - expect(_.str.endsWith('vader', 'der', -20)).to.be.false - expect(_.str.endsWith('vader', 'der', 0)).to.be.false - expect(_.str.endsWith('vader', 'der', 1)).to.be.false - expect(_.str.endsWith('vader', 'der', 2)).to.be.false - expect(_.str.endsWith('vader', 'der', 3)).to.be.false - expect(_.str.endsWith('vader', 'der', 4)).to.be.false + expect(_.str.endsWith('foobar', 'bar')).to.equal(true) + expect(_.str.endsWith('foobarfoobar', 'bar')).to.equal(true) + expect(_.str.endsWith('foo', 'o')).to.equal(true) + expect(_.str.endsWith('foobar', 'bar')).to.equal(true) + expect(_.str.endsWith('00018-0000062.Plone.sdh264.1a7264e6912a91aa4a81b64dc5517df7b8875994.mp4', 'mp4')).to.equal(true) + expect(!_.str.endsWith('fooba', 'bar')).to.equal(true) + expect(_.str.endsWith(12345, 45)).to.equal(true) + expect(!_.str.endsWith(12345, 6)).to.equal(true) + expect(_.str.endsWith('', '')).to.equal(true) + expect(_.str.endsWith(null, '')).to.equal(true) + expect(!_.str.endsWith(null, 'foo')).to.equal(true) + + expect(_.str.endsWith('foobar?', 'bar', 6)).to.equal(true) + expect(_.str.endsWith(12345, 34, 4)).to.equal(true) + expect(!_.str.endsWith(12345, 45, 4)).to.equal(true) + + expect(_.str.endsWith('foobä', 'ä')).to.equal(true) + + expect(_.str.endsWith('vader', 'der')).to.equal(true) + expect(_.str.endsWith('VADER', 'DER')).to.equal(true) + expect(_.str.endsWith('VADER', 'der')).to.equal(false) + expect(_.str.endsWith('VADER', 'DeR')).to.equal(false) + expect(_.str.endsWith('VADER')).to.equal(false) + expect(_.str.endsWith('undefined')).to.equal(true) + expect(_.str.endsWith('null', null)).to.equal(true) + expect(_.str.endsWith('vader', 'der', 5)).to.equal(true) + expect(_.str.endsWith('VADER', 'DER', 5)).to.equal(true) + expect(_.str.endsWith('VADER', 'der', 5)).to.equal(false) + expect(_.str.endsWith('VADER', 'DER', 5)).to.equal(true) + expect(_.str.endsWith('VADER', 'der', 5)).to.equal(false) + expect(_.str.endsWith('vader', 'der', -20)).to.equal(false) + expect(_.str.endsWith('vader', 'der', 0)).to.equal(false) + expect(_.str.endsWith('vader', 'der', 1)).to.equal(false) + expect(_.str.endsWith('vader', 'der', 2)).to.equal(false) + expect(_.str.endsWith('vader', 'der', 3)).to.equal(false) + expect(_.str.endsWith('vader', 'der', 4)).to.equal(false) }); }) diff --git a/test/test-str.js b/test/test-str.js index 79eb4c7..e855acf 100644 --- a/test/test-str.js +++ b/test/test-str.js @@ -7,90 +7,90 @@ describe('String', function () { var arg // normal email addr arg = 'dev' + CHAR_AT + 'cmui.net' - expect(_.str.RE_EMAIL.test(arg)).to.be.true + expect(_.str.RE_EMAIL.test(arg)).to.equal(true) // domain can be any level arg = 'dev' + CHAR_AT + 'gearbox.by.cmui.net' - expect(_.str.RE_EMAIL.test(arg)).to.be.true + expect(_.str.RE_EMAIL.test(arg)).to.equal(true) // future proof for unknown domain suffix arg = 'dev' + CHAR_AT + 'gearbox.rocks' - expect(_.str.RE_EMAIL.test(arg)).to.be.true + expect(_.str.RE_EMAIL.test(arg)).to.equal(true) // username can be numbers arg = '007' + CHAR_AT + 'cmui.net' - expect(_.str.RE_EMAIL.test(arg)).to.be.true + expect(_.str.RE_EMAIL.test(arg)).to.equal(true) // domain name can be numbers arg = 'username' + CHAR_AT + '126.com' - expect(_.str.RE_EMAIL.test(arg)).to.be.true + expect(_.str.RE_EMAIL.test(arg)).to.equal(true) // email can be in upper case arg = 'DEV' + CHAR_AT + 'CMUI.NET' - expect(_.str.RE_EMAIL.test(arg)).to.be.true + expect(_.str.RE_EMAIL.test(arg)).to.equal(true) }) it('recognizes bad value', function () { var arg // domain suffix need at least 2 letters arg = 'a' + CHAR_AT + 'a.a' - expect(_.str.RE_EMAIL.test(arg)).to.be.false + expect(_.str.RE_EMAIL.test(arg)).to.equal(false) // domain suffix cannot be numbers arg = '007' + CHAR_AT + '007.007' - expect(_.str.RE_EMAIL.test(arg)).to.be.false + expect(_.str.RE_EMAIL.test(arg)).to.equal(false) // domain cannot be ip addr arg = 'a' + CHAR_AT + '192.168.10.10' - expect(_.str.RE_EMAIL.test(arg)).to.be.false + expect(_.str.RE_EMAIL.test(arg)).to.equal(false) }) }) describe('_.str.RE_MOBILE', function () { it('matches mobile number', function () { var arg arg = '13000000000' - expect(_.str.RE_MOBILE.test(arg)).to.be.true + expect(_.str.RE_MOBILE.test(arg)).to.equal(true) arg = '13322558899' - expect(_.str.RE_MOBILE.test(arg)).to.be.true + expect(_.str.RE_MOBILE.test(arg)).to.equal(true) arg = '15966558877' - expect(_.str.RE_MOBILE.test(arg)).to.be.true + expect(_.str.RE_MOBILE.test(arg)).to.equal(true) arg = '18055668899' - expect(_.str.RE_MOBILE.test(arg)).to.be.true + expect(_.str.RE_MOBILE.test(arg)).to.equal(true) arg = 18978963214 - expect(_.str.RE_MOBILE.test(arg)).to.be.true + expect(_.str.RE_MOBILE.test(arg)).to.equal(true) }) it('recognizes bad value', function () { var arg arg = '12000000000' - expect(_.str.RE_MOBILE.test(arg)).to.be.false + expect(_.str.RE_MOBILE.test(arg)).to.equal(false) arg = '1332255889' - expect(_.str.RE_MOBILE.test(arg)).to.be.false + expect(_.str.RE_MOBILE.test(arg)).to.equal(false) arg = '133-2255-8899' - expect(_.str.RE_MOBILE.test(arg)).to.be.false + expect(_.str.RE_MOBILE.test(arg)).to.equal(false) arg = 'foobar' - expect(_.str.RE_MOBILE.test(arg)).to.be.false + expect(_.str.RE_MOBILE.test(arg)).to.equal(false) }) }) describe('_.str.RE_POSTCODE', function () { it('matches postcode', function () { var arg arg = '000000' - expect(_.str.RE_POSTCODE.test(arg)).to.be.true + expect(_.str.RE_POSTCODE.test(arg)).to.equal(true) arg = '001100' - expect(_.str.RE_POSTCODE.test(arg)).to.be.true + expect(_.str.RE_POSTCODE.test(arg)).to.equal(true) arg = '220000' - expect(_.str.RE_POSTCODE.test(arg)).to.be.true + expect(_.str.RE_POSTCODE.test(arg)).to.equal(true) arg = '000022' - expect(_.str.RE_POSTCODE.test(arg)).to.be.true + expect(_.str.RE_POSTCODE.test(arg)).to.equal(true) arg = '336699' - expect(_.str.RE_POSTCODE.test(arg)).to.be.true + expect(_.str.RE_POSTCODE.test(arg)).to.equal(true) arg = 114477 - expect(_.str.RE_POSTCODE.test(arg)).to.be.true + expect(_.str.RE_POSTCODE.test(arg)).to.equal(true) }) it('recognizes bad value', function () { var arg arg = '11111' - expect(_.str.RE_POSTCODE.test(arg)).to.be.false + expect(_.str.RE_POSTCODE.test(arg)).to.equal(false) arg = '5555555' - expect(_.str.RE_POSTCODE.test(arg)).to.be.false + expect(_.str.RE_POSTCODE.test(arg)).to.equal(false) arg = '22-55-66' - expect(_.str.RE_POSTCODE.test(arg)).to.be.false + expect(_.str.RE_POSTCODE.test(arg)).to.equal(false) arg = 077777 - expect(_.str.RE_POSTCODE.test(arg)).to.be.false + expect(_.str.RE_POSTCODE.test(arg)).to.equal(false) arg = 'foobar' - expect(_.str.RE_POSTCODE.test(arg)).to.be.false + expect(_.str.RE_POSTCODE.test(arg)).to.equal(false) }) }) }) @@ -116,41 +116,41 @@ describe('String', function () { it('returns `true` if a string starts with `#`', function () { var arg arg = 'foo' - expect(_.str.isHash(arg)).to.be.false + expect(_.str.isHash(arg)).to.equal(false) arg = '#foo' - expect(_.str.isHash(arg)).to.be.true + expect(_.str.isHash(arg)).to.equal(true) arg = '###bar' - expect(_.str.isHash(arg)).to.be.true + expect(_.str.isHash(arg)).to.equal(true) arg = '#!foobar' - expect(_.str.isHash(arg)).to.be.true + expect(_.str.isHash(arg)).to.equal(true) }) it('ignores initial spaces', function () { var arg arg = ' foo ' - expect(_.str.isHash(arg)).to.be.false + expect(_.str.isHash(arg)).to.equal(false) arg = ' #foo ' - expect(_.str.isHash(arg)).to.be.true + expect(_.str.isHash(arg)).to.equal(true) arg = ' ###bar ' - expect(_.str.isHash(arg)).to.be.true + expect(_.str.isHash(arg)).to.equal(true) arg = ' #!foobar ' - expect(_.str.isHash(arg)).to.be.true + expect(_.str.isHash(arg)).to.equal(true) }) it('returns `false` if bad type of param', function () { var arg arg = undefined - expect(_.str.isHash(arg)).to.be.false + expect(_.str.isHash(arg)).to.equal(false) arg = null - expect(_.str.isHash(arg)).to.be.false + expect(_.str.isHash(arg)).to.equal(false) arg = 0 - expect(_.str.isHash(arg)).to.be.false + expect(_.str.isHash(arg)).to.equal(false) arg = true - expect(_.str.isHash(arg)).to.be.false + expect(_.str.isHash(arg)).to.equal(false) arg = {} - expect(_.str.isHash(arg)).to.be.false + expect(_.str.isHash(arg)).to.equal(false) arg = [] - expect(_.str.isHash(arg)).to.be.false + expect(_.str.isHash(arg)).to.equal(false) arg = function () {} - expect(_.str.isHash(arg)).to.be.false + expect(_.str.isHash(arg)).to.equal(false) }) }) describe('_.str.stripHash()', function () { @@ -207,7 +207,7 @@ describe('String', function () { expect(_.str.toFloat('-2e3')).to.equal(-2000) expect(_.str.toFloat('1.23foo')).to.equal(1.23) expect(_.str.toFloat('-1.23foo')).to.equal(-1.23) - expect(isNaN(_.str.toFloat('foo123'))).to.be.true + expect(isNaN(_.str.toFloat('foo123'))).to.equal(true) }) }) describe('_.str.toInt()', function () { @@ -223,7 +223,7 @@ describe('String', function () { expect(_.str.toInt('-2e100')).to.equal(-2e100) expect(_.str.toInt('1.23foo')).to.equal(1) expect(_.str.toInt('-1.23foo')).to.equal(-1) - expect(isNaN(_.str.toInt('foo123'))).to.be.true + expect(isNaN(_.str.toInt('foo123'))).to.equal(true) }) }) describe('_.str.toFixed()', function () { @@ -239,7 +239,7 @@ describe('String', function () { expect(_.str.toFixed('-2e3', 3)).to.equal(-2000) expect(_.str.toFixed('1.23foo', 1)).to.equal(1.2) expect(_.str.toFixed('-1.23foo', 1)).to.equal(-1.2) - expect(isNaN(_.str.toFixed('foo123'))).to.be.true + expect(isNaN(_.str.toFixed('foo123'))).to.equal(true) }) }) }) diff --git a/test/test-template.js b/test/test-template.js index 4f43716..b793704 100644 --- a/test/test-template.js +++ b/test/test-template.js @@ -56,36 +56,38 @@ describe('Template', function () { }) }) describe('_.template.render()', function () { - // dummy script elements - var $elem1 - var $elem2 - function prepareDummyScript() { - $elem1 = $('