index.test.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. 'use strict';
  2. const utils = require('../index');
  3. describe('utils', () => {
  4. describe('createArrowFunction', () => {
  5. it('should stringify an arrow function', () => {
  6. expect(utils.createArrowFunction('app.js')).toMatchSnapshot();
  7. });
  8. });
  9. describe('createRegularFunction', () => {
  10. it('should stringify an regular function', () => {
  11. expect(utils.createRegularFunction('app.js')).toMatchSnapshot();
  12. });
  13. });
  14. describe('createDynamicPromise', () => {
  15. it('should stringify an single value', () => {
  16. expect(utils.createDynamicPromise('app.js')).toMatchSnapshot();
  17. });
  18. it('should stringify an array', () => {
  19. expect(utils.createDynamicPromise(['app.js', 'index.js'])).toMatchSnapshot();
  20. });
  21. });
  22. describe('createAssetFilterFunction', () => {
  23. it('should stringify an assetFilterFunction', () => {
  24. expect(utils.createAssetFilterFunction('js')).toMatchSnapshot();
  25. });
  26. });
  27. describe('createExternalFunction', () => {
  28. it('should stringify an ExternalFunction', () => {
  29. expect(utils.createExternalFunction('js')).toMatchSnapshot();
  30. });
  31. });
  32. describe('createCommonsChunkPlugin', () => {
  33. it('should stringify an commonChunksPlugin', () => {
  34. expect(utils.createCommonsChunkPlugin('vendor')).toMatchSnapshot();
  35. });
  36. });
  37. describe('createRequire', () => {
  38. it('should stringify an require statement', () => {
  39. expect(utils.createRequire('webpack')).toMatchSnapshot();
  40. });
  41. });
  42. describe('Inquirer', () => {
  43. it('should make an List object', () => {
  44. expect(utils.List('entry', 'does it work?', ['Yes', 'Maybe'])).toEqual({
  45. type: 'list',
  46. name: 'entry',
  47. message: 'does it work?',
  48. choices: ['Yes', 'Maybe']
  49. });
  50. });
  51. it('should make an RawList object', () => {
  52. expect(utils.RawList('output', 'does it work?', ['Yes', 'Maybe'])).toEqual({
  53. type: 'rawlist',
  54. name: 'output',
  55. message: 'does it work?',
  56. choices: ['Yes', 'Maybe']
  57. });
  58. });
  59. it('should make an CheckList object', () => {
  60. expect(utils.CheckList('context', 'does it work?', ['Yes', 'Maybe'])).toEqual({
  61. type: 'checkbox',
  62. name: 'context',
  63. message: 'does it work?',
  64. choices: ['Yes', 'Maybe']
  65. });
  66. });
  67. it('should make an Input object', () => {
  68. expect(utils.Input('plugins', 'what is your plugin?')).toEqual({
  69. type: 'input',
  70. name: 'plugins',
  71. message: 'what is your plugin?'
  72. });
  73. });
  74. it('should make an Confirm object', () => {
  75. expect(utils.Confirm('context', 'what is your context?')).toEqual({
  76. type: 'confirm',
  77. name: 'context',
  78. message: 'what is your context?'
  79. });
  80. });
  81. it('should make an Input object with validation', () => {
  82. expect(
  83. utils.InputValidate('plugins', 'what is your plugin?', () => {})
  84. ).toMatchSnapshot();
  85. });
  86. });
  87. });