2021-02-04 19:54:03 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import { assert } from 'chai';
|
|
|
|
|
2021-07-28 23:46:25 +00:00
|
|
|
import {
|
|
|
|
Environment,
|
|
|
|
isTestEnvironment,
|
|
|
|
parseEnvironment,
|
|
|
|
} from '../environment';
|
2021-02-04 19:54:03 +00:00
|
|
|
|
|
|
|
describe('environment utilities', () => {
|
|
|
|
describe('parseEnvironment', () => {
|
2024-09-04 18:12:45 +00:00
|
|
|
it('returns Environment.PackagedApp for non-strings', () => {
|
|
|
|
assert.equal(parseEnvironment(undefined), Environment.PackagedApp);
|
|
|
|
assert.equal(parseEnvironment(0), Environment.PackagedApp);
|
2021-02-04 19:54:03 +00:00
|
|
|
});
|
|
|
|
|
2024-09-04 18:12:45 +00:00
|
|
|
it('returns Environment.PackagedApp for invalid strings', () => {
|
|
|
|
assert.equal(parseEnvironment(''), Environment.PackagedApp);
|
|
|
|
assert.equal(parseEnvironment(' development '), Environment.PackagedApp);
|
|
|
|
assert.equal(parseEnvironment('PRODUCTION'), Environment.PackagedApp);
|
2021-02-04 19:54:03 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('parses "development" as Environment.Development', () => {
|
|
|
|
assert.equal(parseEnvironment('development'), Environment.Development);
|
|
|
|
});
|
|
|
|
|
2024-09-04 18:12:45 +00:00
|
|
|
it('parses "production" as Environment.PackagedApp', () => {
|
|
|
|
assert.equal(parseEnvironment('production'), Environment.PackagedApp);
|
2021-02-04 19:54:03 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('parses "staging" as Environment.Staging', () => {
|
|
|
|
assert.equal(parseEnvironment('staging'), Environment.Staging);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('parses "test" as Environment.Test', () => {
|
|
|
|
assert.equal(parseEnvironment('test'), Environment.Test);
|
|
|
|
});
|
|
|
|
});
|
2021-07-28 23:46:25 +00:00
|
|
|
|
|
|
|
describe('isTestEnvironment', () => {
|
|
|
|
it('returns false for non-test environments', () => {
|
|
|
|
assert.isFalse(isTestEnvironment(Environment.Development));
|
2024-09-04 18:12:45 +00:00
|
|
|
assert.isFalse(isTestEnvironment(Environment.PackagedApp));
|
2021-07-28 23:46:25 +00:00
|
|
|
assert.isFalse(isTestEnvironment(Environment.Staging));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('returns true for test environments', () => {
|
|
|
|
assert.isTrue(isTestEnvironment(Environment.Test));
|
|
|
|
});
|
|
|
|
});
|
2021-02-04 19:54:03 +00:00
|
|
|
});
|