1 |
|
2 |
|
3 | import assert from 'assert';
|
4 | import {createEnvironment} from '../src/Environment';
|
5 |
|
6 | describe('Environment', () => {
|
7 | it('assigns a default environment with nothing passed', () => {
|
8 | assert.deepEqual(createEnvironment(), {
|
9 | context: 'browser',
|
10 | engines: {
|
11 | browsers: ['> 0.25%'],
|
12 | },
|
13 | includeNodeModules: true,
|
14 | outputFormat: 'global',
|
15 | isLibrary: false,
|
16 | });
|
17 | });
|
18 |
|
19 | it('assigns a node context if a node engine is given', () => {
|
20 | assert.deepEqual(createEnvironment({engines: {node: '>= 10.0.0'}}), {
|
21 | context: 'node',
|
22 | engines: {
|
23 | node: '>= 10.0.0',
|
24 | },
|
25 | includeNodeModules: false,
|
26 | outputFormat: 'commonjs',
|
27 | isLibrary: false,
|
28 | });
|
29 | });
|
30 |
|
31 | it('assigns a browser context if browser engines are given', () => {
|
32 | assert.deepEqual(
|
33 | createEnvironment({engines: {browsers: ['last 1 version']}}),
|
34 | {
|
35 | context: 'browser',
|
36 | engines: {
|
37 | browsers: ['last 1 version'],
|
38 | },
|
39 | includeNodeModules: true,
|
40 | outputFormat: 'global',
|
41 | isLibrary: false,
|
42 | },
|
43 | );
|
44 | });
|
45 |
|
46 | it('assigns default engines for node', () => {
|
47 | assert.deepEqual(createEnvironment({context: 'node'}), {
|
48 | context: 'node',
|
49 | engines: {
|
50 | node: '>= 8.0.0',
|
51 | },
|
52 | includeNodeModules: false,
|
53 | outputFormat: 'commonjs',
|
54 | isLibrary: false,
|
55 | });
|
56 | });
|
57 |
|
58 | it('assigns default engines for browsers', () => {
|
59 | assert.deepEqual(createEnvironment({context: 'browser'}), {
|
60 | context: 'browser',
|
61 | engines: {
|
62 | browsers: ['> 0.25%'],
|
63 | },
|
64 | includeNodeModules: true,
|
65 | outputFormat: 'global',
|
66 | isLibrary: false,
|
67 | });
|
68 | });
|
69 | });
|