source: trip-planner-front/node_modules/requires-port/test.js@ 571e0df

Last change on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.3 KB
RevLine 
[6a3a178]1describe('requires-port', function () {
2 'use strict';
3
4 var assume = require('assume')
5 , required = require('./');
6
7 it('is exported as a function', function () {
8 assume(required).is.a('function');
9 });
10
11 it('does not require empty ports', function () {
12 assume(required('', 'http')).false();
13 assume(required('', 'wss')).false();
14 assume(required('', 'ws')).false();
15 assume(required('', 'cowsack')).false();
16 });
17
18 it('assumes true for unknown protocols',function () {
19 assume(required('808', 'foo')).true();
20 assume(required('80', 'bar')).true();
21 });
22
23 it('never requires port numbers for file', function () {
24 assume(required(8080, 'file')).false();
25 });
26
27 it('does not require port 80 for http', function () {
28 assume(required('80', 'http')).false();
29 assume(required(80, 'http')).false();
30 assume(required(80, 'http://')).false();
31 assume(required(80, 'http://www.google.com')).false();
32
33 assume(required('8080', 'http')).true();
34 assume(required(8080, 'http')).true();
35 assume(required(8080, 'http://')).true();
36 assume(required(8080, 'http://www.google.com')).true();
37 });
38
39 it('does not require port 80 for ws', function () {
40 assume(required('80', 'ws')).false();
41 assume(required(80, 'ws')).false();
42 assume(required(80, 'ws://')).false();
43 assume(required(80, 'ws://www.google.com')).false();
44
45 assume(required('8080', 'ws')).true();
46 assume(required(8080, 'ws')).true();
47 assume(required(8080, 'ws://')).true();
48 assume(required(8080, 'ws://www.google.com')).true();
49 });
50
51 it('does not require port 443 for https', function () {
52 assume(required('443', 'https')).false();
53 assume(required(443, 'https')).false();
54 assume(required(443, 'https://')).false();
55 assume(required(443, 'https://www.google.com')).false();
56
57 assume(required('8080', 'https')).true();
58 assume(required(8080, 'https')).true();
59 assume(required(8080, 'https://')).true();
60 assume(required(8080, 'https://www.google.com')).true();
61 });
62
63 it('does not require port 443 for wss', function () {
64 assume(required('443', 'wss')).false();
65 assume(required(443, 'wss')).false();
66 assume(required(443, 'wss://')).false();
67 assume(required(443, 'wss://www.google.com')).false();
68
69 assume(required('8080', 'wss')).true();
70 assume(required(8080, 'wss')).true();
71 assume(required(8080, 'wss://')).true();
72 assume(required(8080, 'wss://www.google.com')).true();
73 });
74
75 it('does not require port 21 for ftp', function () {
76 assume(required('21', 'ftp')).false();
77 assume(required(21, 'ftp')).false();
78 assume(required(21, 'ftp://')).false();
79 assume(required(21, 'ftp://www.google.com')).false();
80
81 assume(required('8080', 'ftp')).true();
82 assume(required(8080, 'ftp')).true();
83 assume(required(8080, 'ftp://')).true();
84 assume(required(8080, 'ftp://www.google.com')).true();
85 });
86
87 it('does not require port 70 for gopher', function () {
88 assume(required('70', 'gopher')).false();
89 assume(required(70, 'gopher')).false();
90 assume(required(70, 'gopher://')).false();
91 assume(required(70, 'gopher://www.google.com')).false();
92
93 assume(required('8080', 'gopher')).true();
94 assume(required(8080, 'gopher')).true();
95 assume(required(8080, 'gopher://')).true();
96 assume(required(8080, 'gopher://www.google.com')).true();
97 });
98});
Note: See TracBrowser for help on using the repository browser.