Skip to content

Commit

Permalink
V1.0.3
Browse files Browse the repository at this point in the history
Add version to toolbar
add unit test
fix readme
  • Loading branch information
fakoua committed Feb 4, 2024
1 parent e1bbbdb commit 1f92724
Show file tree
Hide file tree
Showing 8 changed files with 6,784 additions and 6,664 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ Windows Services Manager by Deno!
Run the following command and see the magic!

```
deno run -A https://deno.land/x/denoman/mod.ts
deno run -A --reload https://deno.land/x/denoman/mod.ts
```
37 changes: 37 additions & 0 deletions deno.lock

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

4 changes: 2 additions & 2 deletions q-manui/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "q-manui",
"version": "1.0.2",
"description": "DenoMan 1.0.2",
"version": "1.0.3",
"description": "DenoMan 1.0.3",
"productName": "q-manui",
"author": "Sameh Fakoua <s.fakoua@gmail.com>",
"private": true,
Expand Down
7 changes: 5 additions & 2 deletions q-manui/src/layouts/MainLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<q-toolbar>
<q-toolbar-title> DenoMan </q-toolbar-title>

<div>v 0.1</div>
<div>v {{ version }}</div>
</q-toolbar>
</q-header>
<q-page-container>
Expand All @@ -15,12 +15,15 @@

<script lang="ts">
import { defineComponent } from 'vue';
import { version } from '../../package.json';
export default defineComponent({
name: 'MainLayout',
setup() {
return {};
return {
version,
};
},
});
</script>
37 changes: 37 additions & 0 deletions src/memcache_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { assertEquals } from "https://deno.land/std@0.214.0/assert/assert_equals.ts";
import { get, has, put } from "./memcache.ts";

// Mock window object
// deno-lint-ignore no-explicit-any
(window as any).GlobalCache = ["test", "test"];

Deno.test("has should return false when the key does not exist", () => {
assertEquals(has("nonexistent"), false);
});

Deno.test("has should return true when the key exists", () => {
put("test", { key: "test", obj: "test" });
assertEquals(has("test"), true);
});

Deno.test("get should return undefined when the key does not exist", () => {
assertEquals(get("nonexistent"), undefined);
});

Deno.test("get should return the object when the key exists", () => {
const obj = "test";
put("test", obj);
assertEquals(get("test"), obj);
});

Deno.test("put should add a new object to the cache", () => {
const obj = "new";
put("new", obj);
assertEquals(get("new"), obj);
});

Deno.test("put should update an existing object in the cache", () => {
const obj = "updated";
put("test", obj);
assertEquals(get("test"), obj);
});
2 changes: 2 additions & 0 deletions src/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export async function getService(
}
return undefined;
}

function processDependsWmi(wmi: string): Array<DependenciesModel> {
const rtnVal: Array<DependenciesModel> = [];
const regexAnt = /Antecedent.*\"(.*?)\"/gim; // matches Antecedent : Win32_SystemDriver (Name = "WinVerbs")
Expand All @@ -116,6 +117,7 @@ function processDependsWmi(wmi: string): Array<DependenciesModel> {
}
return rtnVal;
}

function processWmi(wmi: string, isSystemDriver: boolean): ServiceModel[] {
wmi = wmi.replaceAll("\\", "|");
const regex = /\{(.*?)\}.?/gims; // match withing class ManagementObject { ... }
Expand Down
41 changes: 41 additions & 0 deletions src/wmiutils_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { assertEquals } from "https://deno.land/std@0.214.0/assert/assert_equals.ts";
import { getWmiValue } from "./wmiutils.ts";

// Test case 1: Testing with a single match
Deno.test("getWmiValue should return the correct value when there is a single match", () => {
const wmi = `class PSCustomObject
{
AcceptPause = True
Caption = test
AcceptStop = True
}`;
const result = getWmiValue<boolean>("AcceptPause", "Caption", wmi);
const expected = true;
assertEquals(result, expected);
});

Deno.test("getWmiValue should return string", () => {
const wmi = `class PSCustomObject
{
AcceptPause = True
Caption = test
AcceptStop = True
}`;
const result = getWmiValue<string>("Caption", "AcceptStop", wmi);
const expected = "test";
assertEquals(result, expected);
});

// Test case 3: Testing with boolean values
Deno.test("getWmiValue should return boolean false correctly", () => {
const wmi = `class PSCustomObject
{
AcceptPause = True
Caption = test
AcceptStop = False
Foo = Bar
}`;
const result1 = getWmiValue<boolean>("AcceptStop", "Foo", wmi);
const expected1 = false;
assertEquals(result1, expected1);
});
Loading

0 comments on commit 1f92724

Please sign in to comment.