snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
This commit is contained in:
39
apps/meteor/tests/unit/lib/getMessageMaxParseLength.spec.ts
Normal file
39
apps/meteor/tests/unit/lib/getMessageMaxParseLength.spec.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { expect } from 'chai';
|
||||
|
||||
import { getMessageMaxParseLength } from '../../../lib/getMessageMaxParseLength';
|
||||
|
||||
describe('getMessageMaxParseLength', () => {
|
||||
afterEach(() => {
|
||||
delete process.env.MESSAGE_MAX_PARSE_LENGTH;
|
||||
});
|
||||
|
||||
it('should return 0 (default) when env var is not set', () => {
|
||||
delete process.env.MESSAGE_MAX_PARSE_LENGTH;
|
||||
expect(getMessageMaxParseLength()).to.equal(0);
|
||||
});
|
||||
|
||||
it('should return 0 (default) when env var is empty string', () => {
|
||||
process.env.MESSAGE_MAX_PARSE_LENGTH = '';
|
||||
expect(getMessageMaxParseLength()).to.equal(0);
|
||||
});
|
||||
|
||||
it('should return 0 (default) when env var is not a number', () => {
|
||||
process.env.MESSAGE_MAX_PARSE_LENGTH = 'abc';
|
||||
expect(getMessageMaxParseLength()).to.equal(0);
|
||||
});
|
||||
|
||||
it('should return the parsed number when env var is a valid integer', () => {
|
||||
process.env.MESSAGE_MAX_PARSE_LENGTH = '5000';
|
||||
expect(getMessageMaxParseLength()).to.equal(5000);
|
||||
});
|
||||
|
||||
it('should return 0 when env var is "0"', () => {
|
||||
process.env.MESSAGE_MAX_PARSE_LENGTH = '0';
|
||||
expect(getMessageMaxParseLength()).to.equal(0);
|
||||
});
|
||||
|
||||
it('should return 0 (default) when env var is Infinity', () => {
|
||||
process.env.MESSAGE_MAX_PARSE_LENGTH = 'Infinity';
|
||||
expect(getMessageMaxParseLength()).to.equal(0);
|
||||
});
|
||||
});
|
||||
15
apps/meteor/tests/unit/lib/mimeTypes.tests.ts
Normal file
15
apps/meteor/tests/unit/lib/mimeTypes.tests.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { expect } from 'chai';
|
||||
|
||||
import { getExtension } from '../../../app/utils/lib/mimeTypes';
|
||||
|
||||
describe('mimeTypes', () => {
|
||||
describe('#getExtension()', () => {
|
||||
it('should return an empty string if the given param is an invalid mime type', () => {
|
||||
expect(getExtension('invalid-mime')).to.be.equal('');
|
||||
});
|
||||
|
||||
it('should return the correct extension when the mime type is valid', () => {
|
||||
expect(getExtension('image/png')).to.be.equal('png');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,43 @@
|
||||
import { expect } from 'chai';
|
||||
|
||||
import { getMostImportantRole } from '../../../../lib/roles/getMostImportantRole';
|
||||
|
||||
describe('getMostImportantRole', () => {
|
||||
it('should return the same role if only one exists', () => {
|
||||
expect(getMostImportantRole(['admin'])).to.be.eq('admin');
|
||||
expect(getMostImportantRole(['livechat-manager'])).to.be.eq('livechat-manager');
|
||||
expect(getMostImportantRole(['livechat-monitor'])).to.be.eq('livechat-monitor');
|
||||
expect(getMostImportantRole(['livechat-agent'])).to.be.eq('livechat-agent');
|
||||
expect(getMostImportantRole(['user'])).to.be.eq('user');
|
||||
expect(getMostImportantRole(['guest'])).to.be.eq('guest');
|
||||
expect(getMostImportantRole(['anonymous'])).to.be.eq('anonymous');
|
||||
expect(getMostImportantRole(['app'])).to.be.eq('app');
|
||||
expect(getMostImportantRole(['bot'])).to.be.eq('bot');
|
||||
});
|
||||
|
||||
it('should return custom roles as `custom-role`', () => {
|
||||
expect(getMostImportantRole(['custom1'])).to.be.eq('custom-role');
|
||||
});
|
||||
|
||||
it('should return auditor, app and bot as `user`', () => {
|
||||
expect(getMostImportantRole(['auditor'])).to.be.eq('user');
|
||||
expect(getMostImportantRole(['auditor-log'])).to.be.eq('user');
|
||||
});
|
||||
|
||||
it('should return `no-role` if no one exists', () => {
|
||||
expect(getMostImportantRole([])).to.be.eq('no-role');
|
||||
expect(getMostImportantRole()).to.be.eq('no-role');
|
||||
});
|
||||
|
||||
it('should return correct role', () => {
|
||||
expect(getMostImportantRole(['user', 'admin'])).to.be.eq('admin');
|
||||
expect(getMostImportantRole(['user', 'anonymous'])).to.be.eq('user');
|
||||
expect(getMostImportantRole(['user', 'guest'])).to.be.eq('user');
|
||||
expect(getMostImportantRole(['user', 'guest', 'livechat-monitor'])).to.be.eq('livechat-monitor');
|
||||
expect(getMostImportantRole(['user', 'custom1'])).to.be.eq('custom-role');
|
||||
expect(getMostImportantRole(['custom2', 'user', 'custom1'])).to.be.eq('custom-role');
|
||||
expect(getMostImportantRole(['custom2', 'admin', 'custom1'])).to.be.eq('admin');
|
||||
expect(getMostImportantRole(['custom2', 'app'])).to.be.eq('custom-role');
|
||||
expect(getMostImportantRole(['anonymous', 'app'])).to.be.eq('app');
|
||||
});
|
||||
});
|
||||
19
apps/meteor/tests/unit/lib/utils/arrayUtils.tests.ts
Normal file
19
apps/meteor/tests/unit/lib/utils/arrayUtils.tests.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { expect } from 'chai';
|
||||
|
||||
import { ensureArray } from '../../../../lib/utils/arrayUtils';
|
||||
|
||||
describe('Array utils', () => {
|
||||
it('should return an array with one item', () => {
|
||||
const value = 'value';
|
||||
const result = ensureArray(value);
|
||||
|
||||
expect(result).to.be.an('Array').with.lengthOf(1).and.eql([value]);
|
||||
});
|
||||
|
||||
it('should return a new array with the same items', () => {
|
||||
const value = ['value1', 'value2'];
|
||||
const result = ensureArray(value);
|
||||
|
||||
expect(result).to.be.an('Array').with.lengthOf(2).and.eql(value).and.not.equal(value);
|
||||
});
|
||||
});
|
||||
22
apps/meteor/tests/unit/lib/utils/isRelativeURL.spec.ts
Normal file
22
apps/meteor/tests/unit/lib/utils/isRelativeURL.spec.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { expect } from 'chai';
|
||||
|
||||
import { isRelativeURL } from '../../../../lib/utils/isRelativeURL';
|
||||
|
||||
describe('isRelativeURL', () => {
|
||||
const testCases = [
|
||||
['/', false],
|
||||
['test', false], // TODO: should be true?
|
||||
['test/test', true],
|
||||
['.', false], // TODO: should be true?
|
||||
['./test', true],
|
||||
['https://rocket.chat', false],
|
||||
['data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==', true], // TODO: should be false?
|
||||
] as const;
|
||||
|
||||
testCases.forEach(([parameter, expectedResult]) => {
|
||||
it(`should return ${JSON.stringify(expectedResult)} for ${JSON.stringify(parameter)}`, () => {
|
||||
const result = isRelativeURL(parameter);
|
||||
expect(result).to.be.equal(expectedResult);
|
||||
});
|
||||
});
|
||||
});
|
||||
21
apps/meteor/tests/unit/lib/utils/normalizeUsername.spec.ts
Normal file
21
apps/meteor/tests/unit/lib/utils/normalizeUsername.spec.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { expect } from 'chai';
|
||||
|
||||
import { normalizeUsername } from '../../../../lib/utils/normalizeUsername';
|
||||
|
||||
describe('normalizeUsername', () => {
|
||||
const testCases = [
|
||||
['john.doe', 'john.doe'],
|
||||
['@john.doe:matrix.org', 'john.doe:matrix.org'],
|
||||
['@john', 'john'],
|
||||
['@@john', '@john'],
|
||||
['john@doe', 'john@doe'],
|
||||
['', ''],
|
||||
] as const;
|
||||
|
||||
testCases.forEach(([parameter, expectedResult]) => {
|
||||
it(`should return ${JSON.stringify(expectedResult)} for ${JSON.stringify(parameter)}`, () => {
|
||||
const result = normalizeUsername(parameter);
|
||||
expect(result).to.be.equal(expectedResult);
|
||||
});
|
||||
});
|
||||
});
|
||||
48
apps/meteor/tests/unit/lib/utils/parseCSV.tests.ts
Normal file
48
apps/meteor/tests/unit/lib/utils/parseCSV.tests.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { expect } from 'chai';
|
||||
|
||||
import { parseCSV } from '../../../../lib/utils/parseCSV';
|
||||
|
||||
describe('Parse CSV', () => {
|
||||
it('should return an empty array for an empty string', () => {
|
||||
const result = parseCSV('');
|
||||
|
||||
expect(result).to.be.an('Array').with.lengthOf(0);
|
||||
});
|
||||
|
||||
it('should return an array with one item', () => {
|
||||
const value = 'value';
|
||||
const result = parseCSV(value);
|
||||
|
||||
expect(result).to.be.an('Array').with.lengthOf(1).and.eql([value]);
|
||||
});
|
||||
|
||||
it('should trim surrounding spaces', () => {
|
||||
const value1 = 'value1';
|
||||
const value2 = 'value2';
|
||||
|
||||
const csv = `${value1}, ${value2}`;
|
||||
const result = parseCSV(csv);
|
||||
|
||||
expect(result).to.be.an('Array').with.lengthOf(2).and.eql([value1, value2]);
|
||||
});
|
||||
|
||||
it('should ignore empty items', () => {
|
||||
const value1 = 'value1';
|
||||
const value2 = 'value2';
|
||||
|
||||
const csv = `${value1}, , , , ${value2}`;
|
||||
const result = parseCSV(csv);
|
||||
|
||||
expect(result).to.be.an('Array').with.lengthOf(2).and.eql([value1, value2]);
|
||||
});
|
||||
|
||||
it('should not ignore empty items when requested', () => {
|
||||
const value1 = 'value1';
|
||||
const value2 = 'value2';
|
||||
|
||||
const csv = `${value1}, , ${value2}`;
|
||||
const result = parseCSV(csv, false);
|
||||
|
||||
expect(result).to.be.an('Array').with.lengthOf(3).and.eql([value1, '', value2]);
|
||||
});
|
||||
});
|
||||
185
apps/meteor/tests/unit/lib/utils/parseParameters.tests.ts
Normal file
185
apps/meteor/tests/unit/lib/utils/parseParameters.tests.ts
Normal file
@@ -0,0 +1,185 @@
|
||||
import { expect } from 'chai';
|
||||
|
||||
import { parseParameters } from '../../../../lib/utils/parseParameters';
|
||||
|
||||
describe('Parse Parameters', () => {
|
||||
it('should return an empty array for an empty string', () => {
|
||||
const result = parseParameters('');
|
||||
|
||||
expect(result).to.be.an('Array').with.lengthOf(0);
|
||||
});
|
||||
|
||||
it('should return an array with one item', () => {
|
||||
const value = 'value';
|
||||
const result = parseParameters(value);
|
||||
|
||||
expect(result).to.be.an('Array').with.lengthOf(1).and.eql([value]);
|
||||
});
|
||||
|
||||
it('should return an array with three items', () => {
|
||||
const value1 = 'value1';
|
||||
const value2 = 'value2';
|
||||
const value3 = 'value3';
|
||||
|
||||
const parameters = `${value1} ${value2} ${value3}`;
|
||||
const result = parseParameters(parameters);
|
||||
|
||||
expect(result).to.be.an('Array').with.lengthOf(3).and.eql([value1, value2, value3]);
|
||||
});
|
||||
|
||||
it('should ignore extra spaces by default', () => {
|
||||
const value1 = 'value1';
|
||||
const value2 = 'value2';
|
||||
|
||||
const parameters = ` ${value1} ${value2} `;
|
||||
const result = parseParameters(parameters);
|
||||
|
||||
expect(result).to.be.an('Array').with.lengthOf(2).and.eql([value1, value2]);
|
||||
});
|
||||
|
||||
it('should NOT ignore extra spaces when requested', () => {
|
||||
const value1 = '';
|
||||
const value2 = '';
|
||||
const value3 = 'value3';
|
||||
const value4 = '';
|
||||
const value5 = '';
|
||||
const value6 = 'value6';
|
||||
const value7 = '';
|
||||
const value8 = '';
|
||||
|
||||
const parameters = `${value1} ${value2} ${value3} ${value4} ${value5} ${value6} ${value7} ${value8}`;
|
||||
const result = parseParameters(parameters, false);
|
||||
|
||||
expect(result).to.be.an('Array').with.lengthOf(8).and.eql([value1, value2, value3, value4, value5, value6, value7, value8]);
|
||||
});
|
||||
|
||||
it('should return an array with one item without quotes', () => {
|
||||
const value = 'value';
|
||||
const result = parseParameters(`"${value}"`);
|
||||
|
||||
expect(result).to.be.an('Array').with.lengthOf(1).and.eql([value]);
|
||||
});
|
||||
it('should return an array with three items without quotes', () => {
|
||||
const value1 = 'value1';
|
||||
const value2 = 'value2';
|
||||
const value3 = 'value3';
|
||||
const result = parseParameters(`"${value1}" "${value2}" "${value3}"`);
|
||||
|
||||
expect(result).to.be.an('Array').with.lengthOf(3).and.eql([value1, value2, value3]);
|
||||
});
|
||||
|
||||
it('should not trim spaces inside quotes', () => {
|
||||
const value1 = 'value1 ';
|
||||
const value2 = ' value2';
|
||||
const value3 = ' value3 ';
|
||||
|
||||
const parameters = `"${value1}" "${value2}" "${value3}"`;
|
||||
const result = parseParameters(parameters);
|
||||
|
||||
expect(result).to.be.an('Array').with.lengthOf(3).and.eql([value1, value2, value3]);
|
||||
});
|
||||
|
||||
it('should split parameters even without spaces', () => {
|
||||
const value1 = 'value1';
|
||||
const value2 = 'value2';
|
||||
const value3 = 'value3';
|
||||
const value4 = 'value4';
|
||||
|
||||
const parameters = `"${value1}""${value2}""${value3}" "${value4}"`;
|
||||
const result = parseParameters(parameters);
|
||||
|
||||
expect(result).to.be.an('Array').with.lengthOf(4).and.eql([value1, value2, value3, value4]);
|
||||
});
|
||||
|
||||
it('should split parameters by both spaces and quotes in the same line', () => {
|
||||
const value1 = 'value1';
|
||||
const value2 = 'value2';
|
||||
|
||||
const parameters = `"${value1}" ${value2}`;
|
||||
const result = parseParameters(parameters);
|
||||
|
||||
expect(result).to.be.an('Array').with.lengthOf(2).and.eql([value1, value2]);
|
||||
});
|
||||
|
||||
it('should unescape quotes inside values', () => {
|
||||
const value1 = `this is \\"value1\\" here`;
|
||||
const value2 = `\\"value2\\"`;
|
||||
|
||||
const parameters = `"${value1}" "${value2}"`;
|
||||
const result = parseParameters(parameters);
|
||||
|
||||
expect(result).to.be.an('Array').with.lengthOf(2);
|
||||
expect(result[0]).to.be.equal(value1.replace(/\\\"/g, '"'));
|
||||
expect(result[1]).to.be.equal(value2.replace(/\\\"/g, '"'));
|
||||
});
|
||||
|
||||
it('should not ignore empty quoted parameters', () => {
|
||||
const value1 = 'value1';
|
||||
const value2 = '';
|
||||
const value3 = 'value3';
|
||||
|
||||
const parameters = `"${value1}" "${value2}" "${value3}"`;
|
||||
const result = parseParameters(parameters);
|
||||
|
||||
expect(result).to.be.an('Array').with.lengthOf(3).and.eql([value1, value2, value3]);
|
||||
});
|
||||
|
||||
it('should accept line breaks inside quotes', () => {
|
||||
const value1 = `value1
|
||||
is multiline`;
|
||||
const value2 = 'value2\nhas a multine too';
|
||||
const value3 = 'value3\rhas a carriage return';
|
||||
|
||||
const parameters = `"${value1}" "${value2}" "${value3}"`;
|
||||
const result = parseParameters(parameters);
|
||||
|
||||
expect(result).to.be.an('Array').with.lengthOf(3);
|
||||
expect(result[0]).to.be.equal(value1);
|
||||
expect(result[1]).to.be.equal(value2);
|
||||
expect(result[2]).to.be.equal(value3);
|
||||
});
|
||||
|
||||
it('should split on line breaks without quotes', () => {
|
||||
const value1 = `value1`;
|
||||
const value2 = 'value2';
|
||||
const value3 = 'value3';
|
||||
|
||||
const parameters = `${value1}
|
||||
${value2}
|
||||
${value3}`;
|
||||
|
||||
const result = parseParameters(parameters);
|
||||
|
||||
expect(result).to.be.an('Array').with.lengthOf(3);
|
||||
expect(result[0]).to.be.equal(value1);
|
||||
expect(result[1]).to.be.equal(value2);
|
||||
expect(result[2]).to.be.equal(value3);
|
||||
});
|
||||
|
||||
it('should accept tabs inside quotes', () => {
|
||||
const value1 = `value1 is tabbed`;
|
||||
const value2 = 'value2';
|
||||
|
||||
const parameters = `"${value1}" "${value2}"`;
|
||||
const result = parseParameters(parameters);
|
||||
|
||||
expect(result).to.be.an('Array').with.lengthOf(2);
|
||||
expect(result[0]).to.be.equal(value1);
|
||||
expect(result[1]).to.be.equal(value2);
|
||||
});
|
||||
|
||||
it('should split on tabs without quotes', () => {
|
||||
const value1 = `value1`;
|
||||
const value2 = 'value2';
|
||||
const value3 = 'value3';
|
||||
|
||||
const parameters = `${value1} ${value2} ${value3}`;
|
||||
|
||||
const result = parseParameters(parameters);
|
||||
|
||||
expect(result).to.be.an('Array').with.lengthOf(3);
|
||||
expect(result[0]).to.be.equal(value1);
|
||||
expect(result[1]).to.be.equal(value2);
|
||||
expect(result[2]).to.be.equal(value3);
|
||||
});
|
||||
});
|
||||
28
apps/meteor/tests/unit/lib/utils/secondsToHHMMSS.spec.ts
Normal file
28
apps/meteor/tests/unit/lib/utils/secondsToHHMMSS.spec.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { expect } from 'chai';
|
||||
|
||||
import { secondsToHHMMSS } from '../../../../lib/utils/secondsToHHMMSS';
|
||||
|
||||
describe('secondsToHHMMSS', () => {
|
||||
const testCases = [
|
||||
[0, '00:00:00'],
|
||||
[1, '00:00:01'],
|
||||
[60, '00:01:00'],
|
||||
[61, '00:01:01'],
|
||||
[3600, '01:00:00'],
|
||||
[3601, '01:00:01'],
|
||||
[3661, '01:01:01'],
|
||||
[3661.1, '01:01:01'],
|
||||
[3661.9, '01:01:02'], // rounding down?
|
||||
[3662, '01:01:02'],
|
||||
[86400, '24:00:00'],
|
||||
[172800, '48:00:00'],
|
||||
[360000, '100:00:00'], // should exceed 8 characters?
|
||||
] as const;
|
||||
|
||||
testCases.forEach(([parameter, expectedResult]) => {
|
||||
it(`should return ${JSON.stringify(expectedResult)} for ${JSON.stringify(parameter)}`, () => {
|
||||
const result = secondsToHHMMSS(parameter);
|
||||
expect(result).to.be.equal(expectedResult);
|
||||
});
|
||||
});
|
||||
});
|
||||
21
apps/meteor/tests/unit/lib/utils/stringUtils.tests.ts
Normal file
21
apps/meteor/tests/unit/lib/utils/stringUtils.tests.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { expect } from 'chai';
|
||||
|
||||
import { truncate } from '../../../../lib/utils/stringUtils';
|
||||
|
||||
describe('String utils', () => {
|
||||
it('should return an empty string when the specified string is empty', () => {
|
||||
expect(truncate('', 10)).to.be.equal('');
|
||||
});
|
||||
|
||||
it('should truncate a larger string', () => {
|
||||
expect(truncate('this text has a few words', 9)).to.be.equal('this t...');
|
||||
});
|
||||
|
||||
it('should not truncate a smaller string', () => {
|
||||
expect(truncate('this', 9)).to.be.equal('this');
|
||||
});
|
||||
|
||||
it('should not truncate a string with the exact length', () => {
|
||||
expect(truncate('this', 4)).to.be.equal('this');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user