mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-22 01:22:54 +00:00
committed by
Karl-Philipp Wulfert
parent
1ae3beb347
commit
766205049b
@@ -14,11 +14,15 @@
|
||||
*/
|
||||
import {expect} from 'chai';
|
||||
import {slow, suite, test, timeout} from 'mocha-typescript';
|
||||
import {deleteUndefinedProperties} from '../src/common';
|
||||
import {
|
||||
deleteUndefinedProperties,
|
||||
isNodeEnvironment,
|
||||
isProductiveEnvironment,
|
||||
isProductiveNodeEnvironment,
|
||||
} from '../src/common';
|
||||
|
||||
@suite(timeout(2000), slow(1000))
|
||||
export class CommonSpec {
|
||||
/* tslint:disable:member-ordering */
|
||||
@test
|
||||
deleteUndefinedProperties1() {
|
||||
expect(deleteUndefinedProperties(
|
||||
@@ -67,4 +71,48 @@ export class CommonSpec {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@test
|
||||
isNodeEnvironment() {
|
||||
expect(isNodeEnvironment()).to.be.equal(true);
|
||||
|
||||
const savedProcess = process;
|
||||
|
||||
// @ts-ignore
|
||||
process = undefined;
|
||||
|
||||
expect(isNodeEnvironment()).to.be.equal(false);
|
||||
|
||||
process = savedProcess;
|
||||
}
|
||||
|
||||
@test
|
||||
isProductiveEnvironment() {
|
||||
const nodeEnv = process.env.NODE_ENV;
|
||||
|
||||
process.env.NODE_ENV = '';
|
||||
|
||||
expect(isProductiveEnvironment()).to.be.equal(false);
|
||||
|
||||
process.env.NODE_ENV = 'production';
|
||||
|
||||
expect(isProductiveEnvironment()).to.be.equal(true);
|
||||
|
||||
process.env.NODE_ENV = nodeEnv;
|
||||
}
|
||||
|
||||
@test
|
||||
isProductiveNodeEnvironment() {
|
||||
const nodeEnv = process.env.NODE_ENV;
|
||||
|
||||
process.env.NODE_ENV = '';
|
||||
|
||||
expect(isProductiveNodeEnvironment()).to.be.equal(false);
|
||||
|
||||
process.env.NODE_ENV = 'production';
|
||||
|
||||
expect(isProductiveNodeEnvironment()).to.be.equal(true);
|
||||
|
||||
process.env.NODE_ENV = nodeEnv;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user