env.test.js 1.12 KB
Newer Older
1
2
3
4
5
import { expect } from 'chai'
import initDOM from './initDOM'

describe('Integration', () => {
  describe('Environment variables', () => {
6
7
8
9
10
11
    it('file env variables', async () => {
      const doc = await initDOM('file-env-variables')

      expect(doc.getElementById('feature-file-env-variables').textContent).to.equal('fromtheenvfile.')
    })

12
13
14
15
16
17
    it('NODE_PATH', async () => {
      const doc = await initDOM('node-path')

      expect(doc.getElementById('feature-node-path').childElementCount).to.equal(4)
    })

18
19
    it('PUBLIC_URL', async () => {
      const doc = await initDOM('public-url')
20

21
22
23
24
      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`)
25
26
    })

27
28
    it('shell env variables', async () => {
      const doc = await initDOM('shell-env-variables')
29

30
      expect(doc.getElementById('feature-shell-env-variables').textContent).to.equal('fromtheshell.')
31
32
33
    })
  })
})