This repository has been archived by the owner on Oct 30, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #389 from mridgway/acTests
Finished up porting ac addon tests to Arrow
- Loading branch information
Showing
19 changed files
with
2,185 additions
and
93 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright (c) 2011-2012, Yahoo! Inc. All rights reserved. | ||
* Copyrights licensed under the New BSD License. | ||
* See the accompanying LICENSE file for terms. | ||
*/ | ||
|
||
YUI().use('mojito-device-addon', 'test', function (Y) { | ||
|
||
/** | ||
* Creates the action context Mock | ||
* */ | ||
function getAC() { | ||
var ac = { | ||
http : { | ||
req : { | ||
device : { | ||
get : function () { | ||
this.getCalled = true; | ||
return "iPhone"; | ||
} | ||
} | ||
}, | ||
getRequest : function () { | ||
return this.req; | ||
} | ||
} | ||
}; | ||
|
||
return ac; | ||
} | ||
|
||
/** | ||
* Creates the command Mock | ||
* */ | ||
function getCommand() { | ||
return { | ||
instance : { | ||
config : { | ||
} | ||
} | ||
}; | ||
} | ||
|
||
var suite = new Y.Test.Suite('mojito-device-addon tests'), | ||
A = Y.Assert, | ||
OA = Y.ObjectAssert, | ||
Mock = Y.Mock; | ||
|
||
suite.add(new Y.Test.Case({ | ||
|
||
name: 'device Add-on', | ||
|
||
setUp: function() { | ||
}, | ||
tearDown: function() { | ||
}, | ||
'test add-on functions' : function () { | ||
|
||
var command = getCommand(), | ||
ac = getAC(), | ||
addon = new Y.mojito.addons.ac.device(command, {}, ac); | ||
|
||
A.isFunction(addon.get); | ||
A.isFunction(ac.device.get); | ||
}, | ||
'test add-on calls get function' : function () { | ||
var command = getCommand(), | ||
ac = getAC(), | ||
addon = new Y.mojito.addons.ac.device(command, {}, ac); | ||
|
||
A.areEqual("iPhone", ac.device.get("Make")); | ||
A.isTrue(ac.http.req.device.getCalled); | ||
}, | ||
'test add-on is available if catalog is not available' : function () { | ||
var command = getCommand(), | ||
ac = getAC(); | ||
|
||
// Overwrite the request with the empty object | ||
ac.http.req = {}; | ||
var addon = new Y.mojito.addons.ac.device(command, {}, ac); | ||
|
||
A.isFunction(addon.get); | ||
A.isFunction(ac.device.get); | ||
A.areEqual(undefined, ac.device.get("Make")); | ||
} | ||
})); | ||
|
||
Y.Test.Runner.add(suite); | ||
|
||
}); |
Oops, something went wrong.