From b8fdbc3e94a545c36d3831bc5e17f40f7933b0e1 Mon Sep 17 00:00:00 2001 From: Alexis Svinartchouk Date: Wed, 15 Jan 2020 21:13:15 +0100 Subject: [PATCH] Convert middle-ellipsis.spec.js to typescript Change-type: patch --- Makefile | 2 +- tests/gui/utils/middle-ellipsis.spec.js | 46 ------------------------- tests/gui/utils/middle-ellipsis.spec.ts | 43 +++++++++++++++++++++++ 3 files changed, 44 insertions(+), 47 deletions(-) delete mode 100644 tests/gui/utils/middle-ellipsis.spec.js create mode 100644 tests/gui/utils/middle-ellipsis.spec.ts diff --git a/Makefile b/Makefile index aa93ece5..eaa4d94c 100644 --- a/Makefile +++ b/Makefile @@ -178,7 +178,7 @@ test-spectron: ETCHER_SPECTRON_ENTRYPOINT="$(ETCHER_SPECTRON_ENTRYPOINT)" mocha $(MOCHA_OPTIONS) tests/spectron test-gui: - electron-mocha $(MOCHA_OPTIONS) --full-trace --no-sandbox --renderer tests/gui + electron-mocha $(MOCHA_OPTIONS) --full-trace --no-sandbox --renderer tests/gui/**/*.js tests/gui/**/*.ts test-sdk: electron-mocha $(MOCHA_OPTIONS) --full-trace --no-sandbox tests/shared/**/*.js tests/shared/**/*.ts diff --git a/tests/gui/utils/middle-ellipsis.spec.js b/tests/gui/utils/middle-ellipsis.spec.js deleted file mode 100644 index 50cedc04..00000000 --- a/tests/gui/utils/middle-ellipsis.spec.js +++ /dev/null @@ -1,46 +0,0 @@ - -/* - * Copyright 2018 balena.io - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict' - -const m = require('mochainon') -// eslint-disable-next-line node/no-missing-require -const { middleEllipsis } = require('../../../lib/gui/app/utils/middle-ellipsis') - -describe('Browser: MiddleEllipsis', function () { - describe('.middleEllipsis()', function () { - it('should throw error if limit < 3', function () { - m.chai.expect(() => { - middleEllipsis('No', 2) - }).to.throw('middleEllipsis: Limit should be at least 3') - }) - - describe('given the input length is greater than the limit', function () { - it('should always truncate input to an odd length', function () { - const alphabet = 'abcdefghijklmnopqrstuvwxyz' - m.chai.expect(middleEllipsis(alphabet, 3)).to.have.a.lengthOf(3) - m.chai.expect(middleEllipsis(alphabet, 4)).to.have.a.lengthOf(3) - m.chai.expect(middleEllipsis(alphabet, 5)).to.have.a.lengthOf(5) - m.chai.expect(middleEllipsis(alphabet, 6)).to.have.a.lengthOf(5) - }) - }) - - it('should return the input if it is within the bounds of limit', function () { - m.chai.expect(middleEllipsis('Hello', 10)).to.equal('Hello') - }) - }) -}) diff --git a/tests/gui/utils/middle-ellipsis.spec.ts b/tests/gui/utils/middle-ellipsis.spec.ts new file mode 100644 index 00000000..a7b3e396 --- /dev/null +++ b/tests/gui/utils/middle-ellipsis.spec.ts @@ -0,0 +1,43 @@ +/* + * Copyright 2018 balena.io + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { expect } from 'chai'; + +import { middleEllipsis } from '../../../lib/gui/app/utils/middle-ellipsis'; + +describe('Browser: MiddleEllipsis', function() { + describe('.middleEllipsis()', function() { + it('should throw error if limit < 3', function() { + expect(() => { + middleEllipsis('No', 2); + }).to.throw('middleEllipsis: Limit should be at least 3'); + }); + + describe('given the input length is greater than the limit', function() { + it('should always truncate input to an odd length', function() { + const alphabet = 'abcdefghijklmnopqrstuvwxyz'; + expect(middleEllipsis(alphabet, 3)).to.have.lengthOf(3); + expect(middleEllipsis(alphabet, 4)).to.have.lengthOf(3); + expect(middleEllipsis(alphabet, 5)).to.have.lengthOf(5); + expect(middleEllipsis(alphabet, 6)).to.have.lengthOf(5); + }); + }); + + it('should return the input if it is within the bounds of limit', function() { + expect(middleEllipsis('Hello', 10)).to.equal('Hello'); + }); + }); +});