Files
upstream-rocketchat/packages/apps/tests/server/misc/Utilities.test.ts
upstream-mirror 30810eecd7
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 2s
snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
2026-09-16 01:21:02 +05:00

100 lines
3.1 KiB
TypeScript

import * as assert from 'node:assert';
import { describe, it } from 'node:test';
import { Utilities } from '../../../src/server/misc/Utilities';
describe('Utilities', () => {
const expectedInfo = {
id: '614055e2-3dba-41fb-be48-c1ff146f5932',
name: 'Testing App',
nameSlug: 'testing-app',
description: 'A Rocket.Chat Application used to test out the various features.',
version: '0.0.8',
requiredApiVersion: '>=0.9.6',
author: {
name: 'Bradley Hilton',
homepage: 'https://github.com/RocketChat/Rocket.Chat.Apps-ts-definitions',
support: 'https://github.com/RocketChat/Rocket.Chat.Apps-ts-definitions/issues',
},
classFile: 'TestingApp.ts',
iconFile: 'testing.jpg',
};
it('testDeepClone', () => {
assert.doesNotThrow(() => Utilities.deepClone(expectedInfo));
const info = Utilities.deepClone(expectedInfo);
assert.deepStrictEqual(info, expectedInfo);
info.name = 'New Testing App';
assert.strictEqual(info.name, 'New Testing App');
assert.strictEqual(info.author.name, expectedInfo.author.name);
});
it('testDeepFreeze', () => {
const testInfo = {
id: '614055e2-3dba-41fb-be48-c1ff146f5932',
name: 'Testing App',
nameSlug: 'testing-app',
description: 'A Rocket.Chat Application used to test out the various features.',
version: '0.0.8',
requiredApiVersion: '>=0.9.6',
author: {
name: 'Bradley Hilton',
homepage: 'https://github.com/RocketChat/Rocket.Chat.Apps-ts-definitions',
support: 'https://github.com/RocketChat/Rocket.Chat.Apps-ts-definitions/issues',
},
classFile: 'TestingApp.ts',
iconFile: 'testing.jpg',
};
assert.doesNotThrow(() => {
testInfo.name = 'New Testing App';
});
assert.doesNotThrow(() => {
testInfo.author.name = 'Bradley H';
});
assert.strictEqual(testInfo.name, 'New Testing App');
assert.strictEqual(testInfo.author.name, 'Bradley H');
assert.doesNotThrow(() => Utilities.deepFreeze(testInfo));
assert.throws(() => {
testInfo.name = 'Old Testing App';
});
assert.throws(() => {
testInfo.author.name = 'Bradley';
});
assert.strictEqual(testInfo.name, 'New Testing App');
assert.strictEqual(testInfo.author.name, 'Bradley H');
});
it('testDeepCloneAndFreeze', () => {
const testInfo = {
id: '614055e2-3dba-41fb-be48-c1ff146f5932',
name: 'Testing App',
nameSlug: 'testing-app',
description: 'A Rocket.Chat Application used to test out the various features.',
version: '0.0.8',
requiredApiVersion: '>=0.9.6',
author: {
name: 'Bradley H',
homepage: 'https://github.com/RocketChat/Rocket.Chat.Apps-ts-definitions',
support: 'https://github.com/RocketChat/Rocket.Chat.Apps-ts-definitions/issues',
},
classFile: 'TestingApp.ts',
iconFile: 'testing.jpg',
};
assert.doesNotThrow(() => Utilities.deepCloneAndFreeze({}));
const info = Utilities.deepCloneAndFreeze(testInfo);
assert.deepStrictEqual(info, testInfo);
assert.notStrictEqual(info, testInfo);
assert.strictEqual(info.author.name, testInfo.author.name);
assert.strictEqual(info.author.name, 'Bradley H');
assert.throws(() => {
info.author.name = 'Bradley Hilton';
});
});
});