diff --git a/packages/bot-utils/tests/args-to-flags.test.ts b/packages/bot-utils/tests/args-to-flags.test.ts index 4156075..35567f7 100644 --- a/packages/bot-utils/tests/args-to-flags.test.ts +++ b/packages/bot-utils/tests/args-to-flags.test.ts @@ -3,151 +3,157 @@ import { describe, expect, it } from 'vitest'; import { argsToFlags, Flags } from '../src/flags'; describe('Utils', () => { - describe('args to flags', () => { - it('should convert dns args to flags', () => { - const args = 'dns google.com from New York --limit 2 --type AAAA --protocol tcp --port 80 --resolver 1.1.1.1 --trace --latency'; - const result = argsToFlags(args); - const flags: Flags = { - cmd: 'dns', - target: 'google.com', - from: 'new york', - limit: 2, - query: 'AAAA', - protocol: 'TCP', - port: 80, - resolver: '1.1.1.1', - trace: true, - latency: true, - }; - - expect(result).toEqual(flags); - }); - - describe('http args to flags', () => { - it('host target', () => { - const args = 'http google.com from New York --limit 2 --path / --query ?a=abc --host google.fr --method get --port 80 --protocol http2 --latency'; - const result = argsToFlags(args); - - const flags: Flags = { - cmd: 'http', - from: 'new york', - host: 'google.fr', - limit: 2, - method: 'GET', - path: '/', - port: 80, - protocol: 'HTTP2', - query: '?a=abc', - target: 'google.com', - latency: true, - headers: {}, - }; - - expect(result).toEqual(flags); - }); - - it('url target, resolver and spaces', () => { - const args = 'http https://www.example.com:1234/my/path/?abc=123&xyz=test @8.8.8.8 --from usa --limit 2 --method get'; - const result = argsToFlags(args); - - const flags: Flags = { - cmd: 'http', - from: 'usa', - host: 'www.example.com', - limit: 2, - method: 'GET', - path: '/my/path/', - port: 1234, - protocol: 'HTTPS', - query: 'abc=123&xyz=test', - target: 'www.example.com', - headers: {}, - resolver: '8.8.8.8' - }; - - expect(result).toEqual(flags); - }); - - it('with 1 simple header', () => { - const args = 'http google.com from New York --limit 2 --path / --query "?a=abc" --host google.fr --method get --port 80 --protocol http2 --full -H "AB: 123z"'; - const result = argsToFlags(args); - - const flags: Flags = { - cmd: 'http', - from: 'new york', - host: 'google.fr', - limit: 2, - method: 'GET', - path: '/', - port: 80, - protocol: 'HTTP2', - query: '?a=abc', - target: 'google.com', - full: true, - headers: { - 'AB': '123z', - }, - }; - - expect(result).toEqual(flags); - }); - - it('with 2 headers', () => { - const args = 'http google.com from New York --limit 2 --path / --query ?a=abc --host google.fr --method get --port 80 --protocol http2 --latency --header "Content-Encoding: gzip" --header \'Content-Type: text/html; charset=utf-8\''; - const result = argsToFlags(args); - - const flags: Flags = { - cmd: 'http', - from: 'new york', - host: 'google.fr', - limit: 2, - method: 'GET', - path: '/', - port: 80, - protocol: 'HTTP2', - query: '?a=abc', - target: 'google.com', - latency: true, - headers: { - 'Content-Encoding': 'gzip', - 'Content-Type': 'text/html; charset=utf-8', - }, - }; - - expect(result).toEqual(flags); - }); - }); - - it('convert ping args to flags', () => { - const args = 'ping google.com from New York --limit 2 --packets 3 --latency'; - const result = argsToFlags(args); - const flags: Flags = { - cmd: 'ping', - from: 'new york', - limit: 2, - packets: 3, - target: 'google.com', - latency: true, - }; - - expect(result).toEqual(flags); - }); - - it('convert mtr args to flags with share', () => { - const args = 'mtr aws.com from Canada --packets 2 --protocol icmp -L 5 --share'; - const result = argsToFlags(args); - const flags: Flags = { - cmd: 'mtr', - from: 'canada', - limit: 5, - packets: 2, - protocol: 'ICMP', - target: 'aws.com', - share: true, - }; - - expect(result).toEqual(flags); - }); - - }); -}); \ No newline at end of file + describe('args to flags', () => { + it('should convert dns args to flags', () => { + const args = + 'dns google.com from New York --limit 2 --type AAAA --protocol tcp --port 80 --resolver 1.1.1.1 --trace --latency'; + const result = argsToFlags(args); + const flags: Flags = { + cmd: 'dns', + target: 'google.com', + from: 'New York', + limit: 2, + query: 'AAAA', + protocol: 'TCP', + port: 80, + resolver: '1.1.1.1', + trace: true, + latency: true, + }; + + expect(result).toEqual(flags); + }); + + describe('http args to flags', () => { + it('host target', () => { + const args = + 'http google.com from New York --limit 2 --path / --query ?a=abc --host google.fr --method get --port 80 --protocol http2 --latency'; + const result = argsToFlags(args); + + const flags: Flags = { + cmd: 'http', + from: 'New York', + host: 'google.fr', + limit: 2, + method: 'GET', + path: '/', + port: 80, + protocol: 'HTTP2', + query: '?a=abc', + target: 'google.com', + latency: true, + headers: {}, + }; + + expect(result).toEqual(flags); + }); + + it('url target, resolver and spaces', () => { + const args = + 'http https://www.example.com:1234/my/path/?abc=123&xyz=test @8.8.8.8 --from usa --limit 2 --method get'; + const result = argsToFlags(args); + + const flags: Flags = { + cmd: 'http', + from: 'usa', + host: 'www.example.com', + limit: 2, + method: 'GET', + path: '/my/path/', + port: 1234, + protocol: 'HTTPS', + query: 'abc=123&xyz=test', + target: 'www.example.com', + headers: {}, + resolver: '8.8.8.8', + }; + + expect(result).toEqual(flags); + }); + + it('with 1 simple header', () => { + const args = + 'http google.com from New York --limit 2 --path / --query "?a=abc" --host google.fr --method get --port 80 --protocol http2 --full -H "AB: 123z"'; + const result = argsToFlags(args); + + const flags: Flags = { + cmd: 'http', + from: 'New York', + host: 'google.fr', + limit: 2, + method: 'GET', + path: '/', + port: 80, + protocol: 'HTTP2', + query: '?a=abc', + target: 'google.com', + full: true, + headers: { + AB: '123z', + }, + }; + + expect(result).toEqual(flags); + }); + + it('with 2 headers', () => { + const args = + 'http google.com from New York --limit 2 --path / --query ?a=abc --host google.fr --method get --port 80 --protocol http2 --latency --header "Content-Encoding: gzip" --header \'Content-Type: text/html; charset=utf-8\''; + const result = argsToFlags(args); + + const flags: Flags = { + cmd: 'http', + from: 'New York', + host: 'google.fr', + limit: 2, + method: 'GET', + path: '/', + port: 80, + protocol: 'HTTP2', + query: '?a=abc', + target: 'google.com', + latency: true, + headers: { + 'Content-Encoding': 'gzip', + 'Content-Type': 'text/html; charset=utf-8', + }, + }; + + expect(result).toEqual(flags); + }); + }); + + it('convert ping args to flags', () => { + const args = + 'ping google.com from New York --limit 2 --packets 3 --latency'; + const result = argsToFlags(args); + const flags: Flags = { + cmd: 'ping', + from: 'New York', + limit: 2, + packets: 3, + target: 'google.com', + latency: true, + }; + + expect(result).toEqual(flags); + }); + + it('convert mtr args to flags with share', () => { + const args = + 'mtr aws.com from Canada --packets 2 --protocol icmp -L 5 --share'; + const result = argsToFlags(args); + const flags: Flags = { + cmd: 'mtr', + from: 'Canada', + limit: 5, + packets: 2, + protocol: 'ICMP', + target: 'aws.com', + share: true, + }; + + expect(result).toEqual(flags); + }); + }); +}); diff --git a/packages/bot-utils/tests/measurements-request.test.ts b/packages/bot-utils/tests/measurements-request.test.ts index 379ecc2..87e30a5 100644 --- a/packages/bot-utils/tests/measurements-request.test.ts +++ b/packages/bot-utils/tests/measurements-request.test.ts @@ -9,34 +9,41 @@ describe('Utils', () => { it('should parse ping args', () => { const args = 'ping google.com from New York'; const result = buildPostMeasurements(argsToFlags(args)); - expect(result).toEqual([{ - type: 'ping', - target: 'google.com', - inProgressUpdates: false, - limit: 1, - locations: [{ magic: 'new york' }], - measurementOptions: {} - }]); + expect(result).toEqual([ + { + type: 'ping', + target: 'google.com', + inProgressUpdates: false, + limit: 1, + locations: [{ magic: 'New York' }], + measurementOptions: {}, + }, + ]); }); it('should parse ping args with flags', () => { const args = 'ping google.com from New York --limit 2 --packets 3'; const result = buildPostMeasurements(argsToFlags(args)); - expect(result).toEqual([{ - type: 'ping', - target: 'google.com', - inProgressUpdates: false, - limit: 2, - locations: [{ magic: 'new york' }], - measurementOptions: { - packets: 3 - } - }]); + expect(result).toEqual([ + { + type: 'ping', + target: 'google.com', + inProgressUpdates: false, + limit: 2, + locations: [{ magic: 'New York' }], + measurementOptions: { + packets: 3, + }, + }, + ]); }); it('should throw if incorrect ping flag', () => { - const args = 'ping google.com from New York --limit 2 --packets 3 --protocol icmp'; - expect(() => buildPostMeasurements(argsToFlags(args))).toThrow('Invalid option "protocol" for "ping"!\nExpected "packets, latency, target, from, limit, share".'); + const args = + 'ping google.com from New York --limit 2 --packets 3 --protocol icmp'; + expect(() => buildPostMeasurements(argsToFlags(args))).toThrow( + 'Invalid option "protocol" for "ping"!\nExpected "packets, latency, target, from, limit, share".' + ); }); }); @@ -44,35 +51,43 @@ describe('Utils', () => { it('should parse traceroute args', () => { const args = 'traceroute google.com from New York'; const result = buildPostMeasurements(argsToFlags(args)); - expect(result).toEqual([{ - type: 'traceroute', - target: 'google.com', - inProgressUpdates: false, - limit: 1, - locations: [{ magic: 'new york' }], - measurementOptions: {} - }]); + expect(result).toEqual([ + { + type: 'traceroute', + target: 'google.com', + inProgressUpdates: false, + limit: 1, + locations: [{ magic: 'New York' }], + measurementOptions: {}, + }, + ]); }); it('should parse traceroute args with flags', () => { - const args = 'traceroute google.com from New York --limit 2 --protocol tcp --port 80'; + const args = + 'traceroute google.com from New York --limit 2 --protocol tcp --port 80'; const result = buildPostMeasurements(argsToFlags(args)); - expect(result).toEqual([{ - type: 'traceroute', - target: 'google.com', - inProgressUpdates: false, - limit: 2, - locations: [{ magic: 'new york' }], - measurementOptions: { - protocol: 'TCP', - port: 80 - } - }]); + expect(result).toEqual([ + { + type: 'traceroute', + target: 'google.com', + inProgressUpdates: false, + limit: 2, + locations: [{ magic: 'New York' }], + measurementOptions: { + protocol: 'TCP', + port: 80, + }, + }, + ]); }); it('should throw if incorrect traceroute flag', () => { - const args = 'traceroute google.com from New York --limit 2 --protocol tcp --port 80 --packets 3'; - expect(() => buildPostMeasurements(argsToFlags(args))).toThrow('Invalid option "packets" for "traceroute"!\nExpected "protocol, port, target, from, limit, share".'); + const args = + 'traceroute google.com from New York --limit 2 --protocol tcp --port 80 --packets 3'; + expect(() => buildPostMeasurements(argsToFlags(args))).toThrow( + 'Invalid option "packets" for "traceroute"!\nExpected "protocol, port, target, from, limit, share".' + ); }); }); @@ -80,40 +95,48 @@ describe('Utils', () => { it('should parse dns args', () => { const args = 'dns google.com from New York'; const result = buildPostMeasurements(argsToFlags(args)); - expect(result).toEqual([{ - type: 'dns', - target: 'google.com', - inProgressUpdates: false, - limit: 1, - locations: [{ magic: 'new york' }], - measurementOptions: {} - }]); + expect(result).toEqual([ + { + type: 'dns', + target: 'google.com', + inProgressUpdates: false, + limit: 1, + locations: [{ magic: 'New York' }], + measurementOptions: {}, + }, + ]); }); it('should parse dns args with flags', () => { - const args = 'dns google.com from New York --limit 2 --query AAAA --protocol tcp --port 80 --resolver 1.1.1.1 --trace'; + const args = + 'dns google.com from New York --limit 2 --query AAAA --protocol tcp --port 80 --resolver 1.1.1.1 --trace'; const result = buildPostMeasurements(argsToFlags(args)); - expect(result).toEqual([{ - type: 'dns', - target: 'google.com', - inProgressUpdates: false, - limit: 2, - locations: [{ magic: 'new york' }], - measurementOptions: { - query: { - type: 'AAAA' + expect(result).toEqual([ + { + type: 'dns', + target: 'google.com', + inProgressUpdates: false, + limit: 2, + locations: [{ magic: 'New York' }], + measurementOptions: { + query: { + type: 'AAAA', + }, + protocol: 'TCP', + port: 80, + resolver: '1.1.1.1', + trace: true, }, - protocol: 'TCP', - port: 80, - resolver: '1.1.1.1', - trace: true, - } - }]); + }, + ]); }); it('should throw if incorrect dns flag', () => { - const args = 'dns google.com from New York --limit 2 --query AAAA --protocol tcp --port 80 --test'; - expect(() => buildPostMeasurements(argsToFlags(args))).toThrow('Invalid option "test" for "dns"!\nExpected "query, protocol, port, resolver, trace, latency, target, from, limit, share".'); + const args = + 'dns google.com from New York --limit 2 --query AAAA --protocol tcp --port 80 --test'; + expect(() => buildPostMeasurements(argsToFlags(args))).toThrow( + 'Invalid option "test" for "dns"!\nExpected "query, protocol, port, resolver, trace, latency, target, from, limit, share".' + ); }); }); @@ -121,36 +144,44 @@ describe('Utils', () => { it('should parse mtr args', () => { const args = 'mtr google.com from New York'; const result = buildPostMeasurements(argsToFlags(args)); - expect(result).toEqual([{ - type: 'mtr', - target: 'google.com', - inProgressUpdates: false, - limit: 1, - locations: [{ magic: 'new york' }], - measurementOptions: {} - }]); + expect(result).toEqual([ + { + type: 'mtr', + target: 'google.com', + inProgressUpdates: false, + limit: 1, + locations: [{ magic: 'New York' }], + measurementOptions: {}, + }, + ]); }); it('should parse mtr args with flags', () => { - const args = 'mtr google.com from New York --limit 2 --protocol tcp --port 80 --packets 16'; + const args = + 'mtr google.com from New York --limit 2 --protocol tcp --port 80 --packets 16'; const result = buildPostMeasurements(argsToFlags(args)); - expect(result).toEqual([{ - type: 'mtr', - target: 'google.com', - inProgressUpdates: false, - limit: 2, - locations: [{ magic: 'new york' }], - measurementOptions: { - protocol: 'TCP', - port: 80, - packets: 16 - } - }]); + expect(result).toEqual([ + { + type: 'mtr', + target: 'google.com', + inProgressUpdates: false, + limit: 2, + locations: [{ magic: 'New York' }], + measurementOptions: { + protocol: 'TCP', + port: 80, + packets: 16, + }, + }, + ]); }); it('should throw if incorrect mtr flag', () => { - const args = 'mtr google.com from New York --limit 2 --protocol tcp --port 80 --packets 16 --test'; - expect(() => buildPostMeasurements(argsToFlags(args))).toThrow('Invalid option "test" for "mtr"!\nExpected "protocol, port, packets, target, from, limit, share".'); + const args = + 'mtr google.com from New York --limit 2 --protocol tcp --port 80 --packets 16 --test'; + expect(() => buildPostMeasurements(argsToFlags(args))).toThrow( + 'Invalid option "test" for "mtr"!\nExpected "protocol, port, packets, target, from, limit, share".' + ); }); }); @@ -158,80 +189,91 @@ describe('Utils', () => { it('should parse http args', () => { const args = 'http google.com from New York'; const result = buildPostMeasurements(argsToFlags(args)); - expect(result).toEqual([{ - type: 'http', - target: 'google.com', - inProgressUpdates: false, - limit: 1, - locations: [{ magic: 'new york' }], - measurementOptions: { - protocol: 'HTTP', - request: { - host: 'google.com', - path: '/', - headers: {}, + expect(result).toEqual([ + { + type: 'http', + target: 'google.com', + inProgressUpdates: false, + limit: 1, + locations: [{ magic: 'New York' }], + measurementOptions: { + protocol: 'HTTP', + request: { + host: 'google.com', + path: '/', + headers: {}, + }, }, - } - }]); + }, + ]); }); it('should parse http args with flags', () => { - const args = 'http google.com from New York --limit 2 --path / --query ?a=abc --host google.com --method get --port 80 --protocol https --header "Content-Type: text/html; charset=utf-8" --header "Content-Encoding: gzip"'; + const args = + 'http google.com from New York --limit 2 --path / --query ?a=abc --host google.com --method get --port 80 --protocol https --header "Content-Type: text/html; charset=utf-8" --header "Content-Encoding: gzip"'; const result = buildPostMeasurements(argsToFlags(args)); - expect(result).toEqual([{ - type: 'http', - target: 'google.com', - inProgressUpdates: false, - limit: 2, - locations: [{ magic: 'new york' }], - measurementOptions: { - port: 80, - protocol: 'HTTPS', - request: { - path: '/', - query: '?a=abc', - method: 'GET', - host: 'google.com', - headers: { - 'Content-Encoding': 'gzip', - 'Content-Type': 'text/html; charset=utf-8' - } - } - } - }]); + expect(result).toEqual([ + { + type: 'http', + target: 'google.com', + inProgressUpdates: false, + limit: 2, + locations: [{ magic: 'New York' }], + measurementOptions: { + port: 80, + protocol: 'HTTPS', + request: { + path: '/', + query: '?a=abc', + method: 'GET', + host: 'google.com', + headers: { + 'Content-Encoding': 'gzip', + 'Content-Type': 'text/html; charset=utf-8', + }, + }, + }, + }, + ]); }); it('should infer url for http parse', () => { - const args = 'http https://google.com:80/test?a=abc from New York --limit 2 --method get --header "Content-Encoding: gzip" --header "Content-Type: text/html; charset=utf-8"'; + const args = + 'http https://google.com:80/test?a=abc from New York --limit 2 --method get --header "Content-Encoding: gzip" --header "Content-Type: text/html; charset=utf-8"'; const result = buildPostMeasurements(argsToFlags(args)); - expect(result).toEqual([{ - type: 'http', - target: 'google.com', - inProgressUpdates: false, - limit: 2, - locations: [{ magic: 'new york' }], - measurementOptions: { - port: 80, - protocol: 'HTTPS', - request: { - path: '/test', - query: 'a=abc', - method: 'GET', - host: 'google.com', - headers: { - 'Content-Encoding': 'gzip', - 'Content-Type': 'text/html; charset=utf-8' - } - } - } - }]); + expect(result).toEqual([ + { + type: 'http', + target: 'google.com', + inProgressUpdates: false, + limit: 2, + locations: [{ magic: 'New York' }], + measurementOptions: { + port: 80, + protocol: 'HTTPS', + request: { + path: '/test', + query: 'a=abc', + method: 'GET', + host: 'google.com', + headers: { + 'Content-Encoding': 'gzip', + 'Content-Type': 'text/html; charset=utf-8', + }, + }, + }, + }, + ]); }); it('should throw if incorrect http flag', () => { - const args = 'http google.com from New York --limit 2 --path / --query ?a=abc --host google.com --method get --port 80 --protocol https --header Content-Encoding: gzip --header Content-Type: text/html; charset=utf-8 --test'; - expect(() => buildPostMeasurements(argsToFlags(args))).toThrow('Invalid option "test" for "http"!\nExpected "protocol, port, resolver, method, path, query, host, header, latency, full, target, from, limit, share".'); + const args = + 'http google.com from New York --limit 2 --path / --query ?a=abc --host google.com --method get --port 80 --protocol https --header Content-Encoding: gzip --header Content-Type: text/html; charset=utf-8 --test'; + expect(() => buildPostMeasurements(argsToFlags(args))).toThrow( + 'Invalid option "test" for "http"!\nExpected "protocol, port, resolver, method, path, query, host, header, latency, full, target, from, limit, share".' + ); }); }); }); diff --git a/packages/bot-utils/tests/target-query.test.ts b/packages/bot-utils/tests/target-query.test.ts index e991e58..3b6c60a 100644 --- a/packages/bot-utils/tests/target-query.test.ts +++ b/packages/bot-utils/tests/target-query.test.ts @@ -1,94 +1,100 @@ import { describe, expect, it } from 'vitest'; -import { findAndRemoveResolver, parseTargetQuery, TargetQuery } from '../src/target-query'; +import { + findAndRemoveResolver, + parseTargetQuery, + TargetQuery, +} from '../src/target-query'; describe('Utils', () => { - describe('parseTargetQuery', () => { - it('simple', () => { - const cmd = 'ping'; - const args = ['example.com']; + describe('parseTargetQuery', () => { + it('simple', () => { + const cmd = 'ping'; + const args = ['example.com']; - const q: TargetQuery = parseTargetQuery(cmd, args); + const q: TargetQuery = parseTargetQuery(cmd, args); - expect(q.target).toEqual('example.com'); - expect(q.from).toEqual(undefined); - }); + expect(q.target).toEqual('example.com'); + expect(q.from).toEqual(undefined); + }); - it('simple with resolver', () => { - const cmd = 'dns'; - const args = ['example.com', '@1.1.1.1']; + it('simple with resolver', () => { + const cmd = 'dns'; + const args = ['example.com', '@1.1.1.1']; - const q: TargetQuery = parseTargetQuery(cmd, args); + const q: TargetQuery = parseTargetQuery(cmd, args); - expect(q.target).toEqual('example.com'); - expect(q.from).toEqual(undefined); - expect(q.resolver).toEqual('1.1.1.1'); - }); + expect(q.target).toEqual('example.com'); + expect(q.from).toEqual(undefined); + expect(q.resolver).toEqual('1.1.1.1'); + }); - it('resolver not allowed', () => { - const cmd = 'ping'; - const args = ['example.com', '@1.1.1.1']; + it('resolver not allowed', () => { + const cmd = 'ping'; + const args = ['example.com', '@1.1.1.1']; - expect(() => parseTargetQuery(cmd, args)).toThrowError('does not accept a resolver argument'); - }); + expect(() => parseTargetQuery(cmd, args)).toThrowError( + 'does not accept a resolver argument' + ); + }); - it('target from x', () => { - const cmd = 'ping'; - const args = ['example.com', 'from', 'London']; + it('target from x', () => { + const cmd = 'ping'; + const args = ['example.com', 'from', 'London']; - const q: TargetQuery = parseTargetQuery(cmd, args); + const q: TargetQuery = parseTargetQuery(cmd, args); - expect(q.target).toEqual('example.com'); - expect(q.from).toEqual('london'); - }); + expect(q.target).toEqual('example.com'); + expect(q.from).toEqual('London'); + }); - it('target from x with resolver', () => { - const cmd = 'http'; - const args = ['example.com', 'from', 'London', '@1.1.1.1']; + it('target from x with resolver', () => { + const cmd = 'http'; + const args = ['example.com', 'from', 'London', '@1.1.1.1']; - const q: TargetQuery = parseTargetQuery(cmd, args); + const q: TargetQuery = parseTargetQuery(cmd, args); - expect(q.target).toEqual('example.com'); - expect(q.from).toEqual('london'); - expect(q.resolver).toEqual('1.1.1.1'); - }); - }); + expect(q.target).toEqual('example.com'); + expect(q.from).toEqual('London'); + expect(q.resolver).toEqual('1.1.1.1'); + }); + }); - describe('findAndRemoveResolver', () => { - it('simple no resolver', () => { - const args = ['example.com']; + describe('findAndRemoveResolver', () => { + it('simple no resolver', () => { + const args = ['example.com']; - const [resolver, argsWithoutResolver] = findAndRemoveResolver(args); + const [resolver, argsWithoutResolver] = findAndRemoveResolver(args); - expect(resolver).toEqual(''); - expect(argsWithoutResolver).toEqual(args); - }); + expect(resolver).toEqual(''); + expect(argsWithoutResolver).toEqual(args); + }); - it('no resolver', () => { - const args = ['example.com', 'from', 'London']; + it('no resolver', () => { + const args = ['example.com', 'from', 'London']; - const [resolver, argsWithoutResolver] = findAndRemoveResolver(args); + const [resolver, argsWithoutResolver] = findAndRemoveResolver(args); - expect(resolver).toEqual(''); - expect(argsWithoutResolver).toEqual(args); - }); + expect(resolver).toEqual(''); + expect(argsWithoutResolver).toEqual(args); + }); - it('resolver and from', () => { - const args = ['example.com', '@1.1.1.1', 'from', 'London']; + it('resolver and from', () => { + const args = ['example.com', '@1.1.1.1', 'from', 'London']; - const [resolver, argsWithoutResolver] = findAndRemoveResolver(args); + const [resolver, argsWithoutResolver] = findAndRemoveResolver(args); - expect(resolver).toEqual('1.1.1.1'); - expect(argsWithoutResolver).toEqual(['example.com', 'from', 'London']); - }); + expect(resolver).toEqual('1.1.1.1'); + expect(argsWithoutResolver).toEqual(['example.com', 'from', 'London']); + }); - it('resolver only', () => { - const args = ['example.com', '@1.1.1.1']; + it('resolver only', () => { + const args = ['example.com', '@1.1.1.1']; - const [resolver, argsWithoutResolver] = findAndRemoveResolver(args); + const [resolver, argsWithoutResolver] = findAndRemoveResolver(args); - expect(resolver).toEqual('1.1.1.1'); - expect(argsWithoutResolver).toEqual(['example.com']); - }); - }); + expect(resolver).toEqual('1.1.1.1'); + expect(argsWithoutResolver).toEqual(['example.com']); + }); + }); });