|
| 1 | +var cli = require("../../../dist/cli/cli-options"); |
| 2 | +var merge = cli.merge; |
| 3 | +var assert = require("chai").assert; |
| 4 | + |
| 5 | +describe.only("CLI: Options: Merging Watch Option", function() { |
| 6 | + it("watches in server mode (no files given)", function() { |
| 7 | + var input = {server: true, watch: true}; |
| 8 | + var config = merge(input).toJS(); |
| 9 | + assert.deepEqual(config.files, { core: { globs: [ '.' ], objs: [] } }); |
| 10 | + assert.ok(config.watchOptions.ignored.length); |
| 11 | + }); |
| 12 | + it("watches in server mode (files given also)", function() { |
| 13 | + var input = {server: true, watch: true, files: ['/shane']}; |
| 14 | + var config = merge(input).toJS(); |
| 15 | + assert.deepEqual(config.files, { core: { globs: [ '/shane', '.' ], objs: [] } }); |
| 16 | + }); |
| 17 | + it("watches from serveStatic option (no files given also)", function() { |
| 18 | + var input = {serveStatic: ['./test'], watch: true}; |
| 19 | + var config = merge(input).toJS(); |
| 20 | + assert.deepEqual(config.files, { core: { globs: [ './test' ], objs: [] } }); |
| 21 | + }); |
| 22 | + it("watches from serveStatic option (files given also)", function() { |
| 23 | + var input = {serveStatic: ['./test'], watch: true, files: ['/some-path']}; |
| 24 | + var config = merge(input).toJS(); |
| 25 | + assert.deepEqual(config.files, { core: { globs: [ '/some-path', './test' ], objs: [] } }); |
| 26 | + }); |
| 27 | + it("watches from server as string option", function() { |
| 28 | + var input = {server: './test', watch: true}; |
| 29 | + var config = merge(input).toJS(); |
| 30 | + assert.deepEqual(config.files, { core: { globs: [ './test' ], objs: [] } }); |
| 31 | + }); |
| 32 | + it("watches from server as Array<string> option", function() { |
| 33 | + var input = {server: ['./test', '.tmp'], watch: true}; |
| 34 | + var config = merge(input).toJS(); |
| 35 | + assert.deepEqual(config.files, { core: { globs: [ './test', '.tmp'], objs: [] } }); |
| 36 | + }); |
| 37 | + it("watches from server.baseDir as string", function() { |
| 38 | + var input = {server: { baseDir: './test' }, watch: true}; |
| 39 | + var config = merge(input).toJS(); |
| 40 | + assert.deepEqual(config.files, { core: { globs: [ './test' ], objs: [] } }); |
| 41 | + }); |
| 42 | + it("watches from server.baseDir as Array<string>", function() { |
| 43 | + var input = {server: { baseDir: ['./test', '.tmp'] }, watch: true}; |
| 44 | + var config = merge(input).toJS(); |
| 45 | + assert.deepEqual(config.files, { core: { globs: [ './test', '.tmp'], objs: [] } }); |
| 46 | + }); |
| 47 | + it("merges from ignore path (string)", function() { |
| 48 | + var input = {server: ['.'], watch: true, ignore: '*.json'}; |
| 49 | + var config = merge(input); |
| 50 | + assert.ok(config.getIn(['watchOptions', 'ignored']).contains('*.json')); |
| 51 | + }); |
| 52 | + it("merges from ignore path + watchOptions (string)", function() { |
| 53 | + var input = { |
| 54 | + server: ['.'], |
| 55 | + watch: true, |
| 56 | + ignore: '*.json', |
| 57 | + watchOptions: {ignored: '*.txt'} |
| 58 | + }; |
| 59 | + var config = merge(input); |
| 60 | + assert.ok(config.getIn(['watchOptions', 'ignored']).contains('*.txt')); |
| 61 | + assert.ok(config.getIn(['watchOptions', 'ignored']).contains('*.json')); |
| 62 | + }); |
| 63 | + it("merges from ignore path + watchOptions (Array<string>)", function() { |
| 64 | + var input = { |
| 65 | + server: ['.'], |
| 66 | + watch: true, |
| 67 | + ignore: ['*.json', '*.json2'], |
| 68 | + watchOptions: {ignored: ['*.txt', '*.txt2']} |
| 69 | + }; |
| 70 | + var config = merge(input); |
| 71 | + assert.ok(config.getIn(['watchOptions', 'ignored']).contains('*.txt')); |
| 72 | + assert.ok(config.getIn(['watchOptions', 'ignored']).contains('*.txt2')); |
| 73 | + assert.ok(config.getIn(['watchOptions', 'ignored']).contains('*.json')); |
| 74 | + assert.ok(config.getIn(['watchOptions', 'ignored']).contains('*.json2')); |
| 75 | + }); |
| 76 | + it("merges from server, serveStatic + ignore path + watchOptions (Array<string>)", function() { |
| 77 | + var input = { |
| 78 | + server: ['.'], |
| 79 | + watch: true, |
| 80 | + ignore: ['*.json', '*.json2'], |
| 81 | + watchOptions: {ignored: ['*.txt', '*.txt2']} |
| 82 | + }; |
| 83 | + var config = merge(input); |
| 84 | + assert.ok(config.getIn(['watchOptions', 'ignored']).contains('*.txt')); |
| 85 | + assert.ok(config.getIn(['watchOptions', 'ignored']).contains('*.txt2')); |
| 86 | + assert.ok(config.getIn(['watchOptions', 'ignored']).contains('*.json')); |
| 87 | + assert.ok(config.getIn(['watchOptions', 'ignored']).contains('*.json2')); |
| 88 | + }); |
| 89 | +}); |
0 commit comments