|
| 1 | +/** |
| 2 | + * Copyright (c) 2020 Gitpod GmbH. All rights reserved. |
| 3 | + * Licensed under the GNU Affero General Public License (AGPL). |
| 4 | + * See License-AGPL.txt in the project root for license information. |
| 5 | + */ |
| 6 | + |
| 7 | +import { User } from "@gitpod/gitpod-protocol"; |
| 8 | +import * as chai from "chai"; |
| 9 | +import { IDEService } from "./ide-service"; |
| 10 | +const expect = chai.expect; |
| 11 | + |
| 12 | +describe("ide-service", function () { |
| 13 | + describe("migrateSettings", function () { |
| 14 | + const ideService = new IDEService(); |
| 15 | + it("with no ideSettings should be undefined", function () { |
| 16 | + const user: User = { |
| 17 | + id: "string", |
| 18 | + |
| 19 | + creationDate: "string", |
| 20 | + identities: [], |
| 21 | + additionalData: {}, |
| 22 | + }; |
| 23 | + const result = ideService.migrateSettings(user); |
| 24 | + expect(result).to.undefined; |
| 25 | + }); |
| 26 | + |
| 27 | + it("with settingVersion 2.0 should be undefined", function () { |
| 28 | + const user: User = { |
| 29 | + id: "string", |
| 30 | + creationDate: "string", |
| 31 | + identities: [], |
| 32 | + additionalData: { |
| 33 | + ideSettings: { |
| 34 | + settingVersion: "2.0", |
| 35 | + defaultIde: "code-latest", |
| 36 | + useDesktopIde: false, |
| 37 | + }, |
| 38 | + }, |
| 39 | + }; |
| 40 | + const result = ideService.migrateSettings(user); |
| 41 | + expect(result).to.undefined; |
| 42 | + }); |
| 43 | + |
| 44 | + it("with code-latest should be code latest", function () { |
| 45 | + const user: User = { |
| 46 | + id: "string", |
| 47 | + creationDate: "string", |
| 48 | + identities: [], |
| 49 | + additionalData: { |
| 50 | + ideSettings: { |
| 51 | + defaultIde: "code-latest", |
| 52 | + useDesktopIde: false, |
| 53 | + }, |
| 54 | + }, |
| 55 | + }; |
| 56 | + const result = ideService.migrateSettings(user); |
| 57 | + expect(result?.defaultIde).to.equal("code"); |
| 58 | + expect(result?.useLatestVersion ?? false).to.be.true; |
| 59 | + }); |
| 60 | + |
| 61 | + it("with code-desktop-insiders should be code-desktop latest", function () { |
| 62 | + const user: User = { |
| 63 | + id: "string", |
| 64 | + creationDate: "string", |
| 65 | + identities: [], |
| 66 | + additionalData: { |
| 67 | + ideSettings: { |
| 68 | + defaultIde: "code", |
| 69 | + defaultDesktopIde: "code-desktop-insiders", |
| 70 | + useDesktopIde: true, |
| 71 | + }, |
| 72 | + }, |
| 73 | + }; |
| 74 | + const result = ideService.migrateSettings(user); |
| 75 | + expect(result?.defaultIde).to.equal("code-desktop"); |
| 76 | + expect(result?.useLatestVersion ?? false).to.be.true; |
| 77 | + }); |
| 78 | + |
| 79 | + it("with code-desktop should be code-desktop", function () { |
| 80 | + const user: User = { |
| 81 | + id: "string", |
| 82 | + creationDate: "string", |
| 83 | + identities: [], |
| 84 | + additionalData: { |
| 85 | + ideSettings: { |
| 86 | + defaultIde: "code", |
| 87 | + defaultDesktopIde: "code-desktop", |
| 88 | + useDesktopIde: true, |
| 89 | + }, |
| 90 | + }, |
| 91 | + }; |
| 92 | + const result = ideService.migrateSettings(user); |
| 93 | + expect(result?.defaultIde).to.equal("code-desktop"); |
| 94 | + expect(result?.useLatestVersion ?? false).to.be.false; |
| 95 | + }); |
| 96 | + |
| 97 | + it("with intellij should be intellij", function () { |
| 98 | + const user: User = { |
| 99 | + id: "string", |
| 100 | + creationDate: "string", |
| 101 | + identities: [], |
| 102 | + additionalData: { |
| 103 | + ideSettings: { |
| 104 | + defaultIde: "code", |
| 105 | + defaultDesktopIde: "intellij", |
| 106 | + useLatestVersion: false, |
| 107 | + useDesktopIde: true, |
| 108 | + }, |
| 109 | + }, |
| 110 | + }; |
| 111 | + const result = ideService.migrateSettings(user); |
| 112 | + expect(result?.defaultIde).to.equal("intellij"); |
| 113 | + expect(result?.useLatestVersion ?? false).to.be.false; |
| 114 | + }); |
| 115 | + |
| 116 | + it("with intellij latest version should be intellij latest", function () { |
| 117 | + const user: User = { |
| 118 | + id: "string", |
| 119 | + creationDate: "string", |
| 120 | + identities: [], |
| 121 | + additionalData: { |
| 122 | + ideSettings: { |
| 123 | + defaultIde: "code", |
| 124 | + defaultDesktopIde: "intellij", |
| 125 | + useLatestVersion: true, |
| 126 | + useDesktopIde: true, |
| 127 | + }, |
| 128 | + }, |
| 129 | + }; |
| 130 | + const result = ideService.migrateSettings(user); |
| 131 | + expect(result?.defaultIde).to.equal("intellij"); |
| 132 | + expect(result?.useLatestVersion ?? false).to.be.true; |
| 133 | + }); |
| 134 | + |
| 135 | + it("with user desktopIde false should be code latest", function () { |
| 136 | + const user: User = { |
| 137 | + id: "string", |
| 138 | + creationDate: "string", |
| 139 | + identities: [], |
| 140 | + additionalData: { |
| 141 | + ideSettings: { |
| 142 | + defaultIde: "code-latest", |
| 143 | + defaultDesktopIde: "intellij", |
| 144 | + useLatestVersion: false, |
| 145 | + useDesktopIde: false, |
| 146 | + }, |
| 147 | + }, |
| 148 | + }; |
| 149 | + const result = ideService.migrateSettings(user); |
| 150 | + expect(result?.defaultIde).to.equal("code"); |
| 151 | + expect(result?.useLatestVersion ?? false).to.be.true; |
| 152 | + }); |
| 153 | + }); |
| 154 | +}); |
0 commit comments