env.test.js 1.52 KB
Newer Older
1
2
3
4
5
6
7
8
9
/**
 * Copyright (c) 2015-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */

10
11
import { expect } from 'chai';
import initDOM from './initDOM';
12
13
14

describe('Integration', () => {
  describe('Environment variables', () => {
15
    it('file env variables', async () => {
16
      const doc = await initDOM('file-env-variables');
17

18
19
20
21
      expect(
        doc.getElementById('feature-file-env-variables').textContent
      ).to.equal('fromtheenvfile.');
    });
22

23
    it('NODE_PATH', async () => {
24
      const doc = await initDOM('node-path');
25

26
27
28
29
      expect(
        doc.getElementById('feature-node-path').childElementCount
      ).to.equal(4);
    });
30

31
    it('PUBLIC_URL', async () => {
32
33
34
35
36
37
38
39
40
41
42
43
      const doc = await initDOM('public-url');

      const prefix = process.env.NODE_ENV === 'development'
        ? ''
        : 'http://www.example.org/spa';
      expect(doc.getElementById('feature-public-url').textContent).to.equal(
        `${prefix}.`
      );
      expect(
        doc.querySelector('head link[rel="shortcut icon"]').getAttribute('href')
      ).to.equal(`${prefix}/favicon.ico`);
    });
44

45
    it('shell env variables', async () => {
46
47
48
49
50
51
52
53
      const doc = await initDOM('shell-env-variables');

      expect(
        doc.getElementById('feature-shell-env-variables').textContent
      ).to.equal('fromtheshell.');
    });
  });
});