summaryrefslogtreecommitdiff
path: root/website/app_test.js
diff options
context:
space:
mode:
authorYoshiya Hinosawa <stibium121@gmail.com>2018-09-25 00:31:14 +0900
committerRyan Dahl <ry@tinyclouds.org>2018-09-24 11:31:14 -0400
commit17a7b03d1b86b3519e611aa855f561352075a954 (patch)
tree26b64f6bfd13e2d9c6ee013b5e0c2b32a48fb78f /website/app_test.js
parentc124db4701c21ce179c0f2527cf6b8a5413910b9 (diff)
Start testing website (#813)
Diffstat (limited to 'website/app_test.js')
-rw-r--r--website/app_test.js89
1 files changed, 89 insertions, 0 deletions
diff --git a/website/app_test.js b/website/app_test.js
new file mode 100644
index 000000000..74ccb406d
--- /dev/null
+++ b/website/app_test.js
@@ -0,0 +1,89 @@
+// Copyright 2018 the Deno authors. All rights reserved. MIT license.
+
+import { test, testPerm, assertEqual } from "../js/test_util.ts";
+import {
+ createBinarySizeColumns,
+ createExecTimeColumns,
+ createSha1List,
+ formatBytes
+} from "./app.js";
+
+const regularData = [
+ {
+ created_at: "2018-01-01T01:00:00Z",
+ sha1: "abcdef",
+ binary_size: 100000000,
+ benchmark: {
+ hello: {
+ mean: 0.05
+ },
+ relative_import: {
+ mean: 0.06
+ }
+ }
+ },
+ {
+ created_at: "2018-01-02T01:00:00Z",
+ sha1: "012345",
+ binary_size: 110000000,
+ benchmark: {
+ hello: {
+ mean: 0.055
+ },
+ relative_import: {
+ mean: 0.065
+ }
+ }
+ }
+];
+
+const irregularData = [
+ {
+ created_at: "2018-01-01T01:00:00Z",
+ sha1: "123",
+ benchmark: {
+ hello: {},
+ relative_import: {}
+ }
+ },
+ {
+ created_at: "2018-02-01T01:00:00Z",
+ sha1: "456",
+ benchmark: {}
+ }
+];
+
+test(function createExecTimeColumnsRegularData() {
+ const columns = createExecTimeColumns(regularData);
+ assertEqual(columns, [
+ ["hello", 0.05, 0.055],
+ ["relative_import", 0.06, 0.065]
+ ]);
+});
+
+test(function createExecTimeColumnsIrregularData() {
+ const columns = createExecTimeColumns(irregularData);
+ assertEqual(columns, [["hello", 0, 0], ["relative_import", 0, 0]]);
+});
+
+test(function createBinarySizeColumnsRegularData() {
+ const columns = createBinarySizeColumns(regularData);
+ assertEqual(columns, [["binary_size", 100000000, 110000000]]);
+});
+
+test(function createBinarySizeColumnsIrregularData() {
+ const columns = createBinarySizeColumns(irregularData);
+ assertEqual(columns, [["binary_size", 0, 0]]);
+});
+
+test(function createSha1ListRegularData() {
+ const sha1List = createSha1List(regularData);
+ assertEqual(sha1List, ["abcdef", "012345"]);
+});
+
+test(function formatBytesPatterns() {
+ assertEqual(formatBytes(18000), "17.58 KB");
+ assertEqual(formatBytes(1800000), "1.72 MB");
+ assertEqual(formatBytes(180000000), "171.66 MB");
+ assertEqual(formatBytes(18000000000), "16.76 GB");
+});