-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add basic k8s info * add k8s * add clusters * unbase64 * add null check * fix encrypt * more * fix things * add cluster * fix types * longer key * use nacl * add nacl * update * add keys * fix things * add config syncing * release: v0.0.70-pre.1732232823462 * add an echo * add clusters list * fix * add clusters * add cluster details * clean cred * fix * release: v0.0.70-pre.1732315142968 * release: v0.0.71-pre.1732315608791 * fix * udpate * release: v0.0.71-pre.1732316035899 * fix * release: v0.0.71-pre.1732317365533 * add .kubedir * release: v0.0.71-pre.1732317531748 * insecure tls verify for the moment * add sell
- Loading branch information
Showing
21 changed files
with
1,637 additions
and
154 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,94 +1,95 @@ | ||
import { describe, expect, test } from "bun:test"; | ||
import { | ||
assert, | ||
assertEquals, | ||
} from "https://deno.land/[email protected]/testing/asserts.ts"; | ||
import { | ||
type Cents, | ||
centsToDollarsFormatted, | ||
priceWholeToCents, | ||
} from "../units"; | ||
|
||
describe("units", () => { | ||
test("price whole to cents", () => { | ||
const inputToExpectedValids = [ | ||
// formatted as USD | ||
["$0", 0], | ||
["$1", 100], | ||
["$10", 10_00], | ||
["$100", 100_00], | ||
|
||
["$0.0", 0], | ||
["$0.00", 0], | ||
["$0.000", 0], | ||
|
||
["$1.0", 100], | ||
["$1.00", 100], | ||
["$1.000", 100], | ||
|
||
["$1.23", 123], | ||
["$1.234", 123.4], | ||
|
||
// formatted as numbers | ||
["0", 0], | ||
["1", 100], | ||
["10", 10_00], | ||
["100", 100_00], | ||
|
||
["1.23", 123], | ||
["1.234", 123.4], | ||
|
||
// nested quotes (double) | ||
['"$0"', 0], | ||
['"$1"', 100], | ||
['"$10"', 10_00], | ||
['"0"', 0], | ||
['"1"', 100], | ||
['"10"', 10_00], | ||
|
||
// nested quotes (single) | ||
["'$0'", 0], | ||
["'$1'", 100], | ||
["'$10'", 10_00], | ||
["'$0'", 0], | ||
["'$1'", 100], | ||
["'$10'", 10_00], | ||
]; | ||
|
||
for (const [input, centsExpected] of inputToExpectedValids) { | ||
const { cents, invalid } = priceWholeToCents(input); | ||
|
||
expect(cents).not.toBeNull(); | ||
expect(cents).toEqual(centsExpected as number); | ||
expect(invalid).toBe(false); | ||
} | ||
|
||
const invalidPrices = [null, undefined, [], {}]; | ||
for (const input of invalidPrices) { | ||
const { cents, invalid } = priceWholeToCents(input as any); | ||
|
||
expect(cents).toBeNull(); | ||
expect(invalid).toBeTrue(); | ||
} | ||
}); | ||
|
||
test("cents to dollars formatted", () => { | ||
const inputToExpectedValids = [ | ||
// whole | ||
[0, "$0.00"], | ||
[100, "$1.00"], | ||
[10_00, "$10.00"], | ||
[100_00, "$100.00"], | ||
|
||
[9_99, "$9.99"], | ||
|
||
// with cents | ||
[1, "$0.01"], | ||
[2, "$0.02"], | ||
[10, "$0.10"], | ||
[90, "$0.90"], | ||
]; | ||
|
||
for (const [input, expected] of inputToExpectedValids) { | ||
const result = centsToDollarsFormatted(input as Cents); | ||
|
||
expect(result).toEqual(expected as string); | ||
} | ||
}); | ||
} from "../units.ts"; | ||
|
||
Deno.test("price whole to cents", () => { | ||
const inputToExpectedValids = [ | ||
// formatted as USD | ||
["$0", 0], | ||
["$1", 100], | ||
["$10", 10_00], | ||
["$100", 100_00], | ||
|
||
["$0.0", 0], | ||
["$0.00", 0], | ||
["$0.000", 0], | ||
|
||
["$1.0", 100], | ||
["$1.00", 100], | ||
["$1.000", 100], | ||
|
||
["$1.23", 123], | ||
["$1.234", 123.4], | ||
|
||
// formatted as numbers | ||
["0", 0], | ||
["1", 100], | ||
["10", 10_00], | ||
["100", 100_00], | ||
|
||
["1.23", 123], | ||
["1.234", 123.4], | ||
|
||
// nested quotes (double) | ||
['"$0"', 0], | ||
['"$1"', 100], | ||
['"$10"', 10_00], | ||
['"0"', 0], | ||
['"1"', 100], | ||
['"10"', 10_00], | ||
|
||
// nested quotes (single) | ||
["'$0'", 0], | ||
["'$1'", 100], | ||
["'$10'", 10_00], | ||
["'$0'", 0], | ||
["'$1'", 100], | ||
["'$10'", 10_00], | ||
]; | ||
|
||
for (const [input, centsExpected] of inputToExpectedValids) { | ||
const { cents, invalid } = priceWholeToCents(input); | ||
|
||
assertEquals(cents !== null, true); | ||
assertEquals(cents, centsExpected); | ||
assert(invalid === false); | ||
} | ||
|
||
const invalidPrices = [null, undefined, [], {}]; | ||
for (const input of invalidPrices) { | ||
const { cents, invalid } = priceWholeToCents(input as any); | ||
|
||
assertEquals(cents, null); | ||
assertEquals(invalid, true); | ||
} | ||
}); | ||
|
||
Deno.test("cents to dollars formatted", () => { | ||
const inputToExpectedValids = [ | ||
// whole | ||
[0, "$0.00"], | ||
[100, "$1.00"], | ||
[10_00, "$10.00"], | ||
[100_00, "$100.00"], | ||
|
||
[9_99, "$9.99"], | ||
|
||
// with cents | ||
[1, "$0.01"], | ||
[2, "$0.02"], | ||
[10, "$0.10"], | ||
[90, "$0.90"], | ||
]; | ||
|
||
for (const [input, expected] of inputToExpectedValids) { | ||
const result = centsToDollarsFormatted(input as Cents); | ||
|
||
assertEquals(result, expected); | ||
} | ||
}); |
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
Oops, something went wrong.