1 |
|
2 |
|
3 |
|
4 | const assert = require('assert');
|
5 | const lib = require('./lib');
|
6 | const logger = require('../lib/logger');
|
7 |
|
8 | describe('FEBS Lib Tests', function () {
|
9 | let compile;
|
10 |
|
11 | logger.setLogLevel('warn');
|
12 |
|
13 | beforeEach(function () {
|
14 | process.env.FEBS_TEST = true;
|
15 | compile = lib.createCompileFn(lib.createFS(), 'development');
|
16 | });
|
17 |
|
18 | it('positively asserts against entryName, fileName, content', async function () {
|
19 | const compiled = await compile(lib.createConf({
|
20 | entry: {
|
21 | app1: lib.absPath('fixtures/src/main-es2015.js'),
|
22 | },
|
23 | }));
|
24 |
|
25 |
|
26 | assert(lib.compiledContains(compiled, {
|
27 | entryName: /app1/,
|
28 | fileName: /\.js$/,
|
29 | content: /ction/,
|
30 | }));
|
31 | });
|
32 |
|
33 | it('negatively asserts entryName', async function () {
|
34 | const compiled = await compile(lib.createConf({
|
35 | entry: {
|
36 | app1: lib.absPath('fixtures/src/main-es2015.js'),
|
37 | },
|
38 | }));
|
39 |
|
40 |
|
41 | assert(!lib.compiledContains(compiled, {
|
42 | entryName: /apx/,
|
43 | fileName: /\.js$/,
|
44 | content: /ction/,
|
45 | }));
|
46 | });
|
47 |
|
48 | it('negatively asserts content', async function () {
|
49 | const compiled = await compile(lib.createConf({
|
50 | entry: {
|
51 | app1: lib.absPath('fixtures/src/main-es2015.js'),
|
52 | },
|
53 | }));
|
54 |
|
55 |
|
56 | assert(!lib.compiledContains(compiled, {
|
57 | entryName: /app/,
|
58 | fileName: /\.js$/,
|
59 | content: /xtion/,
|
60 | }));
|
61 | });
|
62 |
|
63 | it('matches filename only', async function () {
|
64 | const compiled = await compile(lib.createConf({
|
65 | entry: {
|
66 | app1: lib.absPath('fixtures/src/main-es2015.js'),
|
67 | },
|
68 | }));
|
69 |
|
70 |
|
71 | assert(lib.compiledContains(compiled, {
|
72 | fileName: /\.js$/,
|
73 | }));
|
74 | });
|
75 |
|
76 | it('matches content only', async function () {
|
77 | const compiled = await compile(lib.createConf({
|
78 | entry: {
|
79 | app1: lib.absPath('fixtures/src/main-es2015.js'),
|
80 | },
|
81 | }));
|
82 |
|
83 |
|
84 | assert(lib.compiledContains(compiled, {
|
85 | content: /add/,
|
86 | }));
|
87 | });
|
88 | });
|