webpack.test.js 2.17 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
15

describe('Integration', () => {
  describe('Webpack plugins', () => {
    it('css inclusion', async () => {
16
      const doc = await initDOM('css-inclusion');
17

18
19
      expect(
        doc.getElementsByTagName('style')[0].textContent.replace(/\s/g, '')
20
21
22
      ).to.match(/html\{/);
      expect(
        doc.getElementsByTagName('style')[1].textContent.replace(/\s/g, '')
23
24
      ).to.match(/#feature-css-inclusion\{background:.+;color:.+}/);
    });
25
26

    it('image inclusion', async () => {
27
      const doc = await initDOM('image-inclusion');
28

29
30
31
32
      expect(doc.getElementById('feature-image-inclusion').src).to.match(
        /^data:image\/jpeg;base64.+==$/
      );
    });
33
34

    it('no ext inclusion', async () => {
35
      const doc = await initDOM('no-ext-inclusion');
36

37
38
39
40
      expect(doc.getElementById('feature-no-ext-inclusion').href).to.match(
        /\/static\/media\/aFileWithoutExt\.[a-f0-9]{8}\.bin$/
      );
    });
41
42

    it('json inclusion', async () => {
43
      const doc = await initDOM('json-inclusion');
44

45
46
47
48
      expect(doc.getElementById('feature-json-inclusion').textContent).to.equal(
        'This is an abstract.'
      );
    });
49

Joe Haddad's avatar
Joe Haddad committed
50
51
52
53
54
55
56
57
    it('linked modules', async () => {
      const doc = await initDOM('linked-modules');

      expect(doc.getElementById('feature-linked-modules').textContent).to.equal(
        '2.0.0'
      );
    });

58
    it('svg inclusion', async () => {
59
      const doc = await initDOM('svg-inclusion');
60

61
62
63
64
      expect(doc.getElementById('feature-svg-inclusion').src).to.match(
        /\/static\/media\/logo\..+\.svg$/
      );
    });
65
66

    it('unknown ext inclusion', async () => {
67
68
69
70
71
72
73
74
      const doc = await initDOM('unknown-ext-inclusion');

      expect(doc.getElementById('feature-unknown-ext-inclusion').href).to.match(
        /\/static\/media\/aFileWithExt\.[a-f0-9]{8}\.unknown$/
      );
    });
  });
});