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

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 outstanding feedbacks 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
« no previous file with comments | « remoting/webapp/crd/js/remoting.js ('k') | remoting/webapp/unittests/chrome_mocks.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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, v1HasHosts) {
29 remoting.identity.getUserInfo = function(onDone, onError) {
30 if (base.isAppsV2()) {
31 onDone('v2user@gmail.com','v2userName');
32 } else {
33 onDone(v1UserEmail, v1UserName);
34 }
35 };
36
37 mockIsAppsV2.returns(false);
38 if (v1HasHosts) {
39 remoting.AppsV2Migration.saveUserInfo();
40 }
41 }
42
43 module('AppsV2Migration', {
44 setup: function() {
45 chromeMocks.activate(['storage']);
46 mockIsAppsV2 = sinon.stub(base, 'isAppsV2');
47 remoting.identity = {};
48 },
49 teardown: function() {
50 chromeMocks.restore();
51 mockIsAppsV2.restore();
52 remoting.identity = null;
53 }
54 });
55
56 QUnit.asyncTest(
57 'hasHostsInV1App() should reject the promise if v1 user has same identity',
58 function() {
59 setMigrationData_('v1userName', 'v2user@gmail.com', true);
60 mockIsAppsV2.returns(true);
61 remoting.AppsV2Migration.hasHostsInV1App().then(fail, pass);
62 });
63
64 QUnit.asyncTest(
65 'hasHostsInV1App() should reject the promise if v1 user has no hosts',
66 function() {
67 setMigrationData_('v1userName', 'v1user@gmail.com', false);
68 mockIsAppsV2.returns(true);
69 remoting.AppsV2Migration.hasHostsInV1App().then(fail, pass);
70 });
71
72 QUnit.asyncTest(
73 'hasHostsInV1App() should reject the promise in v1', function() {
74 setMigrationData_('v1userName', 'v1user@gmail.com', true);
75 mockIsAppsV2.returns(false);
76 remoting.AppsV2Migration.hasHostsInV1App().then(fail, pass);
77 });
78
79 QUnit.asyncTest(
80 'hasHostsInV1App() should return v1 identity if v1 user has hosts',
81 function() {
82 setMigrationData_('v1userName', 'v1user@gmail.com', true);
83 mockIsAppsV2.returns(true);
84 remoting.AppsV2Migration.hasHostsInV1App().then(
85 function(result) {
86 QUnit.equal(result.email, 'v1user@gmail.com');
87 QUnit.equal(result.fullName, 'v1userName');
88 pass();
89 }, fail
90 );
91 });
92
93 QUnit.asyncTest(
94 'saveUserInfo() should clear the preferences on v2',
95 function() {
96 setMigrationData_('v1userName', 'v1user@gmail.com', 'v2user@gmail.com',
97 true);
98 mockIsAppsV2.returns(true);
99 remoting.AppsV2Migration.saveUserInfo(true);
100 remoting.AppsV2Migration.hasHostsInV1App().then(fail, pass);
101 });
102
103 })();
OLDNEW
« no previous file with comments | « remoting/webapp/crd/js/remoting.js ('k') | remoting/webapp/unittests/chrome_mocks.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698