Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(615)

Side by Side Diff: remoting/webapp/unittests/apps_v2_migration_unittest.js

Issue 848993002: Improve apps v2 upgrade UX (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address CL feedback Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 (function() {
6
7 'use strict';
8
9 var mockIsAppsV2 = null;
10 var mockChromeStorage = {};
11
12 function pass() {
13 ok(true);
14 QUnit.start();
15 }
16
17 function fail() {
18 ok(false);
19 QUnit.start();
20 }
21
22 /**
23 * @param {string} v1UserName
24 * @param {string} v1UserEmail
25 * @param {string} currentEmail
26 * @param {boolean} v1HasHost
27 */
28 function setMigrationData_(v1UserName, v1UserEmail, currentEmail,
29 v1HasHosts) {
30 remoting.identity.getUserInfo = function(onDone, onError) {
Jamie 2015/01/21 22:02:20 You're overriding this without restoring it at the
kelvinp 2015/01/22 02:10:55 remoting.identity is null to begin with, and we ar
31 if (base.isAppsV2()) {
32 return onDone(currentEmail);
Jamie 2015/01/21 22:02:20 No need for "return", and you should specify a dum
kelvinp 2015/01/22 02:10:55 Done.
33 } else {
34 return onDone(v1UserEmail, v1UserName);
35 }
36 };
37
38 mockIsAppsV2.returns(false);
39 if (v1HasHosts) {
40 remoting.AppsV2Migration.savePreferences();
41 }
42 }
43
44 module('AppsV2Migration', {
45 setup: function() {
46 chromeMocks.activate(['storage']);
47 mockIsAppsV2 = sinon.stub(base, 'isAppsV2');
48 remoting.identity = {};
49 },
50 teardown: function() {
51 chromeMocks.restore();
52 mockIsAppsV2.restore();
53 remoting.identity = null;
54 }
55 });
56
57 QUnit.asyncTest(
58 'hasHostsInV1App() should reject the promise if v1 user has same identity',
59 function() {
60 setMigrationData_('v1userName', 'v2user@gmail.com', 'v2user@gmail.com',
61 true);
62 mockIsAppsV2.returns(true);
63 remoting.AppsV2Migration.hasHostsInV1App().then(fail, pass);
64 });
65
66 QUnit.asyncTest(
67 'hasHostsInV1App() should reject the promise if v1 user has no hosts',
68 function() {
69 setMigrationData_('v1userName', 'v1user@gmail.com', 'v2user@gmail.com',
70 false);
71 mockIsAppsV2.returns(true);
72 remoting.AppsV2Migration.hasHostsInV1App().then(fail, pass);
73 });
74
75 QUnit.asyncTest(
76 'hasHostsInV1App() should reject the promise in v1', function() {
77 setMigrationData_('v1userName', 'v1user@gmail.com', 'v2user@gmail.com',
78 true);
79 mockIsAppsV2.returns(false);
80 remoting.AppsV2Migration.hasHostsInV1App().then(fail, pass);
81 });
82
83 QUnit.asyncTest(
84 'hasHostsInV1App() should return v1 identity if v1 user has hosts',
85 function() {
86 setMigrationData_('v1userName', 'v1user@gmail.com', 'v2user@gmail.com',
87 true);
88 mockIsAppsV2.returns(true);
89 remoting.AppsV2Migration.hasHostsInV1App().then(
90 function(result) {
91 QUnit.equal(result.email, 'v1user@gmail.com');
92 QUnit.equal(result.fullName, 'v1userName');
93 pass();
94 }, fail
95 );
96 });
97
98 QUnit.asyncTest(
99 'savePreferences() should clear the preferences on v2',
100 function() {
101 setMigrationData_('v1userName', 'v1user@gmail.com', 'v2user@gmail.com',
102 true);
103 mockIsAppsV2.returns(true);
104 remoting.AppsV2Migration.savePreferences(true);
105 remoting.AppsV2Migration.hasHostsInV1App().then(fail, pass);
106 });
107
108 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698