cli.spec.js 631 B

1234567891011121314151617181920212223242526
  1. const { getOptionsArgs } = require('../cli');
  2. describe('cli', () => {
  3. describe('getOptionsArgs', () => {
  4. it('should return an object with specified fields when provided', () => {
  5. const options = {
  6. socks: 'socks',
  7. port: 'port',
  8. level: 'level',
  9. config: 'config',
  10. FIELD_NOT_EXIST: 'FIELD_NOT_EXIST',
  11. };
  12. const res = getOptionsArgs(options);
  13. Object.keys(options).forEach((name) => {
  14. if (name === 'FIELD_NOT_EXIST') {
  15. expect(res[name]).toBeFalsy();
  16. return;
  17. }
  18. expect(res[name]).toBeTruthy();
  19. });
  20. });
  21. });
  22. });