Skip to content

Commit

Permalink
Updated tests for latest version of the API.
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenbenner committed Oct 4, 2012
1 parent ce4bdeb commit 53f330d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 8 deletions.
5 changes: 4 additions & 1 deletion test/tests.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ $(function() {


test('expose API', function() { test('expose API', function() {
ok($.powerTip, 'API is defined'); ok($.powerTip, 'API is defined');
strictEqual(typeof $.powerTip.show, 'function', 'show method is defined');
strictEqual(typeof $.powerTip.reposition, 'function', 'reposition method is defined');
strictEqual(typeof $.powerTip.hide, 'function', 'closeTip method is defined');
// deprecated
strictEqual(typeof $.powerTip.showTip, 'function', 'showTip method is defined'); strictEqual(typeof $.powerTip.showTip, 'function', 'showTip method is defined');
strictEqual(typeof $.powerTip.resetPosition, 'function', 'resetPosition method is defined');
strictEqual(typeof $.powerTip.closeTip, 'function', 'closeTip method is defined'); strictEqual(typeof $.powerTip.closeTip, 'function', 'closeTip method is defined');
}); });


Expand Down
46 changes: 39 additions & 7 deletions test/unit/core.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -118,13 +118,30 @@ $(function() {
}); });


test('expose API', function() { test('expose API', function() {
strictEqual(typeof $.powerTip.show, 'function', 'show is defined');
strictEqual(typeof $.powerTip.reposition, 'function', 'reposition is defined');
strictEqual(typeof $.powerTip.hide, 'function', 'hide is defined');
strictEqual(typeof $.powerTip.destroy, 'function', 'destroy is defined');
// deprecated
strictEqual(typeof $.powerTip.showTip, 'function', 'showTip is defined'); strictEqual(typeof $.powerTip.showTip, 'function', 'showTip is defined');
strictEqual(typeof $.powerTip.resetPosition, 'function', 'resetPosition is defined');
strictEqual(typeof $.powerTip.closeTip, 'function', 'closeTip is defined'); strictEqual(typeof $.powerTip.closeTip, 'function', 'closeTip is defined');
strictEqual(typeof $.powerTip.destroy, 'function', 'destroy is defined');
}); });


test('API showTip method should call DisplayController.show', function() { test('API show method should call DisplayController.show', function() {
var showCalled = false,
element = $('<span />')
.data(DATA_DISPLAYCONTROLLER, new MockDisplayController(
function() {
showCalled = true;
}
));

$.powerTip.show(element);

ok(showCalled, 'show method was called');
});

test('API showTip (DEPRECATED) method should call DisplayController.show', function() {
var showCalled = false, var showCalled = false,
element = $('<span />') element = $('<span />')
.data(DATA_DISPLAYCONTROLLER, new MockDisplayController( .data(DATA_DISPLAYCONTROLLER, new MockDisplayController(
Expand All @@ -138,7 +155,7 @@ $(function() {
ok(showCalled, 'show method was called'); ok(showCalled, 'show method was called');
}); });


test('API resetPosition method should call DisplayController.resetPosition', function() { test('API reposition method should call DisplayController.resetPosition', function() {
var resetCalled = false, var resetCalled = false,
element = $('<span />') element = $('<span />')
.data(DATA_DISPLAYCONTROLLER, new MockDisplayController( .data(DATA_DISPLAYCONTROLLER, new MockDisplayController(
Expand All @@ -150,12 +167,27 @@ $(function() {
} }
)); ));


$.powerTip.resetPosition(element); $.powerTip.reposition(element);


ok(resetCalled, 'resetPosition method was called'); ok(resetCalled, 'reposition method was called');
});

test('API hide method should call DisplayController.hide', function() {
var hideCalled = false,
element = $('<span />')
.data(DATA_DISPLAYCONTROLLER, new MockDisplayController(
null,
function() {
hideCalled = true;
}
));

$.powerTip.hide(element);

ok(hideCalled, 'hide method was called');
}); });


test('API closeTip method should call DisplayController.hide', function() { test('API closeTip (DEPRECATED) method should call DisplayController.hide', function() {
var hideCalled = false, var hideCalled = false,
element = $('<span />') element = $('<span />')
.data(DATA_DISPLAYCONTROLLER, new MockDisplayController( .data(DATA_DISPLAYCONTROLLER, new MockDisplayController(
Expand Down

0 comments on commit 53f330d

Please sign in to comment.