Skip to content
This repository has been archived by the owner on Jul 18, 2022. It is now read-only.

Commit

Permalink
test on save extensions for profile
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronpowell committed Jul 3, 2019
1 parent fca8e8f commit 24929b2
Showing 1 changed file with 84 additions and 29 deletions.
113 changes: 84 additions & 29 deletions src/test/saveProfile.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
/* eslint @typescript-eslint/no-explicit-any: "off" */
import { assert } from "chai";
import * as vscode from "vscode";
import { ConfigKey, ConfigProfilesKey, ConfigStorageKey } from "../constants";
import {
ConfigKey,
ConfigProfilesKey,
ConfigStorageKey,
ConfigExtensionsKey
} from "../constants";
import Config from "../services/config";
import { ExtensionInfo } from "../services/extensions";

suite("save profile", () => {
const expectedProfileName = "test1";
const expectedProfileSettings = { foo: "bar" };
const expectedUpdatedProfileSettings = { foo: "baz", a: "b" };

teardown(async () => {
let config = vscode.workspace.getConfiguration(ConfigKey);

Expand All @@ -17,11 +20,6 @@ suite("save profile", () => {
undefined,
vscode.ConfigurationTarget.Global
);
await config.update(
ConfigStorageKey,
undefined,
vscode.ConfigurationTarget.Global
);
});

test("can save a profile name", async () => {
Expand All @@ -33,31 +31,88 @@ suite("save profile", () => {
assert.include(profiles, expectedProfileName);
});

test("can save profile settings", async () => {
var config = new Config();
suite("settings", () => {
const expectedProfileSettings = { foo: "bar" };
const expectedUpdatedProfileSettings = { foo: "baz", a: "b" };

await config.addProfileSettings(
expectedProfileName,
expectedProfileSettings
);
teardown(async () => {
let config = vscode.workspace.getConfiguration(ConfigKey);

await config.update(
ConfigStorageKey,
undefined,
vscode.ConfigurationTarget.Global
);
});

test("can save profile settings", async () => {
var config = new Config();

await config.addProfileSettings(
expectedProfileName,
expectedProfileSettings
);

let settings = config.getProfileSettings(expectedProfileName);
assert.deepEqual(settings, expectedProfileSettings);
});

let settings = config.getProfileSettings(expectedProfileName);
assert.deepEqual(settings, expectedProfileSettings);
test("can update existing profile", async () => {
var config = new Config();

await config.addProfileSettings(
expectedProfileName,
expectedProfileSettings
);
await config.addProfileSettings(
expectedProfileName,
expectedUpdatedProfileSettings
);

let settings = config.getProfileSettings(expectedProfileName);
assert.deepEqual(settings, expectedUpdatedProfileSettings);
});
});

test("can update existing profile", async () => {
var config = new Config();
suite("extensions", () => {
const expectedExtensions = [
new ExtensionInfo("abcd", "test.ext", "test", "1.0.0", "ext")
];
const expectedUpdatedExtensions = [
new ExtensionInfo("abcd", "test.ext", "test", "1.0.0", "ext"),
new ExtensionInfo("12345", "test2.ext", "test2", "1.0.0", "ext")
];

await config.addProfileSettings(
expectedProfileName,
expectedProfileSettings
);
await config.addProfileSettings(
expectedProfileName,
expectedUpdatedProfileSettings
);
teardown(async () => {
let config = vscode.workspace.getConfiguration(ConfigKey);

await config.update(
ConfigExtensionsKey,
undefined,
vscode.ConfigurationTarget.Global
);
});

test("can save extensions", async () => {
var config = new Config();

await config.addExtensions(expectedProfileName, expectedExtensions);

let settings = config.getProfileExtensions(expectedProfileName);
assert.deepEqual(settings, expectedExtensions);
});

test("can update existing profile", async () => {
var config = new Config();

await config.addExtensions(expectedProfileName, expectedExtensions);
await config.addExtensions(
expectedProfileName,
expectedUpdatedExtensions
);

let settings = config.getProfileSettings(expectedProfileName);
assert.deepEqual(settings, expectedUpdatedProfileSettings);
let settings = config.getProfileExtensions(expectedProfileName);
assert.deepEqual(settings, expectedUpdatedExtensions);
});
});
});

0 comments on commit 24929b2

Please # to comment.