This repository has been archived by the owner on Oct 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
43 lines (37 loc) · 1.65 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import {test} from 'ava';
import env from '.';
const CWD = './fixtures';
async function context(t, input, expected) {
const context = this.title === 'default' ? undefined : this.title;
t.is((await env(CWD, {context}))[input], expected);
}
context.title = title => title.split(':').pop();
test('context:production', context, 'NODE_ENV', 'production');
test('context:deploy-preview', context, 'NODE_ENV', 'staging');
test('context:branch-deploy', context, 'NODE_ENV', 'staging');
test('context:development', context, 'NODE_ENV', 'development');
test('context:default', context, 'NODE_ENV', 'development');
test('context:production', context, 'PRODUCTION_ENV', 'production');
test('context:deploy-preview', context, 'DEPLOY_PREVIEW_ENV', 'deploy-preview');
test('context:branch-deploy', context, 'BRANCH_DEPLOY_ENV', 'branch-deploy');
test('context:development', context, 'DEVELOPMENT_ENV', 'development');
test('context:default', context, 'DEVELOPMENT_ENV', 'development');
test('context:production', context, 'BUILD_ENV', 'build');
test('context:deploy-preview', context, 'BUILD_ENV', 'build');
test('context:branch-deploy', context, 'BUILD_ENV', 'build');
test('context:development', context, 'BUILD_ENV', 'build');
test('context:default', context, 'BUILD_ENV', 'build');
test('config:null', async t => {
t.deepEqual((await env('./')), {});
});
test('config:empty', async t => {
const file = 'empty.toml';
t.deepEqual((await env(CWD, {file})), {});
});
test('config:file', async t => {
const file = 'config.toml';
t.is((await env(CWD, {file})).CONFIG_ENV, 'config');
});
test('config:cwd', async t => {
t.is((await env('./fixtures/subdirectory')).BUILD_ENV, 'build');
});