Skip to content

Commit aaa3b06

Browse files
committed
Adding sixth functional test fixture
1 parent 91c2e21 commit aaa3b06

13 files changed

Lines changed: 1988 additions & 0 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/dist
2+
/node_modules

functional_tests/fixture_6/META-INF/context.xml

Whitespace-only changes.

functional_tests/fixture_6/WEB-INF/web.xml

Whitespace-only changes.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import 'mocha';
2+
import * as chai from 'chai';
3+
const expect = chai.expect;
4+
import { exec, cd } from 'shelljs';
5+
import * as AdmZip from 'adm-zip';
6+
import { resolve } from 'path';
7+
8+
describe('Fixture 6: specifying a different archive name, bundling multiple assets, adding a WEB-INF folder and adding additional elements', function () {
9+
let webpackOutput: string;
10+
let archiveEntries: string[];
11+
12+
before('Run webpack build', function () {
13+
cd(resolve(__dirname));
14+
const { code, stderr, stdout } = exec('yarn run build');
15+
16+
if (code != 0) return expect.fail(stderr, '', 'Webpack build failed');
17+
18+
webpackOutput = stdout;
19+
});
20+
21+
before('Get archive entries', function () {
22+
const zip = new AdmZip(resolve(__dirname, 'dist', 'archive.war'));
23+
24+
archiveEntries = zip.getEntries().map(entry => entry.entryName);
25+
});
26+
27+
describe('Webpack output', function () {
28+
it('Should output "WAR Archive"', function () {
29+
expect(webpackOutput).to.contain('WAR Archive');
30+
});
31+
32+
it('Should output the correct archive information line', function () {
33+
expect(webpackOutput).to.contain('archive.war');
34+
expect(webpackOutput).to.contain('[written]');
35+
expect(webpackOutput).to.match(/[\s\S]archive\.war\t\d+\.?\d* (B|KB|MB)[\s\S]/);
36+
});
37+
});
38+
39+
describe('Archive content', function () {
40+
it('Should create a archive which contains the correct assets', function () {
41+
expect(archiveEntries).to.include.members(['file1.js', 'file2.js', 'file3.js', 'dir1/file4.js']);
42+
});
43+
44+
it('Should create a archive which contains the correct additional elements', function () {
45+
expect(archiveEntries).to.include.members(['file1.js', 'META-INF/context.xml', 'pom.xml', 'dir/man.xml']);
46+
});
47+
48+
it('Should create a archive which contains the correct WEB-INF elements', function () {
49+
expect(archiveEntries).to.include.members(['file1.js', 'WEB-INF/web.xml']);
50+
});
51+
});
52+
});

functional_tests/fixture_6/manifest.xml

Whitespace-only changes.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "fixture_6",
3+
"version": "0.0.0",
4+
"description": "Test fixture specifying a different archive name, bundling multiple assets, adding a WEB-INF folder and adding additional elements",
5+
"main": "fixture_6.func.spec.ts",
6+
"license": "MIT",
7+
"private": true,
8+
"scripts": {
9+
"clean": "rimraf dist",
10+
"prebuild": "yarn run clean",
11+
"build": "webpack --display-error-details"
12+
},
13+
"dependencies": {
14+
"rimraf": "^2.6.1",
15+
"webpack": "^2.4.1"
16+
}
17+
}

functional_tests/fixture_6/pom.xml

Whitespace-only changes.

functional_tests/fixture_6/src/dir1/file4.js

Whitespace-only changes.

functional_tests/fixture_6/src/file1.js

Whitespace-only changes.

functional_tests/fixture_6/src/file2.js

Whitespace-only changes.

0 commit comments

Comments
 (0)