-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add version to toolbar add unit test fix readme
- Loading branch information
Showing
8 changed files
with
6,784 additions
and
6,664 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
Oops, something went wrong.