Skip to content

Commit f760a43

Browse files
authored
Merge pull request #1100 from remotestorage/refactor/authorize_tests
Improve Authorize tests
2 parents 0bf8169 + a8afcde commit f760a43

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

test/unit/authorize-suite.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
if (typeof define !== 'function') {
22
var define = require('amdefine')(module);
33
}
4-
define([ 'require', './src/authorize', 'fs'], function(require, Authorize, fs) {
4+
define([ 'require', './src/authorize', './src/config'], function(require, Authorize, config) {
55
var suites = [];
66

77
suites.push({
@@ -82,16 +82,42 @@ define([ 'require', './src/authorize', 'fs'], function(require, Authorize, fs) {
8282
}
8383
},
8484

85+
{
86+
desc: "Authorize doesn't redirect, but opens an in-app-browser window",
87+
run: function(env, test) {
88+
document.location.href = 'file:///some/cordova/path';
89+
var authUrl = 'http://storage.provider.com/oauth';
90+
var scope = 'contacts:r';
91+
var redirectUri = 'http://awesome.app.com/#';
92+
var clientId = 'http://awesome.app.com/';
93+
94+
global.cordova = { foo: 'bar' }; // Pretend we run in Cordova
95+
96+
this.localStorageAvailable = function() { return true; };
97+
98+
Authorize.openWindow = function(url, uri) {
99+
test.assertAnd(uri, redirectUri);
100+
test.done();
101+
};
102+
103+
Authorize(this, authUrl, scope, redirectUri, clientId);
104+
105+
test.assertAnd(document.location.href, 'file:///some/cordova/path');
106+
}
107+
},
108+
85109
{
86110
desc: "document.location getter",
87111
run: function(env, test) {
112+
document.location.href = 'http://foo/bar';
88113
test.assert(Authorize.getLocation().href, "http://foo/bar");
89114
}
90115
},
91116

92117
{
93118
desc: "document.location setter",
94119
run: function(env, test) {
120+
document.location.href = 'http://foo/bar';
95121
Authorize.setLocation("https://bar/foo");
96122
test.assert(Authorize.getLocation().href, "https://bar/foo");
97123
}

0 commit comments

Comments
 (0)