Skip to content

Commit

Permalink
Вынос функции проверки сборщика в статический метод (Closes #53)
Browse files Browse the repository at this point in the history
  • Loading branch information
egorprnn committed Mar 5, 2021
1 parent c200962 commit e8b1cb5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vk-io-pages",
"version": "1.5.2",
"version": "1.5.3",
"description": "Модуль vk-io для создания динамических страниц",
"scripts": {
"tsc": "tsc && node --experimental-modules --es-module-specifier-resolution=node ./scripts/removeEmptyFiles.mjs",
Expand Down
9 changes: 8 additions & 1 deletion src/PagesManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ export class PagesManager {
}
}

/**
* Функция для проверки наличия сборщика
*/
static hasBuilder(builderId: string): boolean {
return pagesStorage.has(builderId);
}


/**
* Метод для установки обработчика при отсутствии сборщика
*/
Expand All @@ -51,7 +59,6 @@ export class PagesManager {
}
}

export { hasBuilder } from "./functions";
export {
PagesBuilder,
pagesStorage
Expand Down
9 changes: 0 additions & 9 deletions src/functions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { pagesStorage } from "./PagesBuilder";

export function randomString(length: number): string {
const characters = "abcdefghijklmnopqrstuvwxyz";

Expand All @@ -11,10 +9,3 @@ export function randomString(length: number): string {

return string;
}

/**
* Функция для проверки наличия сборщика
*/
export function hasBuilder(builderId: string): boolean {
return pagesStorage.has(builderId);
}
18 changes: 8 additions & 10 deletions test/tests.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from "assert";
import VKIO from "vk-io";

import { PagesBuilder, pagesStorage } from "../esm/index.mjs";
import { PagesBuilder, PagesManager } from "../esm/index.mjs";

const { VK, getRandomId, Keyboard } = VKIO;

Expand Down Expand Up @@ -67,17 +67,15 @@ describe("Pages", () => {
builder.addPages("Test");
builder.addPages(pages);

await assert.doesNotReject(async () => {
await builder.build();
await builder.build();

builder.sentContext = createContext();
builder.sentContext = createContext();

for (let i = 2; i <= builder.pages.length; i++) {
await builder.setPage(i);
for (let i = 2; i <= builder.pages.length; i++) {
await builder.setPage(i);

builder.sentContext = createContext();
}
});
builder.sentContext = createContext();
}
});
}

Expand Down Expand Up @@ -121,7 +119,7 @@ describe("Listen", () => {
it("Остановка прослушивания", () => {
builder.stopListen();

assert.ok(pagesStorage.get(builder.id) === undefined);
assert.ok(PagesManager.hasBuilder(builder.id) === false);
});
}
});
Expand Down

0 comments on commit e8b1cb5

Please sign in to comment.