|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const { run } = require('../utils/test-utils'); |
| 4 | +const { stat } = require('fs'); |
| 5 | +const { resolve } = require('path'); |
| 6 | + |
| 7 | +describe('--config-name flag', () => { |
| 8 | + it('should select only the config whose name is passed with --config-name', (done) => { |
| 9 | + const { stderr, stdout } = run(__dirname, ['--config-name', 'first'], false); |
| 10 | + expect(stderr).toBeFalsy(); |
| 11 | + expect(stdout).toContain('Child first'); |
| 12 | + expect(stdout).not.toContain('Child second'); |
| 13 | + expect(stdout).not.toContain('Child third'); |
| 14 | + |
| 15 | + stat(resolve(__dirname, './dist/dist-first.js'), (err, stats) => { |
| 16 | + expect(err).toBe(null); |
| 17 | + expect(stats.isFile()).toBe(true); |
| 18 | + done(); |
| 19 | + }); |
| 20 | + }); |
| 21 | + |
| 22 | + it('should work with multiple values for --config-name', (done) => { |
| 23 | + const { stderr, stdout } = run(__dirname, ['--config-name', 'first', '--config-name', 'third'], false); |
| 24 | + expect(stderr).toBeFalsy(); |
| 25 | + expect(stdout).toContain('Child first'); |
| 26 | + expect(stdout).not.toContain('Child second'); |
| 27 | + expect(stdout).toContain('Child third'); |
| 28 | + |
| 29 | + stat(resolve(__dirname, './dist/dist-first.js'), (err, stats) => { |
| 30 | + expect(err).toBe(null); |
| 31 | + expect(stats.isFile()).toBe(true); |
| 32 | + done(); |
| 33 | + }); |
| 34 | + stat(resolve(__dirname, './dist/dist-third.js'), (err, stats) => { |
| 35 | + expect(err).toBe(null); |
| 36 | + expect(stats.isFile()).toBe(true); |
| 37 | + done(); |
| 38 | + }); |
| 39 | + }); |
| 40 | + |
| 41 | + it('should log error if invalid config name is provided', () => { |
| 42 | + const { stderr, stdout } = run(__dirname, ['--config-name', 'test'], false); |
| 43 | + expect(stderr).toContain('Configuration with name "test" was not found.'); |
| 44 | + expect(stdout).toBeFalsy(); |
| 45 | + }); |
| 46 | +}); |
0 commit comments