2022-10-08 20:56:30 +00:00
|
|
|
import { NotFoundError } from '@apextoaster/js-utils';
|
2019-11-13 14:20:34 +00:00
|
|
|
import { expect } from 'chai';
|
|
|
|
|
2022-10-08 20:56:30 +00:00
|
|
|
import { envType } from '../../src/type/Env.js';
|
2019-11-13 14:20:34 +00:00
|
|
|
|
2020-03-29 13:13:57 +00:00
|
|
|
describe('env config type', async () => {
|
|
|
|
it('should throw on missing variables', async () => {
|
2019-11-13 14:20:34 +00:00
|
|
|
expect(() => {
|
|
|
|
envType.resolve('DOES_NOT_EXIST_');
|
|
|
|
}).to.throw(NotFoundError);
|
|
|
|
});
|
|
|
|
|
2020-03-29 13:13:57 +00:00
|
|
|
it('should resolve existing variables', async () => {
|
2019-11-13 14:20:34 +00:00
|
|
|
expect(envType.resolve('CI_COMMIT_SHA')).to.equal(true);
|
|
|
|
});
|
|
|
|
|
2020-03-29 13:13:57 +00:00
|
|
|
it('should construct a value from variables', async () => {
|
2022-10-08 20:56:30 +00:00
|
|
|
expect(envType.construct('CI_COMMIT_SHA')).to.match(/[a-f0-9]+/);
|
2019-11-13 14:20:34 +00:00
|
|
|
});
|
|
|
|
});
|