From 3e162d2c7d847bdd6b64f952b8d4b23b5d6e57a6 Mon Sep 17 00:00:00 2001 From: Nicolae Pascu Date: Tue, 17 Oct 2017 16:19:56 +1100 Subject: [PATCH] JENKINS-46812 Test results always show duration as "A few seconds" (#1491) * use moment.format instead of humanize which would not give exact duration times * implement suggestions, re-factor TimeDuration so it doesn't need the localisation strings to be passed in every time * fix tests and a typo * release beta ver of the JDL and core-js * remove live duration as is the same as display format * release beta version of the JDL and core-js * release non-beta versions of the JDL and core-js * tick up core-js and JDL versions --- blueocean-core-js/npm-shrinkwrap.json | 785 +----------------- blueocean-core-js/package.json | 4 +- blueocean-dashboard/npm-shrinkwrap.json | 12 +- blueocean-dashboard/package.json | 4 +- .../main/js/components/ActivityDetailsRow.jsx | 4 +- .../main/js/components/RunDetailsHeader.jsx | 7 +- .../js/components/karaoke/components/Step.jsx | 4 +- .../components/testing/TestCaseResultRow.jsx | 6 +- blueocean-personalization/npm-shrinkwrap.json | 12 +- blueocean-personalization/package.json | 4 +- blueocean-pipeline-editor/npm-shrinkwrap.json | 12 +- blueocean-pipeline-editor/package.json | 4 +- blueocean-web/npm-shrinkwrap.json | 12 +- blueocean-web/package.json | 4 +- jenkins-design-language/package.json | 2 +- .../src/js/components/TimeDuration.jsx | 36 +- .../src/js/stories/resultItemStories.jsx | 15 +- .../src/js/stories/timeduration.jsx | 37 +- .../test/js/components/TimeDuration-spec.jsx | 24 +- 19 files changed, 119 insertions(+), 869 deletions(-) diff --git a/blueocean-core-js/npm-shrinkwrap.json b/blueocean-core-js/npm-shrinkwrap.json index 36854e5bafa..8432e2c7325 100644 --- a/blueocean-core-js/npm-shrinkwrap.json +++ b/blueocean-core-js/npm-shrinkwrap.json @@ -1,11 +1,11 @@ { "name": "@jenkins-cd/blueocean-core-js", - "version": "0.0.169-SNAPSHOT", + "version": "0.0.169-SNAPSHOT-nicu2", "dependencies": { "@jenkins-cd/design-language": { - "version": "0.0.157", - "from": "@jenkins-cd/design-language@0.0.157", - "resolved": "https://registry.npmjs.org/@jenkins-cd/design-language/-/design-language-0.0.157.tgz" + "version": "0.0.158", + "from": "@jenkins-cd/design-language@0.0.158", + "resolved": "https://registry.npmjs.org/@jenkins-cd/design-language/-/design-language-0.0.158.tgz" }, "@jenkins-cd/eslint-config-jenkins": { "version": "0.0.2", @@ -2553,776 +2553,6 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "dev": true }, - "fsevents": { - "version": "1.1.2", - "from": "fsevents@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.1.2.tgz", - "dev": true, - "optional": true, - "dependencies": { - "abbrev": { - "version": "1.1.0", - "from": "abbrev@1.1.0", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.0.tgz", - "dev": true, - "optional": true - }, - "ajv": { - "version": "4.11.8", - "from": "ajv@4.11.8", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", - "dev": true, - "optional": true - }, - "ansi-regex": { - "version": "2.1.1", - "from": "ansi-regex@2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "dev": true - }, - "aproba": { - "version": "1.1.1", - "from": "aproba@1.1.1", - "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.1.1.tgz", - "dev": true, - "optional": true - }, - "are-we-there-yet": { - "version": "1.1.4", - "from": "are-we-there-yet@1.1.4", - "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.4.tgz", - "dev": true, - "optional": true - }, - "asn1": { - "version": "0.2.3", - "from": "asn1@0.2.3", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", - "dev": true, - "optional": true - }, - "assert-plus": { - "version": "0.2.0", - "from": "assert-plus@0.2.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", - "dev": true, - "optional": true - }, - "asynckit": { - "version": "0.4.0", - "from": "asynckit@0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "dev": true, - "optional": true - }, - "aws-sign2": { - "version": "0.6.0", - "from": "aws-sign2@0.6.0", - "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", - "dev": true, - "optional": true - }, - "aws4": { - "version": "1.6.0", - "from": "aws4@1.6.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", - "dev": true, - "optional": true - }, - "balanced-match": { - "version": "0.4.2", - "from": "balanced-match@0.4.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.4.2.tgz", - "dev": true - }, - "bcrypt-pbkdf": { - "version": "1.0.1", - "from": "bcrypt-pbkdf@1.0.1", - "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", - "dev": true, - "optional": true - }, - "block-stream": { - "version": "0.0.9", - "from": "block-stream@0.0.9", - "resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz", - "dev": true - }, - "boom": { - "version": "2.10.1", - "from": "boom@2.10.1", - "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", - "dev": true - }, - "brace-expansion": { - "version": "1.1.7", - "from": "brace-expansion@1.1.7", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.7.tgz", - "dev": true - }, - "buffer-shims": { - "version": "1.0.0", - "from": "buffer-shims@1.0.0", - "resolved": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz", - "dev": true - }, - "caseless": { - "version": "0.12.0", - "from": "caseless@0.12.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "dev": true, - "optional": true - }, - "co": { - "version": "4.6.0", - "from": "co@4.6.0", - "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "dev": true, - "optional": true - }, - "code-point-at": { - "version": "1.1.0", - "from": "code-point-at@1.1.0", - "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "dev": true - }, - "combined-stream": { - "version": "1.0.5", - "from": "combined-stream@1.0.5", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", - "dev": true - }, - "concat-map": { - "version": "0.0.1", - "from": "concat-map@0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "dev": true - }, - "console-control-strings": { - "version": "1.1.0", - "from": "console-control-strings@1.1.0", - "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", - "dev": true - }, - "core-util-is": { - "version": "1.0.2", - "from": "core-util-is@1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "dev": true - }, - "cryptiles": { - "version": "2.0.5", - "from": "cryptiles@2.0.5", - "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", - "dev": true, - "optional": true - }, - "dashdash": { - "version": "1.14.1", - "from": "dashdash@1.14.1", - "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "dev": true, - "optional": true, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "from": "assert-plus@1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "dev": true, - "optional": true - } - } - }, - "debug": { - "version": "2.6.8", - "from": "debug@2.6.8", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", - "dev": true, - "optional": true - }, - "deep-extend": { - "version": "0.4.2", - "from": "deep-extend@0.4.2", - "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.4.2.tgz", - "dev": true, - "optional": true - }, - "delayed-stream": { - "version": "1.0.0", - "from": "delayed-stream@1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "dev": true - }, - "delegates": { - "version": "1.0.0", - "from": "delegates@1.0.0", - "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", - "dev": true, - "optional": true - }, - "ecc-jsbn": { - "version": "0.1.1", - "from": "ecc-jsbn@0.1.1", - "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", - "dev": true, - "optional": true - }, - "extend": { - "version": "3.0.1", - "from": "extend@3.0.1", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", - "dev": true, - "optional": true - }, - "extsprintf": { - "version": "1.0.2", - "from": "extsprintf@1.0.2", - "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.0.2.tgz", - "dev": true - }, - "forever-agent": { - "version": "0.6.1", - "from": "forever-agent@0.6.1", - "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "dev": true, - "optional": true - }, - "form-data": { - "version": "2.1.4", - "from": "form-data@2.1.4", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz", - "dev": true, - "optional": true - }, - "fs.realpath": { - "version": "1.0.0", - "from": "fs.realpath@1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "dev": true - }, - "fstream": { - "version": "1.0.11", - "from": "fstream@1.0.11", - "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz", - "dev": true - }, - "fstream-ignore": { - "version": "1.0.5", - "from": "fstream-ignore@1.0.5", - "resolved": "https://registry.npmjs.org/fstream-ignore/-/fstream-ignore-1.0.5.tgz", - "dev": true, - "optional": true - }, - "gauge": { - "version": "2.7.4", - "from": "gauge@2.7.4", - "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", - "dev": true, - "optional": true - }, - "getpass": { - "version": "0.1.7", - "from": "getpass@0.1.7", - "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", - "dev": true, - "optional": true, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "from": "assert-plus@1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "dev": true, - "optional": true - } - } - }, - "glob": { - "version": "7.1.2", - "from": "glob@7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "dev": true - }, - "graceful-fs": { - "version": "4.1.11", - "from": "graceful-fs@4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "dev": true - }, - "har-schema": { - "version": "1.0.5", - "from": "har-schema@1.0.5", - "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-1.0.5.tgz", - "dev": true, - "optional": true - }, - "har-validator": { - "version": "4.2.1", - "from": "har-validator@4.2.1", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-4.2.1.tgz", - "dev": true, - "optional": true - }, - "has-unicode": { - "version": "2.0.1", - "from": "has-unicode@2.0.1", - "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", - "dev": true, - "optional": true - }, - "hawk": { - "version": "3.1.3", - "from": "hawk@3.1.3", - "resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", - "dev": true, - "optional": true - }, - "hoek": { - "version": "2.16.3", - "from": "hoek@2.16.3", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", - "dev": true - }, - "http-signature": { - "version": "1.1.1", - "from": "http-signature@1.1.1", - "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", - "dev": true, - "optional": true - }, - "inflight": { - "version": "1.0.6", - "from": "inflight@1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "dev": true - }, - "inherits": { - "version": "2.0.3", - "from": "inherits@2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "dev": true - }, - "ini": { - "version": "1.3.4", - "from": "ini@1.3.4", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz", - "dev": true, - "optional": true - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "from": "is-fullwidth-code-point@1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "dev": true - }, - "is-typedarray": { - "version": "1.0.0", - "from": "is-typedarray@1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "dev": true, - "optional": true - }, - "isarray": { - "version": "1.0.0", - "from": "isarray@1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "dev": true - }, - "isstream": { - "version": "0.1.2", - "from": "isstream@0.1.2", - "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "dev": true, - "optional": true - }, - "jodid25519": { - "version": "1.0.2", - "from": "jodid25519@1.0.2", - "resolved": "https://registry.npmjs.org/jodid25519/-/jodid25519-1.0.2.tgz", - "dev": true, - "optional": true - }, - "jsbn": { - "version": "0.1.1", - "from": "jsbn@0.1.1", - "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "dev": true, - "optional": true - }, - "json-schema": { - "version": "0.2.3", - "from": "json-schema@0.2.3", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", - "dev": true, - "optional": true - }, - "json-stable-stringify": { - "version": "1.0.1", - "from": "json-stable-stringify@1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", - "dev": true, - "optional": true - }, - "json-stringify-safe": { - "version": "5.0.1", - "from": "json-stringify-safe@5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "dev": true, - "optional": true - }, - "jsonify": { - "version": "0.0.0", - "from": "jsonify@0.0.0", - "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", - "dev": true, - "optional": true - }, - "jsprim": { - "version": "1.4.0", - "from": "jsprim@1.4.0", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.0.tgz", - "dev": true, - "optional": true, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "from": "assert-plus@1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "dev": true, - "optional": true - } - } - }, - "mime-db": { - "version": "1.27.0", - "from": "mime-db@1.27.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.27.0.tgz", - "dev": true - }, - "mime-types": { - "version": "2.1.15", - "from": "mime-types@2.1.15", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.15.tgz", - "dev": true - }, - "minimatch": { - "version": "3.0.4", - "from": "minimatch@3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "dev": true - }, - "minimist": { - "version": "0.0.8", - "from": "minimist@0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "dev": true - }, - "mkdirp": { - "version": "0.5.1", - "from": "mkdirp@0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "dev": true - }, - "ms": { - "version": "2.0.0", - "from": "ms@2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "dev": true, - "optional": true - }, - "node-pre-gyp": { - "version": "0.6.36", - "from": "node-pre-gyp@^0.6.36", - "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.6.36.tgz", - "dev": true, - "optional": true - }, - "nopt": { - "version": "4.0.1", - "from": "nopt@4.0.1", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", - "dev": true, - "optional": true - }, - "npmlog": { - "version": "4.1.0", - "from": "npmlog@4.1.0", - "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.0.tgz", - "dev": true, - "optional": true - }, - "number-is-nan": { - "version": "1.0.1", - "from": "number-is-nan@1.0.1", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "dev": true - }, - "oauth-sign": { - "version": "0.8.2", - "from": "oauth-sign@0.8.2", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", - "dev": true, - "optional": true - }, - "object-assign": { - "version": "4.1.1", - "from": "object-assign@4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "dev": true, - "optional": true - }, - "once": { - "version": "1.4.0", - "from": "once@1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "dev": true - }, - "os-homedir": { - "version": "1.0.2", - "from": "os-homedir@1.0.2", - "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", - "dev": true, - "optional": true - }, - "os-tmpdir": { - "version": "1.0.2", - "from": "os-tmpdir@1.0.2", - "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "dev": true, - "optional": true - }, - "osenv": { - "version": "0.1.4", - "from": "osenv@0.1.4", - "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.4.tgz", - "dev": true, - "optional": true - }, - "path-is-absolute": { - "version": "1.0.1", - "from": "path-is-absolute@1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "dev": true - }, - "performance-now": { - "version": "0.2.0", - "from": "performance-now@0.2.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz", - "dev": true, - "optional": true - }, - "process-nextick-args": { - "version": "1.0.7", - "from": "process-nextick-args@1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "dev": true - }, - "punycode": { - "version": "1.4.1", - "from": "punycode@1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "dev": true, - "optional": true - }, - "qs": { - "version": "6.4.0", - "from": "qs@6.4.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz", - "dev": true, - "optional": true - }, - "rc": { - "version": "1.2.1", - "from": "rc@1.2.1", - "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.1.tgz", - "dev": true, - "optional": true, - "dependencies": { - "minimist": { - "version": "1.2.0", - "from": "minimist@1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "dev": true, - "optional": true - } - } - }, - "readable-stream": { - "version": "2.2.9", - "from": "readable-stream@2.2.9", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.9.tgz", - "dev": true - }, - "request": { - "version": "2.81.0", - "from": "request@2.81.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.81.0.tgz", - "dev": true, - "optional": true - }, - "rimraf": { - "version": "2.6.1", - "from": "rimraf@2.6.1", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.1.tgz", - "dev": true - }, - "safe-buffer": { - "version": "5.0.1", - "from": "safe-buffer@5.0.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.0.1.tgz", - "dev": true - }, - "semver": { - "version": "5.3.0", - "from": "semver@5.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", - "dev": true, - "optional": true - }, - "set-blocking": { - "version": "2.0.0", - "from": "set-blocking@2.0.0", - "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "dev": true, - "optional": true - }, - "signal-exit": { - "version": "3.0.2", - "from": "signal-exit@3.0.2", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "dev": true, - "optional": true - }, - "sntp": { - "version": "1.0.9", - "from": "sntp@1.0.9", - "resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", - "dev": true, - "optional": true - }, - "sshpk": { - "version": "1.13.0", - "from": "sshpk@1.13.0", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.0.tgz", - "dev": true, - "optional": true, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "from": "assert-plus@1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "dev": true, - "optional": true - } - } - }, - "string_decoder": { - "version": "1.0.1", - "from": "string_decoder@1.0.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.1.tgz", - "dev": true - }, - "string-width": { - "version": "1.0.2", - "from": "string-width@1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "dev": true - }, - "stringstream": { - "version": "0.0.5", - "from": "stringstream@0.0.5", - "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", - "dev": true, - "optional": true - }, - "strip-ansi": { - "version": "3.0.1", - "from": "strip-ansi@3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "dev": true - }, - "strip-json-comments": { - "version": "2.0.1", - "from": "strip-json-comments@2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "dev": true, - "optional": true - }, - "tar": { - "version": "2.2.1", - "from": "tar@2.2.1", - "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz", - "dev": true - }, - "tar-pack": { - "version": "3.4.0", - "from": "tar-pack@3.4.0", - "resolved": "https://registry.npmjs.org/tar-pack/-/tar-pack-3.4.0.tgz", - "dev": true, - "optional": true - }, - "tough-cookie": { - "version": "2.3.2", - "from": "tough-cookie@2.3.2", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.2.tgz", - "dev": true, - "optional": true - }, - "tunnel-agent": { - "version": "0.6.0", - "from": "tunnel-agent@0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "dev": true, - "optional": true - }, - "tweetnacl": { - "version": "0.14.5", - "from": "tweetnacl@0.14.5", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "dev": true, - "optional": true - }, - "uid-number": { - "version": "0.0.6", - "from": "uid-number@0.0.6", - "resolved": "https://registry.npmjs.org/uid-number/-/uid-number-0.0.6.tgz", - "dev": true, - "optional": true - }, - "util-deprecate": { - "version": "1.0.2", - "from": "util-deprecate@1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "dev": true - }, - "uuid": { - "version": "3.0.1", - "from": "uuid@3.0.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.0.1.tgz", - "dev": true, - "optional": true - }, - "verror": { - "version": "1.3.6", - "from": "verror@1.3.6", - "resolved": "https://registry.npmjs.org/verror/-/verror-1.3.6.tgz", - "dev": true, - "optional": true - }, - "wide-align": { - "version": "1.1.2", - "from": "wide-align@1.1.2", - "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.2.tgz", - "dev": true, - "optional": true - }, - "wrappy": { - "version": "1.0.2", - "from": "wrappy@1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "dev": true - } - } - }, "function-bind": { "version": "1.1.0", "from": "function-bind@>=1.0.2 <2.0.0", @@ -5462,13 +4692,6 @@ "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.5.tgz", "dev": true }, - "nan": { - "version": "2.7.0", - "from": "nan@>=2.3.0 <3.0.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.7.0.tgz", - "dev": true, - "optional": true - }, "natives": { "version": "1.1.0", "from": "natives@>=1.1.0 <2.0.0", diff --git a/blueocean-core-js/package.json b/blueocean-core-js/package.json index e909cbdee0f..1a648e9064b 100644 --- a/blueocean-core-js/package.json +++ b/blueocean-core-js/package.json @@ -1,6 +1,6 @@ { "name": "@jenkins-cd/blueocean-core-js", - "version": "0.0.169-SNAPSHOT", + "version": "0.0.170-SNAPSHOT", "description": "Shared JavaScript libraries for use with Jenkins Blue Ocean", "main": "dist/js/index.js", "scripts": { @@ -32,7 +32,7 @@ "url": "https://github.com/jenkinsci/blueocean-plugin.git" }, "dependencies": { - "@jenkins-cd/design-language": "0.0.157", + "@jenkins-cd/design-language": "0.0.158", "@jenkins-cd/js-extensions": "0.0.39", "@jenkins-cd/js-modules": "0.0.10", "@jenkins-cd/logging": "0.0.6", diff --git a/blueocean-dashboard/npm-shrinkwrap.json b/blueocean-dashboard/npm-shrinkwrap.json index 84bfe326f6e..15ca19689d3 100644 --- a/blueocean-dashboard/npm-shrinkwrap.json +++ b/blueocean-dashboard/npm-shrinkwrap.json @@ -3,14 +3,14 @@ "version": "0.0.1", "dependencies": { "@jenkins-cd/blueocean-core-js": { - "version": "0.0.168", - "from": "@jenkins-cd/blueocean-core-js@0.0.168", - "resolved": "https://registry.npmjs.org/@jenkins-cd/blueocean-core-js/-/blueocean-core-js-0.0.168.tgz" + "version": "0.0.169", + "from": "@jenkins-cd/blueocean-core-js@0.0.169", + "resolved": "https://registry.npmjs.org/@jenkins-cd/blueocean-core-js/-/blueocean-core-js-0.0.169.tgz" }, "@jenkins-cd/design-language": { - "version": "0.0.157", - "from": "@jenkins-cd/design-language@0.0.157", - "resolved": "https://registry.npmjs.org/@jenkins-cd/design-language/-/design-language-0.0.157.tgz" + "version": "0.0.158", + "from": "@jenkins-cd/design-language@0.0.158", + "resolved": "https://registry.npmjs.org/@jenkins-cd/design-language/-/design-language-0.0.158.tgz" }, "@jenkins-cd/eslint-config-jenkins": { "version": "0.0.2", diff --git a/blueocean-dashboard/package.json b/blueocean-dashboard/package.json index c00c095314b..56e8ceb5355 100644 --- a/blueocean-dashboard/package.json +++ b/blueocean-dashboard/package.json @@ -43,8 +43,8 @@ "skin-deep": "0.16.0" }, "dependencies": { - "@jenkins-cd/blueocean-core-js": "0.0.168", - "@jenkins-cd/design-language": "0.0.157", + "@jenkins-cd/blueocean-core-js": "0.0.169", + "@jenkins-cd/design-language": "0.0.158", "@jenkins-cd/js-extensions": "0.0.39", "@jenkins-cd/js-modules": "0.0.10", "@jenkins-cd/preferences": "0.0.4", diff --git a/blueocean-dashboard/src/main/js/components/ActivityDetailsRow.jsx b/blueocean-dashboard/src/main/js/components/ActivityDetailsRow.jsx index 70d9dfd8d9b..88c59a06df5 100644 --- a/blueocean-dashboard/src/main/js/components/ActivityDetailsRow.jsx +++ b/blueocean-dashboard/src/main/js/components/ActivityDetailsRow.jsx @@ -95,9 +95,7 @@ class ActivityDetailsRow extends Component { updatePeriod={1000} liveUpdate={isRunning} locale={locale} - displayFormat={t('common.date.duration.display.format', { defaultValue: 'M[ month] d[ days] h[ hours] m[ minutes] s[ seconds]' })} - liveFormat={t('common.date.duration.format', { defaultValue: 'm[ minutes] s[ seconds]' })} - hintFormat={t('common.date.duration.hint.format', { defaultValue: 'M [month], d [days], h[h], m[m], s[s]' })} + t={t} /> diff --git a/blueocean-dashboard/src/main/js/components/RunDetailsHeader.jsx b/blueocean-dashboard/src/main/js/components/RunDetailsHeader.jsx index c93c36c6d14..300bf33aaca 100644 --- a/blueocean-dashboard/src/main/js/components/RunDetailsHeader.jsx +++ b/blueocean-dashboard/src/main/js/components/RunDetailsHeader.jsx @@ -71,9 +71,6 @@ class RunDetailsHeader extends Component { t('rundetail.header.pullRequest', { defaultValue: 'Pull Request' }) : t('rundetail.header.branch', { defaultValue: 'Branch' }); const commitLabel = t('rundetail.header.commit', { defaultValue: 'Commit' }); - const durationDisplayFormat = t('common.date.duration.display.format', { defaultValue: 'M[ month] d[ days] h[ hours] m[ minutes] s[ seconds]' }); - const durationFormat = t('common.date.duration.format', { defaultValue: 'm[ minutes] s[ seconds]' }); - const durationHintFormat = t('common.date.duration.hint.format', { defaultValue: 'M [month], d [days], h[h], m[m], s[s]' }); const dateFormatShort = t('common.date.readable.short', { defaultValue: 'MMM DD h:mma Z' }); const dateFormatLong = t('common.date.readable.long', { defaultValue: 'MMM DD YYYY h:mma Z' }); @@ -140,9 +137,7 @@ class RunDetailsHeader extends Component { liveUpdate={ isRunning() } updatePeriod={ 1000 } locale={ locale } - displayFormat={ durationDisplayFormat } - liveFormat={ durationFormat } - hintFormat={ durationHintFormat } + t={ t } /> ); diff --git a/blueocean-dashboard/src/main/js/components/karaoke/components/Step.jsx b/blueocean-dashboard/src/main/js/components/karaoke/components/Step.jsx index 9018e0ec62c..9ad4c532cab 100644 --- a/blueocean-dashboard/src/main/js/components/karaoke/components/Step.jsx +++ b/blueocean-dashboard/src/main/js/components/karaoke/components/Step.jsx @@ -146,9 +146,7 @@ export class Step extends Component { liveUpdate={step.isRunning} updatePeriod={1000} locale={locale} - displayFormat={t('common.date.duration.display.format', { defaultValue: 'M[ month] d[ days] h[ hours] m[ minutes] s[ seconds]' })} - liveFormat={t('common.date.duration.format', { defaultValue: 'm[ minutes] s[ seconds]' })} - hintFormat={t('common.date.duration.hint.format', { defaultValue: 'M [month], d [days], h[h], m[m], s[s]' })} + t={t} />); return (
diff --git a/blueocean-dashboard/src/main/js/components/testing/TestCaseResultRow.jsx b/blueocean-dashboard/src/main/js/components/testing/TestCaseResultRow.jsx index 6a5a5949b81..09c67f309a9 100644 --- a/blueocean-dashboard/src/main/js/components/testing/TestCaseResultRow.jsx +++ b/blueocean-dashboard/src/main/js/components/testing/TestCaseResultRow.jsx @@ -1,7 +1,6 @@ import React, { Component, PropTypes } from 'react'; import { observer } from 'mobx-react'; -import { ResultItem, StatusIndicator } from '@jenkins-cd/design-language'; -import moment from 'moment'; +import { ResultItem, StatusIndicator, TimeDuration } from '@jenkins-cd/design-language'; import TestDetails from './TestDetails'; @observer @@ -23,8 +22,7 @@ export default class TestCaseResultRow extends Component { render() { const { testCase: t, translation, locale = 'en' } = this.props; - moment.locale(locale); - const duration = moment.duration(Number(t.duration), 'milliseconds').humanize(); + const duration = TimeDuration.format(t.duration, translation, locale); const showTestCase = (t.errorStackTrace || t.errorDetails || this.stdout || this.stderr); let statusIndicator = null; switch (t.status) { diff --git a/blueocean-personalization/npm-shrinkwrap.json b/blueocean-personalization/npm-shrinkwrap.json index 18dfe0d6627..0b9138e5eff 100644 --- a/blueocean-personalization/npm-shrinkwrap.json +++ b/blueocean-personalization/npm-shrinkwrap.json @@ -3,14 +3,14 @@ "version": "0.0.2-unpublished", "dependencies": { "@jenkins-cd/blueocean-core-js": { - "version": "0.0.168", - "from": "@jenkins-cd/blueocean-core-js@0.0.168", - "resolved": "https://registry.npmjs.org/@jenkins-cd/blueocean-core-js/-/blueocean-core-js-0.0.168.tgz" + "version": "0.0.169", + "from": "@jenkins-cd/blueocean-core-js@0.0.169", + "resolved": "https://registry.npmjs.org/@jenkins-cd/blueocean-core-js/-/blueocean-core-js-0.0.169.tgz" }, "@jenkins-cd/design-language": { - "version": "0.0.157", - "from": "@jenkins-cd/design-language@0.0.157", - "resolved": "https://registry.npmjs.org/@jenkins-cd/design-language/-/design-language-0.0.157.tgz" + "version": "0.0.158", + "from": "@jenkins-cd/design-language@0.0.158", + "resolved": "https://registry.npmjs.org/@jenkins-cd/design-language/-/design-language-0.0.158.tgz" }, "@jenkins-cd/eslint-config-jenkins": { "version": "0.0.2", diff --git a/blueocean-personalization/package.json b/blueocean-personalization/package.json index 6c44c34c9b6..152d3864a5a 100644 --- a/blueocean-personalization/package.json +++ b/blueocean-personalization/package.json @@ -39,8 +39,8 @@ "react-addons-test-utils": "15.4.2" }, "dependencies": { - "@jenkins-cd/blueocean-core-js": "0.0.168", - "@jenkins-cd/design-language": "0.0.157", + "@jenkins-cd/blueocean-core-js": "0.0.169", + "@jenkins-cd/design-language": "0.0.158", "@jenkins-cd/js-extensions": "0.0.39", "@jenkins-cd/js-modules": "0.0.10", "immutable": "3.8.1", diff --git a/blueocean-pipeline-editor/npm-shrinkwrap.json b/blueocean-pipeline-editor/npm-shrinkwrap.json index 3a9f9287025..e4d50d5f49f 100644 --- a/blueocean-pipeline-editor/npm-shrinkwrap.json +++ b/blueocean-pipeline-editor/npm-shrinkwrap.json @@ -3,14 +3,14 @@ "version": "0.0.1", "dependencies": { "@jenkins-cd/blueocean-core-js": { - "version": "0.0.168", - "from": "@jenkins-cd/blueocean-core-js@0.0.168", - "resolved": "https://registry.npmjs.org/@jenkins-cd/blueocean-core-js/-/blueocean-core-js-0.0.168.tgz" + "version": "0.0.169", + "from": "@jenkins-cd/blueocean-core-js@0.0.169", + "resolved": "https://registry.npmjs.org/@jenkins-cd/blueocean-core-js/-/blueocean-core-js-0.0.169.tgz" }, "@jenkins-cd/design-language": { - "version": "0.0.157", - "from": "@jenkins-cd/design-language@0.0.157", - "resolved": "https://registry.npmjs.org/@jenkins-cd/design-language/-/design-language-0.0.157.tgz" + "version": "0.0.158", + "from": "@jenkins-cd/design-language@0.0.158", + "resolved": "https://registry.npmjs.org/@jenkins-cd/design-language/-/design-language-0.0.158.tgz" }, "@jenkins-cd/eslint-config-jenkins": { "version": "0.0.2", diff --git a/blueocean-pipeline-editor/package.json b/blueocean-pipeline-editor/package.json index c3a07180d75..8657dca0324 100644 --- a/blueocean-pipeline-editor/package.json +++ b/blueocean-pipeline-editor/package.json @@ -41,8 +41,8 @@ "react-addons-test-utils": "15.4.2" }, "dependencies": { - "@jenkins-cd/blueocean-core-js": "0.0.168", - "@jenkins-cd/design-language": "0.0.157", + "@jenkins-cd/blueocean-core-js": "0.0.169", + "@jenkins-cd/design-language": "0.0.158", "@jenkins-cd/js-extensions": "0.0.39", "@jenkins-cd/js-modules": "0.0.10", "lodash.debounce": "4.0.8", diff --git a/blueocean-web/npm-shrinkwrap.json b/blueocean-web/npm-shrinkwrap.json index bc328942ae1..2049e42d68e 100644 --- a/blueocean-web/npm-shrinkwrap.json +++ b/blueocean-web/npm-shrinkwrap.json @@ -3,14 +3,14 @@ "version": "0.0.1", "dependencies": { "@jenkins-cd/blueocean-core-js": { - "version": "0.0.168", - "from": "@jenkins-cd/blueocean-core-js@0.0.168", - "resolved": "https://registry.npmjs.org/@jenkins-cd/blueocean-core-js/-/blueocean-core-js-0.0.168.tgz" + "version": "0.0.169", + "from": "@jenkins-cd/blueocean-core-js@0.0.169", + "resolved": "https://registry.npmjs.org/@jenkins-cd/blueocean-core-js/-/blueocean-core-js-0.0.169.tgz" }, "@jenkins-cd/design-language": { - "version": "0.0.157", - "from": "@jenkins-cd/design-language@0.0.157", - "resolved": "https://registry.npmjs.org/@jenkins-cd/design-language/-/design-language-0.0.157.tgz" + "version": "0.0.158", + "from": "@jenkins-cd/design-language@0.0.158", + "resolved": "https://registry.npmjs.org/@jenkins-cd/design-language/-/design-language-0.0.158.tgz" }, "@jenkins-cd/eslint-config-jenkins": { "version": "0.0.2", diff --git a/blueocean-web/package.json b/blueocean-web/package.json index b6e6f78dbfe..b535cd17238 100644 --- a/blueocean-web/package.json +++ b/blueocean-web/package.json @@ -30,8 +30,8 @@ "zombie": "4.2.1" }, "dependencies": { - "@jenkins-cd/blueocean-core-js": "0.0.168", - "@jenkins-cd/design-language": "0.0.157", + "@jenkins-cd/blueocean-core-js": "0.0.169", + "@jenkins-cd/design-language": "0.0.158", "@jenkins-cd/js-extensions": "0.0.39", "@jenkins-cd/js-modules": "0.0.10", "history": "2.0.2", diff --git a/jenkins-design-language/package.json b/jenkins-design-language/package.json index 23f23d56ddb..2954bf76b21 100644 --- a/jenkins-design-language/package.json +++ b/jenkins-design-language/package.json @@ -1,7 +1,7 @@ { "name": "@jenkins-cd/design-language", "jdlName": "jenkins-design-language", - "version": "0.0.158-SNAPSHOT", + "version": "0.0.159-SNAPSHOT", "description": "Styles, assets, and React classes for Jenkins Design Language", "main": "dist/js/components/index.js", "scripts": { diff --git a/jenkins-design-language/src/js/components/TimeDuration.jsx b/jenkins-design-language/src/js/components/TimeDuration.jsx index 9b76336fb36..d2d8b2828c3 100644 --- a/jenkins-design-language/src/js/components/TimeDuration.jsx +++ b/jenkins-design-language/src/js/components/TimeDuration.jsx @@ -44,8 +44,8 @@ export class TimeDuration extends Component { super(props); // track how much time has elapsed since live updating tracking started this.state = { elapsed: 0 }; - const {updatePeriod = 30000} = this.props; - this.timerPeriodMillis = typeof updatePeriod !== 'number' || isNaN(updatePeriod) ? 30000 : updatePeriod; + const {updatePeriod = 5000} = this.props; + this.timerPeriodMillis = typeof updatePeriod !== 'number' || isNaN(updatePeriod) ? 5000 : updatePeriod; this.clearIntervalId = 0; } @@ -85,6 +85,21 @@ export class TimeDuration extends Component { }); } + static format(value, t, locale) { + const displayFormat = t('common.date.duration.display.format', { defaultValue: 'd[d] h[h] m[m] s[s]' }); + + moment.locale(locale); + + if (!isNaN(value)) { + if(value < 1000) { + return '<1s'; + } + return moment.duration(value).format(displayFormat); + } else { + return '-'; + } + } + componentWillUnmount() { if (this.clearIntervalId) { clearInterval(this.clearIntervalId); @@ -101,17 +116,16 @@ export class TimeDuration extends Component { <1s ); } + const { locale = 'en', - displayFormat = 'd[d] h[h] m[m] s[s]', - liveFormat = 'd[d] h[h] m[m] s[s]', - hintFormat = 'M [months], d [days], h [hours], m [minutes], s [seconds]', + t, } = this.props; - moment.locale(locale); - // in case we are in live update we are interested in seconds - const duration = this.props.liveUpdate ? - moment.duration(millis).format(liveFormat) : moment.duration(millis).format(displayFormat); + const duration = TimeDuration.format(millis, t, locale); + const hintFormat = t('common.date.duration.hint.format', { defaultValue: 'M [month], d [days], h[h], m[m], s[s]' }); + + moment.locale(locale); const hint = this.props.hint ? this.props.hint : moment.duration(millis).format(hintFormat); @@ -130,7 +144,5 @@ TimeDuration.propTypes = { hint: PropTypes.string, liveUpdate: PropTypes.bool, locale: PropTypes.string, - displayFormat: PropTypes.string, - liveFormat: PropTypes.string, - hintFormat: PropTypes.string, + t: PropTypes.func, }; diff --git a/jenkins-design-language/src/js/stories/resultItemStories.jsx b/jenkins-design-language/src/js/stories/resultItemStories.jsx index 24d76514f3a..1095b46694c 100644 --- a/jenkins-design-language/src/js/stories/resultItemStories.jsx +++ b/jenkins-design-language/src/js/stories/resultItemStories.jsx @@ -16,6 +16,14 @@ const wrapperStyle = { let __ctr = 1; +const strings = { + "common.date.duration.display.format": "M [mos], d [Tage], h[Std.], m[m], s[s]", + "common.date.duration.format": "m[ Minuten] s[ Sekunden]", + "common.date.duration.hint.format": "M [Monate], d [Tage], h[Std.], m[m], s[s]", +}; + +const t = (key) => strings[key] || key; + function moLipsum() { const l = lipsum.length; @@ -43,9 +51,7 @@ function standardDe() { ); } @@ -57,8 +63,7 @@ function liveUpdateDe() { updatePeriod={3000} millis={50000} locale="de" - hintFormat="M [mos], d [Tage], h[Std.], m[m], s[s]" - liveFormat="m[ Minuten] s[ Sekunden]" + t={t} /> ); } diff --git a/jenkins-design-language/src/js/stories/timeduration.jsx b/jenkins-design-language/src/js/stories/timeduration.jsx index 8e2bded91ba..2f996b3b877 100644 --- a/jenkins-design-language/src/js/stories/timeduration.jsx +++ b/jenkins-design-language/src/js/stories/timeduration.jsx @@ -2,6 +2,22 @@ import React from 'react'; import { storiesOf } from '@kadira/storybook'; import { TimeDuration } from '../components/TimeDuration'; +const stringsEn = { + "common.date.duration.display.format": "M[ month] d[ days] h[ hours] m[ minutes] s[ seconds]", + "common.date.duration.format": "m[ minutes] s[ seconds]", + "common.date.duration.hint.format": "M [month], d [days], h[h], m[m], s[s]", +}; + +const stringsDe = { + "common.date.duration.display.format": "M [mos], d [Tage], h[Std.], m[m], s[s]", + "common.date.duration.format": "m[ Minuten] s[ Sekunden]", + "common.date.duration.hint.format": "M [Monate], d [Tage], h[Std.], m[m], s[s]", +}; + +const translationsEn = (key) => stringsEn[key] || key; +const translationsDe = (key) => stringsDe[key] || key; + + storiesOf('TimeDuration', module) .add('<1s', lessThan1s) .add('short duration', standard) @@ -14,13 +30,13 @@ storiesOf('TimeDuration', module) function lessThan1s() { return ( - + ); } function standard() { return ( - + ); } @@ -29,15 +45,14 @@ function standardDe() { ); } function liveUpdate() { return ( - + ); } @@ -45,18 +60,17 @@ function liveUpdateDe() { return ( ); } function complexHint() { return ( - + ); } @@ -66,14 +80,13 @@ function complexHintDe() { updatePeriod={3000} millis={3.5*1000*60*60*24*7*4*6+1001*60*60*4.75} locale="de" - hintFormat="M [Monate], d [Tage], h[h], m[m], s[s]" - liveFormat="m[ Minuten] s[ Sekunden]" + t={translationsDe} /> ); } function customHint() { return ( - + ); } diff --git a/jenkins-design-language/test/js/components/TimeDuration-spec.jsx b/jenkins-design-language/test/js/components/TimeDuration-spec.jsx index c75a6fca853..7965c70ff94 100644 --- a/jenkins-design-language/test/js/components/TimeDuration-spec.jsx +++ b/jenkins-design-language/test/js/components/TimeDuration-spec.jsx @@ -6,6 +6,14 @@ import { TimeDuration } from '../../../src/js/components'; describe("TimeDuration", () => { + const strings = { + "common.date.duration.display.format": "d[d] h[h] m[m] s[s]", + "common.date.duration.format": "d[d] h[h] m[m] s[s]", + "common.date.duration.hint.format": "M [month], d [days], h[ hours], m[ minutes], s[ seconds]", + }; + + const t = (key) => strings[key] || key; + it("renders dash with no data", () => { const wrapper = shallow(); @@ -23,13 +31,13 @@ describe("TimeDuration", () => { }); it("renders '2s' with 2000ms", () => { - const wrapper = shallow(); + const wrapper = shallow(); assert.isTrue(wrapper.is('span')); assert.equal(wrapper.text(), '2s'); }); it("renders '-' with 1 as string", () => { - const wrapper = shallow(); + const wrapper = shallow(); assert.isTrue(wrapper.equals( - @@ -37,39 +45,39 @@ describe("TimeDuration", () => { }); it("renders '3d 15m 0s' with 3.25h", () => { - const wrapper = shallow(); + const wrapper = shallow(); assert.isTrue(wrapper.is('span')); assert.equal(wrapper.text(), '3h 15m 0s'); }); it("renders a tooltip of '5 minutes, 5 seconds' when supplied value", () => { - const wrapper = shallow(); + const wrapper = shallow(); assert.equal(wrapper.props().title, '5 minutes, 5 seconds'); }); it("renders a tooltip of '2 hours, 0 minutes, 5 seconds' when supplied value", () => { - const wrapper = shallow(); + const wrapper = shallow(); assert.equal(wrapper.props().title, '2 hours, 0 minutes, 5 seconds'); }); it("renders a custom tooltip", () => { - const wrapper = shallow(); + const wrapper = shallow(); assert.equal(wrapper.props().title, 'Not very long at all.'); }); it("renders '<1s' with durations less than 1s", () => { - const wrapper = shallow(); + const wrapper = shallow(); assert.isTrue(wrapper.is('span')); assert.equal(wrapper.text(), '<1s'); }); it("renders corret time with long duration", () => { - const wrapper = shallow(); + const wrapper = shallow(); assert.isTrue(wrapper.is('span')); assert.equal(wrapper.text(), '177d 23h 59m 59s');