Skip to content

Commit 1f92724

Browse files
committed
V1.0.3
Add version to toolbar add unit test fix readme
1 parent e1bbbdb commit 1f92724

File tree

8 files changed

+6784
-6664
lines changed

8 files changed

+6784
-6664
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ Windows Services Manager by Deno!
77
Run the following command and see the magic!
88

99
```
10-
deno run -A https://deno.land/x/denoman/mod.ts
10+
deno run -A --reload https://deno.land/x/denoman/mod.ts
1111
```

deno.lock

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

q-manui/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "q-manui",
3-
"version": "1.0.2",
4-
"description": "DenoMan 1.0.2",
3+
"version": "1.0.3",
4+
"description": "DenoMan 1.0.3",
55
"productName": "q-manui",
66
"author": "Sameh Fakoua <s.fakoua@gmail.com>",
77
"private": true,

q-manui/src/layouts/MainLayout.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<q-toolbar>
55
<q-toolbar-title> DenoMan </q-toolbar-title>
66

7-
<div>v 0.1</div>
7+
<div>v {{ version }}</div>
88
</q-toolbar>
99
</q-header>
1010
<q-page-container>
@@ -15,12 +15,15 @@
1515

1616
<script lang="ts">
1717
import { defineComponent } from 'vue';
18+
import { version } from '../../package.json';
1819
1920
export default defineComponent({
2021
name: 'MainLayout',
2122
2223
setup() {
23-
return {};
24+
return {
25+
version,
26+
};
2427
},
2528
});
2629
</script>

src/memcache_test.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { assertEquals } from "https://deno.land/std@0.214.0/assert/assert_equals.ts";
2+
import { get, has, put } from "./memcache.ts";
3+
4+
// Mock window object
5+
// deno-lint-ignore no-explicit-any
6+
(window as any).GlobalCache = ["test", "test"];
7+
8+
Deno.test("has should return false when the key does not exist", () => {
9+
assertEquals(has("nonexistent"), false);
10+
});
11+
12+
Deno.test("has should return true when the key exists", () => {
13+
put("test", { key: "test", obj: "test" });
14+
assertEquals(has("test"), true);
15+
});
16+
17+
Deno.test("get should return undefined when the key does not exist", () => {
18+
assertEquals(get("nonexistent"), undefined);
19+
});
20+
21+
Deno.test("get should return the object when the key exists", () => {
22+
const obj = "test";
23+
put("test", obj);
24+
assertEquals(get("test"), obj);
25+
});
26+
27+
Deno.test("put should add a new object to the cache", () => {
28+
const obj = "new";
29+
put("new", obj);
30+
assertEquals(get("new"), obj);
31+
});
32+
33+
Deno.test("put should update an existing object in the cache", () => {
34+
const obj = "updated";
35+
put("test", obj);
36+
assertEquals(get("test"), obj);
37+
});

src/services.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export async function getService(
9696
}
9797
return undefined;
9898
}
99+
99100
function processDependsWmi(wmi: string): Array<DependenciesModel> {
100101
const rtnVal: Array<DependenciesModel> = [];
101102
const regexAnt = /Antecedent.*\"(.*?)\"/gim; // matches Antecedent : Win32_SystemDriver (Name = "WinVerbs")
@@ -116,6 +117,7 @@ function processDependsWmi(wmi: string): Array<DependenciesModel> {
116117
}
117118
return rtnVal;
118119
}
120+
119121
function processWmi(wmi: string, isSystemDriver: boolean): ServiceModel[] {
120122
wmi = wmi.replaceAll("\\", "|");
121123
const regex = /\{(.*?)\}.?/gims; // match withing class ManagementObject { ... }

src/wmiutils_test.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { assertEquals } from "https://deno.land/std@0.214.0/assert/assert_equals.ts";
2+
import { getWmiValue } from "./wmiutils.ts";
3+
4+
// Test case 1: Testing with a single match
5+
Deno.test("getWmiValue should return the correct value when there is a single match", () => {
6+
const wmi = `class PSCustomObject
7+
{
8+
AcceptPause = True
9+
Caption = test
10+
AcceptStop = True
11+
}`;
12+
const result = getWmiValue<boolean>("AcceptPause", "Caption", wmi);
13+
const expected = true;
14+
assertEquals(result, expected);
15+
});
16+
17+
Deno.test("getWmiValue should return string", () => {
18+
const wmi = `class PSCustomObject
19+
{
20+
AcceptPause = True
21+
Caption = test
22+
AcceptStop = True
23+
}`;
24+
const result = getWmiValue<string>("Caption", "AcceptStop", wmi);
25+
const expected = "test";
26+
assertEquals(result, expected);
27+
});
28+
29+
// Test case 3: Testing with boolean values
30+
Deno.test("getWmiValue should return boolean false correctly", () => {
31+
const wmi = `class PSCustomObject
32+
{
33+
AcceptPause = True
34+
Caption = test
35+
AcceptStop = False
36+
Foo = Bar
37+
}`;
38+
const result1 = getWmiValue<boolean>("AcceptStop", "Foo", wmi);
39+
const expected1 = false;
40+
assertEquals(result1, expected1);
41+
});

0 commit comments

Comments
 (0)