-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
578a98a
commit d56aa8e
Showing
1 changed file
with
44 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { | ||
getDecimalPlaces, | ||
hex2ascii, | ||
parseJson, | ||
} from "@/util/dataTransformUtil"; | ||
|
||
describe("hex2ascii", () => { | ||
test("正しく変換できる", () => { | ||
const actual = hex2ascii("666f6f626172"); | ||
|
||
expect(actual).toBe("foobar"); | ||
}); | ||
}); | ||
|
||
describe("getDecimalPlaces", () => { | ||
test("小数点あり", () => { | ||
const actual = getDecimalPlaces(12.345); | ||
|
||
expect(actual).toBe(3); | ||
}); | ||
|
||
test("小数点なし", () => { | ||
const actual = getDecimalPlaces(1234); | ||
|
||
expect(actual).toBe(0); | ||
}); | ||
}); | ||
|
||
describe("parseJson", () => { | ||
test("変換できる", () => { | ||
const actual = parseJson(`{"foo":1,"bar":"2"}`); | ||
|
||
expect(actual).toEqual({ | ||
foo: 1, | ||
bar: "2", | ||
}); | ||
}); | ||
|
||
test("小数点なし", () => { | ||
const actual = getDecimalPlaces(1234); | ||
|
||
expect(actual).toBe(0); | ||
}); | ||
}); |