Created
September 17, 2014 20:42
-
-
Save leobalter/582e325ef9cfdbac41b7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
QUnit.suite('jQuery Core', function (assert, test) { | |
test.beforeEach(function (assert) { | |
var env = this, | |
done = assert.async(); | |
this.user = 'data'; | |
setTimeout(function () { | |
env.foo = 'bar'; | |
done(); | |
}, 100); | |
if (false) { | |
assert.ok(false, 'No pending XHR requests'); | |
} | |
if (false) { | |
assert.ok(false, 'Stale jQuery.cache contents'); | |
} | |
}); | |
test('isArray', function (assert) { | |
assert.equal(jQuery.isArray([]), true); | |
assert.equal(jQuery.isArray(null), false); | |
}); | |
test('addClass', function (assert, test) { | |
var node = test.htmlFixture(); | |
$(node).addClass('foo').addClass('bar'); | |
assert.equal(node.className, 'foo bar'); | |
}); | |
test('hasClass', function (assert, test) { | |
var node = test.htmlFixture('<div class="foo bar"></div>').firstChild; | |
assert.strictEqual($(node).hasClass('foo'), true); | |
assert.strictEqual($(node).hasClass('bar'), true); | |
}); | |
test('Event', function (assert, test) { | |
test.afterEach(function () { | |
this.x = Math.random(); | |
}); | |
assert.ok(!!jQuery.Event); | |
test('trigger', function (assert) { | |
var $x = $('#x'); | |
assert.equal($x.isTriggered, false); | |
assert.equal($x.triggered, 0); | |
$x.trigger(); | |
$x.trigger(); | |
assert.equal($x.isTriggered, true); | |
assert.equal($x.triggered, 2); | |
}); | |
test('dispatch', function (assert) { | |
var $x = $('#x'); | |
jQuery.Event($x).dispatch(); | |
assert.ok($x.parent().isTriggered, true); | |
}); | |
}); | |
test('xhr', function (assert) { | |
var done = assert.async(); | |
$.xhr('./post/123') | |
.done(function () { | |
assert.ok(true); | |
}) | |
.always(done); | |
}); | |
}); | |
QUnit.suite('jQuery Cookie', function (assert, test) { | |
test.beforeEach(function (assert) { | |
this.$cookie = test.stub($, 'cookie').returns(null); | |
}); | |
test('cookie', function (assert) { | |
assert.strictEqual(this.$cookie('userName'), null); | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment