Start tests

orm-types
Garrett Mills 2 years ago
parent d251f8bc15
commit bd7d6a2dbd

@ -47,7 +47,7 @@
"uuid": "^8.3.2"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"test": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'tests/**/*.ts'",
"build": "pnpm run lint && rimraf lib && tsc && fse copy --all --dereference --preserveTimestamps --keepExisting=false --quiet --errorOnExist=false src/resources lib/resources",
"app": "tsc && node lib/index.js",
"prepare": "pnpm run build",
@ -67,9 +67,15 @@
"author": "garrettmills <shout@garrettmills.dev>",
"license": "MIT",
"devDependencies": {
"@types/chai": "^4.2.22",
"@types/mocha": "^9.0.0",
"@types/sinon": "^10.0.6",
"@typescript-eslint/eslint-plugin": "^4.26.0",
"@typescript-eslint/parser": "^4.26.0",
"eslint": "^7.27.0"
"chai": "^4.3.4",
"eslint": "^7.27.0",
"mocha": "^9.1.3",
"sinon": "^12.0.1"
},
"extollo": {
"discover": true,

@ -4,22 +4,26 @@ specifiers:
'@atao60/fse-cli': ^0.1.6
'@types/bcrypt': ^5.0.0
'@types/busboy': ^0.2.3
'@types/chai': ^4.2.22
'@types/cli-table': ^0.3.0
'@types/ioredis': ^4.26.6
'@types/mime-types': ^2.1.0
'@types/mkdirp': ^1.0.1
'@types/mocha': ^9.0.0
'@types/negotiator': ^0.6.1
'@types/node': ^14.17.4
'@types/pg': ^8.6.0
'@types/pluralize': ^0.0.29
'@types/pug': ^2.0.4
'@types/rimraf': ^3.0.0
'@types/sinon': ^10.0.6
'@types/ssh2': ^0.5.46
'@types/uuid': ^8.3.0
'@typescript-eslint/eslint-plugin': ^4.26.0
'@typescript-eslint/parser': ^4.26.0
bcrypt: ^5.0.1
busboy: ^0.3.1
chai: ^4.3.4
cli-table: ^0.3.6
colors: ^1.4.0
dotenv: ^8.2.0
@ -27,6 +31,7 @@ specifiers:
ioredis: ^4.27.6
mime-types: ^2.1.31
mkdirp: ^1.0.4
mocha: ^9.1.3
negotiator: ^0.6.2
node-fetch: ^3
pg: ^8.6.0
@ -34,6 +39,7 @@ specifiers:
pug: ^3.0.2
reflect-metadata: ^0.1.13
rimraf: ^3.0.2
sinon: ^12.0.1
ssh2: ^1.1.0
ts-node: ^9.1.1
typedoc: ^0.20.36
@ -82,9 +88,15 @@ dependencies:
uuid: 8.3.2
devDependencies:
'@types/chai': 4.2.22
'@types/mocha': 9.0.0
'@types/sinon': 10.0.6
'@typescript-eslint/eslint-plugin': 4.26.0_942c48837be95e76bb4156c78358cdbe
'@typescript-eslint/parser': 4.26.0_eslint@7.27.0+typescript@4.2.3
chai: 4.3.4
eslint: 7.27.0
mocha: 9.1.3
sinon: 12.0.1
packages:
@ -204,6 +216,36 @@ packages:
fastq: 1.11.0
dev: true
/@sinonjs/commons/1.8.3:
resolution: {integrity: sha512-xkNcLAn/wZaX14RPlwizcKicDk9G3F8m2nU3L7Ukm5zBgTwiT0wsoFAHx9Jq56fJA1z/7uKGtCRu16sOUCLIHQ==}
dependencies:
type-detect: 4.0.8
dev: true
/@sinonjs/fake-timers/7.1.2:
resolution: {integrity: sha512-iQADsW4LBMISqZ6Ci1dupJL9pprqwcVFTcOsEmQOEhW+KLCVn/Y4Jrvg2k19fIHCp+iFprriYPTdRcQR8NbUPg==}
dependencies:
'@sinonjs/commons': 1.8.3
dev: true
/@sinonjs/fake-timers/8.1.0:
resolution: {integrity: sha512-OAPJUAtgeINhh/TAlUID4QTs53Njm7xzddaVlEs/SXwgtiD1tW22zAB/W1wdqfrpmikgaWQ9Fw6Ws+hsiRm5Vg==}
dependencies:
'@sinonjs/commons': 1.8.3
dev: true
/@sinonjs/samsam/6.0.2:
resolution: {integrity: sha512-jxPRPp9n93ci7b8hMfJOFDPRLFYadN6FSpeROFTR4UNF4i5b+EK6m4QXPO46BDhFgRy1JuS87zAnFOzCUwMJcQ==}
dependencies:
'@sinonjs/commons': 1.8.3
lodash.get: 4.4.2
type-detect: 4.0.8
dev: true
/@sinonjs/text-encoding/0.7.1:
resolution: {integrity: sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==}
dev: true
/@types/bcrypt/5.0.0:
resolution: {integrity: sha512-agtcFKaruL8TmcvqbndlqHPSJgsolhf/qPWchFlgnW1gECTN/nKbFcoFnvKAQRFfKbh+BO6A3SWdJu9t+xF3Lw==}
dependencies:
@ -216,6 +258,10 @@ packages:
'@types/node': 14.14.37
dev: false
/@types/chai/4.2.22:
resolution: {integrity: sha512-tFfcE+DSTzWAgifkjik9AySNqIyNoYwmR+uecPwwD/XRNfvOjmC/FjCxpiUGDkDVDphPfCUecSQVFw+lN3M3kQ==}
dev: true
/@types/cli-table/0.3.0:
resolution: {integrity: sha512-QnZUISJJXyhyD6L1e5QwXDV/A5i2W1/gl6D6YMc8u0ncPepbv/B4w3S+izVvtAg60m6h+JP09+Y/0zF2mojlFQ==}
dev: false
@ -251,6 +297,10 @@ packages:
'@types/node': 14.17.1
dev: false
/@types/mocha/9.0.0:
resolution: {integrity: sha512-scN0hAWyLVAvLR9AyW7HoFF5sJZglyBsbPuHO4fv7JRvfmPBMfp1ozWqOf/e4wwPNxezBZXRfWzMb6iFLgEVRA==}
dev: true
/@types/negotiator/0.6.1:
resolution: {integrity: sha512-c4mvXFByghezQ/eVGN5HvH/jI63vm3B7FiE81BUzDAWmuiohRecCO6ddU60dfq29oKUMiQujsoB2h0JQC7JHKA==}
dev: false
@ -298,6 +348,12 @@ packages:
'@types/node': 14.17.1
dev: false
/@types/sinon/10.0.6:
resolution: {integrity: sha512-6EF+wzMWvBNeGrfP3Nx60hhx+FfwSg1JJBLAAP/IdIUq0EYkqCYf70VT3PhuhPX9eLD+Dp+lNdpb/ZeHG8Yezg==}
dependencies:
'@sinonjs/fake-timers': 7.1.2
dev: true
/@types/ssh2-streams/0.1.8:
resolution: {integrity: sha512-I7gixRPUvVIyJuCEvnmhr3KvA2dC0639kKswqD4H5b4/FOcnPtNU+qWLiXdKIqqX9twUvi5j0U1mwKE5CUsrfA==}
dependencies:
@ -421,6 +477,10 @@ packages:
eslint-visitor-keys: 2.1.0
dev: true
/@ungap/promise-all-settled/1.1.2:
resolution: {integrity: sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==}
dev: true
/abbrev/1.1.1:
resolution: {integrity: sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==}
dev: false
@ -506,6 +566,14 @@ packages:
dependencies:
color-convert: 2.0.1
/anymatch/3.1.2:
resolution: {integrity: sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==}
engines: {node: '>= 8'}
dependencies:
normalize-path: 3.0.0
picomatch: 2.3.0
dev: true
/aproba/1.2.0:
resolution: {integrity: sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==}
dev: false
@ -531,6 +599,10 @@ packages:
sprintf-js: 1.0.3
dev: true
/argparse/2.0.1:
resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==}
dev: true
/array-union/2.1.0:
resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==}
engines: {node: '>=8'}
@ -550,6 +622,10 @@ packages:
resolution: {integrity: sha512-TaTivMB6pYI1kXwrFlEhLeGfOqoDNdTxjCdwRfFFkEA30Eu+k48W34nlok2EYWJfFFzqaEmichdNM7th6M5HNw==}
dev: false
/assertion-error/1.1.0:
resolution: {integrity: sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==}
dev: true
/astral-regex/2.0.0:
resolution: {integrity: sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==}
engines: {node: '>=8'}
@ -591,6 +667,11 @@ packages:
- supports-color
dev: false
/binary-extensions/2.2.0:
resolution: {integrity: sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==}
engines: {node: '>=8'}
dev: true
/bl/4.1.0:
resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==}
dependencies:
@ -612,6 +693,10 @@ packages:
fill-range: 7.0.1
dev: true
/browser-stdout/1.3.1:
resolution: {integrity: sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==}
dev: true
/buffer-from/1.1.1:
resolution: {integrity: sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==}
dev: false
@ -647,6 +732,23 @@ packages:
engines: {node: '>=6'}
dev: true
/camelcase/6.2.1:
resolution: {integrity: sha512-tVI4q5jjFV5CavAU8DXfza/TJcZutVKo/5Foskmsqcm0MsL91moHvwiGNnqaa2o6PF/7yT5ikDRcVcl8Rj6LCA==}
engines: {node: '>=10'}
dev: true
/chai/4.3.4:
resolution: {integrity: sha512-yS5H68VYOCtN1cjfwumDSuzn/9c+yza4f3reKXlE5rUg7SFcCEy90gJvydNgOYtblyf4Zi6jIWRnXOgErta0KA==}
engines: {node: '>=4'}
dependencies:
assertion-error: 1.1.0
check-error: 1.0.2
deep-eql: 3.0.1
get-func-name: 2.0.0
pathval: 1.1.1
type-detect: 4.0.8
dev: true
/chalk/2.4.2:
resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==}
engines: {node: '>=4'}
@ -673,6 +775,25 @@ packages:
resolution: {integrity: sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==}
dev: false
/check-error/1.0.2:
resolution: {integrity: sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=}
dev: true
/chokidar/3.5.2:
resolution: {integrity: sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==}
engines: {node: '>= 8.10.0'}
dependencies:
anymatch: 3.1.2
braces: 3.0.2
glob-parent: 5.1.2
is-binary-path: 2.1.0
is-glob: 4.0.1
normalize-path: 3.0.0
readdirp: 3.6.0
optionalDependencies:
fsevents: 2.3.2
dev: true
/chownr/2.0.0:
resolution: {integrity: sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==}
engines: {node: '>=10'}
@ -702,6 +823,14 @@ packages:
engines: {node: '>= 10'}
dev: false
/cliui/7.0.4:
resolution: {integrity: sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==}
dependencies:
string-width: 4.2.2
strip-ansi: 6.0.0
wrap-ansi: 7.0.0
dev: true
/clone/1.0.4:
resolution: {integrity: sha1-2jCcwmPfFZlMaIypAheco8fNfH4=}
engines: {node: '>=0.8'}
@ -823,6 +952,31 @@ packages:
ms: 2.1.2
dev: false
/debug/4.3.2_supports-color@8.1.1:
resolution: {integrity: sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==}
engines: {node: '>=6.0'}
peerDependencies:
supports-color: '*'
peerDependenciesMeta:
supports-color:
optional: true
dependencies:
ms: 2.1.2
supports-color: 8.1.1
dev: true
/decamelize/4.0.0:
resolution: {integrity: sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==}
engines: {node: '>=10'}
dev: true
/deep-eql/3.0.1:
resolution: {integrity: sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==}
engines: {node: '>=0.12'}
dependencies:
type-detect: 4.0.8
dev: true
/deep-is/0.1.3:
resolution: {integrity: sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=}
dev: true
@ -860,6 +1014,11 @@ packages:
engines: {node: '>=0.3.1'}
dev: false
/diff/5.0.0:
resolution: {integrity: sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==}
engines: {node: '>=0.3.1'}
dev: true
/dir-glob/3.0.1:
resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==}
engines: {node: '>=8'}
@ -893,6 +1052,11 @@ packages:
ansi-colors: 4.1.1
dev: true
/escalade/3.1.1:
resolution: {integrity: sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==}
engines: {node: '>=6'}
dev: true
/escape-string-regexp/1.0.5:
resolution: {integrity: sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=}
engines: {node: '>=0.8.0'}
@ -1096,6 +1260,14 @@ packages:
to-regex-range: 5.0.1
dev: true
/find-up/5.0.0:
resolution: {integrity: sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==}
engines: {node: '>=10'}
dependencies:
locate-path: 6.0.0
path-exists: 4.0.0
dev: true
/flat-cache/3.0.4:
resolution: {integrity: sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==}
engines: {node: ^10.12.0 || >=12.0.0}
@ -1104,6 +1276,11 @@ packages:
rimraf: 3.0.2
dev: true
/flat/5.0.2:
resolution: {integrity: sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==}
hasBin: true
dev: true
/flatted/3.1.1:
resolution: {integrity: sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA==}
dev: true
@ -1137,6 +1314,14 @@ packages:
/fs.realpath/1.0.0:
resolution: {integrity: sha1-FQStJSMVjKpA20onh8sBQRmU6k8=}
/fsevents/2.3.2:
resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==}
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
os: [darwin]
requiresBuild: true
dev: true
optional: true
/function-bind/1.1.1:
resolution: {integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==}
dev: false
@ -1158,6 +1343,15 @@ packages:
wide-align: 1.1.3
dev: false
/get-caller-file/2.0.5:
resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==}
engines: {node: 6.* || 8.* || >= 10.*}
dev: true
/get-func-name/2.0.0:
resolution: {integrity: sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=}
dev: true
/get-intrinsic/1.1.1:
resolution: {integrity: sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==}
dependencies:
@ -1213,6 +1407,11 @@ packages:
resolution: {integrity: sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==}
dev: false
/growl/1.10.5:
resolution: {integrity: sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==}
engines: {node: '>=4.x'}
dev: true
/handlebars/4.7.7:
resolution: {integrity: sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==}
engines: {node: '>=0.4.7'}
@ -1251,6 +1450,11 @@ packages:
function-bind: 1.1.1
dev: false
/he/1.2.0:
resolution: {integrity: sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==}
hasBin: true
dev: true
/https-proxy-agent/5.0.0:
resolution: {integrity: sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==}
engines: {node: '>= 6'}
@ -1347,6 +1551,13 @@ packages:
- supports-color
dev: false
/is-binary-path/2.1.0:
resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==}
engines: {node: '>=8'}
dependencies:
binary-extensions: 2.2.0
dev: true
/is-core-module/2.4.0:
resolution: {integrity: sha512-6A2fkfq1rfeQZjxrZJGerpLCTHRNEBiSgnu0+obeJpEPZRUooHgsizvzv0ZjJwOz3iWIHdJtVWJ/tmPr3D21/A==}
dependencies:
@ -1393,6 +1604,11 @@ packages:
engines: {node: '>=0.12.0'}
dev: true
/is-plain-obj/2.1.0:
resolution: {integrity: sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==}
engines: {node: '>=8'}
dev: true
/is-promise/2.2.2:
resolution: {integrity: sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ==}
dev: false
@ -1408,7 +1624,10 @@ packages:
/is-unicode-supported/0.1.0:
resolution: {integrity: sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==}
engines: {node: '>=10'}
dev: false
/isarray/0.0.1:
resolution: {integrity: sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=}
dev: true
/isarray/1.0.0:
resolution: {integrity: sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=}
@ -1434,6 +1653,13 @@ packages:
esprima: 4.0.1
dev: true
/js-yaml/4.1.0:
resolution: {integrity: sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==}
hasBin: true
dependencies:
argparse: 2.0.1
dev: true
/json-schema-traverse/0.4.1:
resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==}
dev: true
@ -1461,6 +1687,10 @@ packages:
promise: 7.3.1
dev: false
/just-extend/4.2.1:
resolution: {integrity: sha512-g3UB796vUFIY90VIv/WX3L2c8CS2MdWUww3CNrYmqza1Fg0DURc2K/O4YrnklBdQarSJ/y8JnJYDGc+1iumQjg==}
dev: true
/levn/0.4.1:
resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==}
engines: {node: '>= 0.8.0'}
@ -1469,6 +1699,13 @@ packages:
type-check: 0.4.0
dev: true
/locate-path/6.0.0:
resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==}
engines: {node: '>=10'}
dependencies:
p-locate: 5.0.0
dev: true
/lodash.clonedeep/4.5.0:
resolution: {integrity: sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=}
dev: true
@ -1481,6 +1718,10 @@ packages:
resolution: {integrity: sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=}
dev: false
/lodash.get/4.4.2:
resolution: {integrity: sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=}
dev: true
/lodash.merge/4.6.2:
resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==}
dev: true
@ -1498,7 +1739,6 @@ packages:
dependencies:
chalk: 4.1.1
is-unicode-supported: 0.1.0
dev: false
/lru-cache/5.1.1:
resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==}
@ -1593,9 +1833,44 @@ packages:
hasBin: true
dev: false
/mocha/9.1.3:
resolution: {integrity: sha512-Xcpl9FqXOAYqI3j79pEtHBBnQgVXIhpULjGQa7DVb0Po+VzmSIK9kanAiWLHoRR/dbZ2qpdPshuXr8l1VaHCzw==}
engines: {node: '>= 12.0.0'}
hasBin: true
dependencies:
'@ungap/promise-all-settled': 1.1.2
ansi-colors: 4.1.1
browser-stdout: 1.3.1
chokidar: 3.5.2
debug: 4.3.2_supports-color@8.1.1
diff: 5.0.0
escape-string-regexp: 4.0.0
find-up: 5.0.0
glob: 7.1.7
growl: 1.10.5
he: 1.2.0
js-yaml: 4.1.0
log-symbols: 4.1.0
minimatch: 3.0.4
ms: 2.1.3
nanoid: 3.1.25
serialize-javascript: 6.0.0
strip-json-comments: 3.1.1
supports-color: 8.1.1
which: 2.0.2
workerpool: 6.1.5
yargs: 16.2.0
yargs-parser: 20.2.4
yargs-unparser: 2.0.0
dev: true
/ms/2.1.2:
resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==}
/ms/2.1.3:
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
dev: true
/mute-stream/0.0.8:
resolution: {integrity: sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==}
dev: false
@ -1605,6 +1880,12 @@ packages:
dev: false
optional: true
/nanoid/3.1.25:
resolution: {integrity: sha512-rdwtIXaXCLFAQbnfqDRnI6jaRHp9fTcYBjtFKE8eezcZ7LuLjhUaQGNeMXf1HmRoCH32CLz6XwX0TtxEOS/A3Q==}
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
hasBin: true
dev: true
/natural-compare/1.4.0:
resolution: {integrity: sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=}
dev: true
@ -1618,6 +1899,16 @@ packages:
resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==}
dev: false
/nise/5.1.0:
resolution: {integrity: sha512-W5WlHu+wvo3PaKLsJJkgPup2LrsXCcm7AWwyNZkUnn5rwPkuPBi3Iwk5SQtN0mv+K65k7nKKjwNQ30wg3wLAQQ==}
dependencies:
'@sinonjs/commons': 1.8.3
'@sinonjs/fake-timers': 7.1.2
'@sinonjs/text-encoding': 0.7.1
just-extend: 4.2.1
path-to-regexp: 1.8.0
dev: true
/node-addon-api/3.2.1:
resolution: {integrity: sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A==}
dev: false
@ -1643,6 +1934,11 @@ packages:
abbrev: 1.1.1
dev: false
/normalize-path/3.0.0:
resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==}
engines: {node: '>=0.10.0'}
dev: true
/npmlog/4.1.2:
resolution: {integrity: sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==}
dependencies:
@ -1712,6 +2008,20 @@ packages:
engines: {node: '>=0.10.0'}
dev: false
/p-limit/3.1.0:
resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==}
engines: {node: '>=10'}
dependencies:
yocto-queue: 0.1.0
dev: true
/p-locate/5.0.0:
resolution: {integrity: sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==}
engines: {node: '>=10'}
dependencies:
p-limit: 3.1.0
dev: true
/p-map/2.1.0:
resolution: {integrity: sha512-y3b8Kpd8OAN444hxfBbFfj1FY/RjtTd8tzYwhUqNYXx0fXx2iX4maP4Qr6qhIKbQXI02wTLAda4fYUbDagTUFw==}
engines: {node: '>=6'}
@ -1728,6 +2038,11 @@ packages:
callsites: 3.1.0
dev: true
/path-exists/4.0.0:
resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==}
engines: {node: '>=8'}
dev: true
/path-is-absolute/1.0.1:
resolution: {integrity: sha1-F0uSaHNVNP+8es5r9TpanhtcX18=}
engines: {node: '>=0.10.0'}
@ -1741,11 +2056,21 @@ packages:
resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==}
dev: false
/path-to-regexp/1.8.0:
resolution: {integrity: sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==}
dependencies:
isarray: 0.0.1
dev: true
/path-type/4.0.0:
resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==}
engines: {node: '>=8'}
dev: true
/pathval/1.1.1:
resolution: {integrity: sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==}
dev: true
/pg-connection-string/2.5.0:
resolution: {integrity: sha512-r5o/V/ORTA6TmUnyWZR9nCj1klXCO2CEKNRlVuJptZe85QuhFayC7WeMic7ndayT5IRIR0S0xFxFi2ousartlQ==}
dev: false
@ -1953,6 +2278,12 @@ packages:
resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==}
dev: true
/randombytes/2.1.0:
resolution: {integrity: sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==}
dependencies:
safe-buffer: 5.2.1
dev: true
/readable-stream/2.3.7:
resolution: {integrity: sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==}
dependencies:
@ -1974,6 +2305,13 @@ packages:
util-deprecate: 1.0.2
dev: false
/readdirp/3.6.0:
resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==}
engines: {node: '>=8.10.0'}
dependencies:
picomatch: 2.3.0
dev: true
/rechoir/0.6.2:
resolution: {integrity: sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=}
engines: {node: '>= 0.10'}
@ -2010,6 +2348,11 @@ packages:
engines: {node: '>=8'}
dev: true
/require-directory/2.1.1:
resolution: {integrity: sha1-jGStX9MNqxyXbiNE/+f3kqam30I=}
engines: {node: '>=0.10.0'}
dev: true
/require-from-string/2.0.2:
resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==}
engines: {node: '>=0.10.0'}
@ -2070,7 +2413,6 @@ packages:
/safe-buffer/5.2.1:
resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==}
dev: false
/safer-buffer/2.1.2:
resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==}
@ -2088,6 +2430,12 @@ packages:
dependencies:
lru-cache: 6.0.0
/serialize-javascript/6.0.0:
resolution: {integrity: sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==}
dependencies:
randombytes: 2.1.0
dev: true
/set-blocking/2.0.0:
resolution: {integrity: sha1-BF+XgtARrppoA93TgrJDkrPYkPc=}
dev: false
@ -2125,6 +2473,17 @@ packages:
resolution: {integrity: sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==}
dev: false
/sinon/12.0.1:
resolution: {integrity: sha512-iGu29Xhym33ydkAT+aNQFBINakjq69kKO6ByPvTsm3yyIACfyQttRTP03aBP/I8GfhFmLzrnKwNNkr0ORb1udg==}
dependencies:
'@sinonjs/commons': 1.8.3
'@sinonjs/fake-timers': 8.1.0
'@sinonjs/samsam': 6.0.2
diff: 5.0.0
nise: 5.1.0
supports-color: 7.2.0
dev: true
/slash/3.0.0:
resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==}
engines: {node: '>=8'}
@ -2242,6 +2601,13 @@ packages:
dependencies:
has-flag: 4.0.0
/supports-color/8.1.1:
resolution: {integrity: sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==}
engines: {node: '>=10'}
dependencies:
has-flag: 4.0.0
dev: true
/supports-hyperlinks/2.2.0:
resolution: {integrity: sha512-6sXEzV5+I5j8Bmq9/vUphGRM/RJNT9SCURJLjwfOg51heRtguGWDzcaBlgAzKhQa0EVNpPEKzQuBwZ8S8WaCeQ==}
engines: {node: '>=8'}
@ -2357,6 +2723,11 @@ packages:
prelude-ls: 1.2.1
dev: true
/type-detect/4.0.8:
resolution: {integrity: sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==}
engines: {node: '>=4'}
dev: true
/type-fest/0.20.2:
resolution: {integrity: sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==}
engines: {node: '>=10'}
@ -2516,6 +2887,19 @@ packages:
resolution: {integrity: sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=}
dev: false
/workerpool/6.1.5:
resolution: {integrity: sha512-XdKkCK0Zqc6w3iTxLckiuJ81tiD/o5rBE/m+nXpRCB+/Sq4DqkfXZ/x0jW02DG1tGsfUGXbTJyZDP+eu67haSw==}
dev: true
/wrap-ansi/7.0.0:
resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==}
engines: {node: '>=10'}
dependencies:
ansi-styles: 4.3.0
string-width: 4.2.2
strip-ansi: 6.0.0
dev: true
/wrappy/1.0.2:
resolution: {integrity: sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=}
@ -2524,6 +2908,11 @@ packages:
engines: {node: '>=0.4'}
dev: false
/y18n/5.0.8:
resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==}
engines: {node: '>=10'}
dev: true
/yallist/3.1.1:
resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==}
dev: false
@ -2531,7 +2920,40 @@ packages:
/yallist/4.0.0:
resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==}
/yargs-parser/20.2.4:
resolution: {integrity: sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==}
engines: {node: '>=10'}
dev: true
/yargs-unparser/2.0.0:
resolution: {integrity: sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==}
engines: {node: '>=10'}
dependencies:
camelcase: 6.2.1
decamelize: 4.0.0
flat: 5.0.2
is-plain-obj: 2.1.0
dev: true
/yargs/16.2.0:
resolution: {integrity: sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==}
engines: {node: '>=10'}
dependencies:
cliui: 7.0.4
escalade: 3.1.1
get-caller-file: 2.0.5
require-directory: 2.1.1
string-width: 4.2.2
y18n: 5.0.8
yargs-parser: 20.2.4
dev: true
/yn/3.1.1:
resolution: {integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==}
engines: {node: '>=6'}
dev: false
/yocto-queue/0.1.0:
resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==}
engines: {node: '>=10'}
dev: true

@ -0,0 +1,249 @@
import { expect } from 'chai'
import * as sinon from 'sinon'
import { Pipe, AsyncPipe } from '../../../lib'
describe('util -> support -> Pipe', () => {
describe('static.wrap', () => {
it('should return a Pipe containing the input value', () => {
const sym = Symbol()
const pipe = Pipe.wrap(sym)
expect(pipe).to.be.an.instanceof(Pipe)
expect(pipe.get()).to.be.equal(sym)
})
})
describe('constructor', () => {
it('should instantiate a Pipe with the input value', () => {
const sym = Symbol()
const pipe = new Pipe(sym)
expect(pipe).to.be.an.instanceof(Pipe)
expect(pipe.get()).to.be.equal(sym)
})
})
describe('tap', () => {
const pipe = Pipe.wrap(123)
it('should call the input operator with the value of the pipe', () => {
const spy = sinon.spy()
pipe.tap(spy)
expect(spy.callCount).to.be.equal(1)
expect(spy.firstCall.firstArg).to.be.equal(123)
})
it('should return a new Pipe', () => {
const ret = pipe.tap(x => x)
expect(ret).to.be.an.instanceof(Pipe)
expect(ret).to.not.be.equal(pipe)
})
it('should return the operator value in the new pipe', () => {
const ret = pipe.tap(() => 456)
expect(ret.get()).to.be.equal(456)
})
it('should not modify the base pipe', () => {
pipe.tap(() => false)
expect(pipe.get()).to.be.equal(123)
})
})
describe('peek', () => {
const pipe = Pipe.wrap(123)
it('should call the input operator with the value of the pipe', () => {
const spy = sinon.spy()
pipe.peek(spy)
expect(spy.callCount).to.be.equal(1)
expect(spy.firstCall.firstArg).to.be.equal(123)
})
it('should return the same pipe', () => {
const ret = pipe.peek(x => x)
expect(ret).to.be.eql(pipe)
})
it('should not modify the base pipe', () => {
pipe.peek(() => false)
expect(pipe.get()).to.be.equal(123)
})
})
describe('when', () => {
const pipe = Pipe.wrap(123)
describe('condition is true', () => {
it('should call the input operator with the value of the pipe', () => {
const spy = sinon.spy()
pipe.when(true, spy)
expect(spy.callCount).to.be.equal(1)
expect(spy.firstCall.firstArg).to.be.equal(123)
})
it('should return a new Pipe', () => {
const ret = pipe.when(true, x => x)
expect(ret).to.be.an.instanceof(Pipe)
expect(ret).to.not.be.equal(pipe)
})
it('should return the operator value in the new pipe', () => {
const ret = pipe.when(true, () => 456)
expect(ret.get()).to.be.equal(456)
})
it('should not modify the base pipe', () => {
pipe.when(true, () => 456)
expect(pipe.get()).to.be.equal(123)
})
})
describe('condition evaluates to true', () => {
it('should call the input operator with the value of the pipe', () => {
const spy = sinon.spy()
pipe.when(() => true, spy)
expect(spy.callCount).to.be.equal(1)
expect(spy.firstCall.firstArg).to.be.equal(123)
})
it('should return a new Pipe', () => {
const ret = pipe.when(() => true, x => x)
expect(ret).to.be.an.instanceof(Pipe)
expect(ret).to.not.be.equal(pipe)
})
it('should return the operator value in the new pipe', () => {
const ret = pipe.when(() => true, () => 456)
expect(ret.get()).to.be.equal(456)
})
it('should not modify the base pipe', () => {
pipe.when(() => true, () => 456)
expect(pipe.get()).to.be.equal(123)
})
})
describe('condition is false', () => {
it('should not call the input operator with the value of the pipe', () => {
const spy = sinon.spy()
pipe.when(false, spy)
expect(spy.callCount).to.be.equal(0)
})
it('should return the same Pipe', () => {
const ret = pipe.when(false, x => x)
expect(ret).to.be.equal(pipe)
})
})
describe('condition evaluates to false', () => {
it('should not call the input operator with the value of the pipe', () => {
const spy = sinon.spy()
pipe.when(() => false, spy)
expect(spy.callCount).to.be.equal(0)
})
it('should return the same Pipe', () => {
const ret = pipe.when(() => false, x => x)
expect(ret).to.be.equal(pipe)
})
})
})
describe('unless', () => {
const pipe = Pipe.wrap(123)
describe('condition is false', () => {
it('should call the input operator with the value of the pipe', () => {
const spy = sinon.spy()
pipe.unless(false, spy)
expect(spy.callCount).to.be.equal(1)
expect(spy.firstCall.firstArg).to.be.equal(123)
})
it('should return a new Pipe', () => {
const ret = pipe.unless(false, x => x)
expect(ret).to.be.an.instanceof(Pipe)
expect(ret).to.not.be.equal(pipe)
})
it('should return the operator value in the new pipe', () => {
const ret = pipe.unless(false, () => 456)
expect(ret.get()).to.be.equal(456)
})
it('should not modify the base pipe', () => {
pipe.unless(false, () => 456)
expect(pipe.get()).to.be.equal(123)
})
})
describe('condition evaluates to false', () => {
it('should call the input operator with the value of the pipe', () => {
const spy = sinon.spy()
pipe.unless(() => false, spy)
expect(spy.callCount).to.be.equal(1)
expect(spy.firstCall.firstArg).to.be.equal(123)
})
it('should return a new Pipe', () => {
const ret = pipe.unless(() => false, x => x)
expect(ret).to.be.an.instanceof(Pipe)
expect(ret).to.not.be.equal(pipe)
})
it('should return the operator value in the new pipe', () => {
const ret = pipe.unless(() => false, () => 456)
expect(ret.get()).to.be.equal(456)
})
it('should not modify the base pipe', () => {
pipe.unless(() => false, () => 456)
expect(pipe.get()).to.be.equal(123)
})
})
describe('condition is true', () => {
it('should not call the input operator with the value of the pipe', () => {
const spy = sinon.spy()
pipe.unless(true, spy)
expect(spy.callCount).to.be.equal(0)
})
it('should return the same Pipe', () => {
const ret = pipe.unless(true, x => x)
expect(ret).to.be.equal(pipe)
})
})
describe('condition evaluates to true', () => {
it('should not call the input operator with the value of the pipe', () => {
const spy = sinon.spy()
pipe.unless(() => true, spy)
expect(spy.callCount).to.be.equal(0)
})
it('should return the same Pipe', () => {
const ret = pipe.unless(() => true, x => x)
expect(ret).to.be.equal(pipe)
})
})
})
describe('get', () => {
it('should return the value in the pipe', () => {
expect(Pipe.wrap(123).get())
.to.be.equal(123)
const sym = Symbol()
expect(Pipe.wrap(sym).get())
.to.be.eql(sym)
})
})
describe('async', () => {
it('should return an async pipe', () => {
expect(Pipe.wrap(123).async())
.to.be.an.instanceof(AsyncPipe)
})
})
})

@ -0,0 +1,15 @@
import { expect } from 'chai'
import { isJSONState } from '../../../lib'
describe('util -> support -> Rehydratable -> isJSONState', () => {
it('should return true for valid JSON', () => {
expect(isJSONState('this is a string'))
.to.be.true
expect(isJSONState(1234))
.to.be.true
expect(isJSONState({ name: true }))
.to.be.true
})
})

@ -0,0 +1,75 @@
import { padLeft, padRight, padCenter, stringToPascal } from '../../../lib'
import { expect } from 'chai'
describe('util -> support -> string -> padLeft', () => {
it('should return the original string greater than the min', () => {
expect(padLeft('a longer string', 5))
.to.be.equal('a longer string')
})
it('should add spaces to the left of the string', () => {
expect(padLeft('string', 10))
.to.be.equal(' string')
})
it('should respect the pad parameter', () => {
expect(padLeft('string', 10, '*'))
.to.be.equal('****string')
})
})
describe('util -> support -> string -> padRight', () => {
it('should return the original string greater than the min', () => {
expect(padRight('a longer string', 5))
.to.be.equal('a longer string')
})
it('should add spaces to the right of the string', () => {
expect(padRight('string', 10))
.to.be.equal('string ')
})
it('should respect the pad parameter', () => {
expect(padRight('string', 10, '*'))
.to.be.equal('string****')
})
})
describe('util -> support -> string -> padCenter', () => {
it('should return the original string greater than the min', () => {
expect(padCenter('a longer string', 5))
.to.be.equal('a longer string')
})
it('should add spaces to both sides of the string', () => {
expect(padCenter('string', 10))
.to.be.equal(' string ')
})
it('should respect the pad parameter', () => {
expect(padCenter('string', 10, '*'))
.to.be.equal('**string**')
})
})
describe('util -> support -> string -> stringToPascal', () => {
it('should split inputs on spaces', () => {
expect(stringToPascal('foo bar baz'))
.to.be.equal('FooBarBaz')
})
it('should split inputs on underscores', () => {
expect(stringToPascal('foo_bar_baz'))
.to.be.equal('FooBarBaz')
})
it('should split inputs on dashes', () => {
expect(stringToPascal('foo-bar-baz'))
.to.be.equal('FooBarBaz')
})
it('should work with all delimiters', () => {
expect(stringToPascal('foo_bar-baz bin'))
.to.be.equal('FooBarBazBin')
})
})

@ -0,0 +1,54 @@
import { expect } from 'chai'
import * as sinon from 'sinon'
import { withTimeout } from '../../../lib'
const timeoutPromise = (timeout: number) => new Promise(res => {
setTimeout(res, timeout)
})
describe('util -> support -> timeout -> withTimeout', () => {
it('should call the on-time subscriber when promise resolves', async () => {
const onTimeSpy = sinon.spy()
const lateSpy = sinon.spy()
const timeoutSpy = sinon.spy()
await withTimeout(100, timeoutPromise(50))
.onTime(onTimeSpy)
.late(lateSpy)
.timeout(timeoutSpy)
.run()
await timeoutPromise(100)
expect(onTimeSpy.callCount).to.equal(1)
expect(timeoutSpy.callCount).to.equal(0)
expect(lateSpy.callCount).to.equal(0)
})
it('should call the late and timeout subscribers when promise resolves late', async () => {
const onTimeSpy = sinon.spy()
const lateSpy = sinon.spy()
const timeoutSpy = sinon.spy()
await withTimeout(50, timeoutPromise(100))
.onTime(onTimeSpy)
.late(lateSpy)
.timeout(timeoutSpy)
.run()
await timeoutPromise(100)
expect(onTimeSpy.callCount).to.equal(0)
expect(timeoutSpy.callCount).to.equal(1)
expect(lateSpy.callCount).to.equal(1)
})
it('should resolve the run() promise when the promise completes', async () => {
const runSpy = sinon.spy()
await withTimeout(50, timeoutPromise(10))
.run()
.then(runSpy)
await timeoutPromise(100)
expect(runSpy.callCount).to.be.equal(1)
})
})

@ -0,0 +1,31 @@
import { expect } from 'chai'
import { isKeyof } from '../../../lib'
describe('util -> support -> types -> isKeyof', () => {
it('should return false for invalid key types', () => {
expect(isKeyof(true, {})).to.be.false
expect(isKeyof(1.5, {})).to.be.false
})
it('should return true if the key is in the object', () => {
const sym = Symbol('test')
const obj = {
foo: true,
[sym]: 123,
}
expect(isKeyof('foo', obj)).to.be.true
expect(isKeyof(sym, obj)).to.be.true
})
it('should return false if the key is not in the object', () => {
const sym = Symbol('test')
const obj = {
foo: true,
[Symbol('test2')]: 123,
}
expect(isKeyof('bar', obj)).to.be.false
expect(isKeyof(sym, obj)).to.be.false
})
})
Loading…
Cancel
Save