mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix hotbar store tests
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
6c061165de
commit
e414fbace5
@ -115,6 +115,7 @@ describe("HotbarStore", () => {
|
|||||||
|
|
||||||
di.permitSideEffects(fsInjectable);
|
di.permitSideEffects(fsInjectable);
|
||||||
di.permitSideEffects(getConfigurationFileModelInjectable);
|
di.permitSideEffects(getConfigurationFileModelInjectable);
|
||||||
|
di.unoverride(getConfigurationFileModelInjectable);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -256,22 +257,12 @@ describe("HotbarStore", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("throws if invalid arguments provided", () => {
|
it("throws if invalid arguments provided", () => {
|
||||||
// Prevent writing to stderr during this render.
|
|
||||||
const { error, warn } = console;
|
|
||||||
|
|
||||||
console.error = jest.fn();
|
|
||||||
console.warn = jest.fn();
|
|
||||||
|
|
||||||
hotbarStore.addToHotbar(testCluster);
|
hotbarStore.addToHotbar(testCluster);
|
||||||
|
|
||||||
expect(() => hotbarStore.restackItems(-5, 0)).toThrow();
|
expect(() => hotbarStore.restackItems(-5, 0)).toThrow();
|
||||||
expect(() => hotbarStore.restackItems(2, -1)).toThrow();
|
expect(() => hotbarStore.restackItems(2, -1)).toThrow();
|
||||||
expect(() => hotbarStore.restackItems(14, 1)).toThrow();
|
expect(() => hotbarStore.restackItems(14, 1)).toThrow();
|
||||||
expect(() => hotbarStore.restackItems(11, 112)).toThrow();
|
expect(() => hotbarStore.restackItems(11, 112)).toThrow();
|
||||||
|
|
||||||
// Restore writing to stderr.
|
|
||||||
console.error = error;
|
|
||||||
console.warn = warn;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("checks if entity already pinned to hotbar", () => {
|
it("checks if entity already pinned to hotbar", () => {
|
||||||
@ -285,7 +276,7 @@ describe("HotbarStore", () => {
|
|||||||
|
|
||||||
describe("given data from 5.0.0-beta.3 and version being 5.0.0-beta.10", () => {
|
describe("given data from 5.0.0-beta.3 and version being 5.0.0-beta.10", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
const configurationToBeMigrated = {
|
mockFs({
|
||||||
"some-directory-for-user-data": {
|
"some-directory-for-user-data": {
|
||||||
"lens-hotbar-store.json": JSON.stringify({
|
"lens-hotbar-store.json": JSON.stringify({
|
||||||
__internal__: {
|
__internal__: {
|
||||||
@ -345,9 +336,7 @@ describe("HotbarStore", () => {
|
|||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
};
|
});
|
||||||
|
|
||||||
mockFs(configurationToBeMigrated);
|
|
||||||
|
|
||||||
di.override(storeMigrationVersionInjectable, () => "5.0.0-beta.10");
|
di.override(storeMigrationVersionInjectable, () => "5.0.0-beta.10");
|
||||||
|
|
||||||
|
|||||||
@ -53,7 +53,6 @@ export class HotbarStore extends BaseStore<HotbarStoreModel> {
|
|||||||
if (typeof hotbar === "number") {
|
if (typeof hotbar === "number") {
|
||||||
if (hotbar >= 0 && hotbar < this.hotbars.length) {
|
if (hotbar >= 0 && hotbar < this.hotbars.length) {
|
||||||
this._activeHotbarId = this.hotbars[hotbar].id;
|
this._activeHotbarId = this.hotbars[hotbar].id;
|
||||||
console.log("in _activeHotbarId", this._activeHotbarId);
|
|
||||||
}
|
}
|
||||||
} else if (typeof hotbar === "string") {
|
} else if (typeof hotbar === "string") {
|
||||||
if (this.findById(hotbar)) {
|
if (this.findById(hotbar)) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user