pax_global_header00006660000000000000000000000064137573147000014521gustar00rootroot0000000000000052 comment=94dbdaac7a03ef6e646c885205ad37b4fa94ecbd assume-2.3.0/000077500000000000000000000000001375731470000130205ustar00rootroot00000000000000assume-2.3.0/.gitignore000066400000000000000000000001041375731470000150030ustar00rootroot00000000000000node_modules npm-debug.log test/phantom.js dist coverage .tern-port assume-2.3.0/.npmignore000066400000000000000000000000641375731470000150170ustar00rootroot00000000000000node_modules coverage test .tern-port npm-debug.log assume-2.3.0/.travis.yml000066400000000000000000000010041375731470000151240ustar00rootroot00000000000000sudo: false language: node_js node_js: - "0.12" # Ensure that we don't accidently slip in ES6 features - "0.10" # Ensure that we work on older environments - "0.8" # like, really old - "6" - "8" - "9" matrix: allow_failures: - node_js: "0.8" - node_js: "0.10" script: - "npm run test-travis" after_script: - "npm install coveralls && cat coverage/lcov.info | coveralls" notifications: irc: channels: - "irc.freenode.org#bigpipe" on_success: change on_failure: change assume-2.3.0/LICENSE000066400000000000000000000021401375731470000140220ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2015 Arnout Kazemier, Martijn Swaagman, the Contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. assume-2.3.0/README.md000066400000000000000000000633121375731470000143040ustar00rootroot00000000000000# assume [![Version npm][version]](http://browsenpm.org/package/assume)[![Build Status][build]](https://travis-ci.org/bigpipe/assume)[![Dependencies][david]](https://david-dm.org/bigpipe/assume)[![Coverage Status][cover]](https://coveralls.io/r/bigpipe/assume?branch=master) [from]: https://img.shields.io/badge/from-bigpipe.io-9d8dff.svg?style=flat-square [version]: http://img.shields.io/npm/v/assume.svg?style=flat-square [build]: http://img.shields.io/travis/bigpipe/assume/master.svg?style=flat-square [david]: https://img.shields.io/david/bigpipe/assume.svg?style=flat-square [cover]: http://img.shields.io/coveralls/bigpipe/assume/master.svg?style=flat-square Assume is an `expect` inspired assertion library who's sole purpose is to create a working and human readable assert library for browsers and node. The library is designed to work with different assertion styles. I've been trying out a lot of libraries over the last couple of years and none of the assertion libraries that I found "tickled my fancy". They either only worked in node or had really bad browser support. I wanted something that I can use starting from Internet Explorer 5 to the latest version while maintaining the `expect` like API that we all know and love. Writing tests should be dead simple and not cause any annoyances. This library attempts to achieve all of this. ## Installation Assume is written with client and server-side JavaScript in mind and uses the commonjs module system to export it self. The library is released in the public npm registry and can be installed using: ``` npm install --save-dev assume ``` The `--save-dev` flag tells `npm` to automatically add this `package.json` and it's installed version to the `devDependencies` of your module. As code is written against the commonjs module system we also ship a standalone version in the module which introduces an `assume` global. The standalone version can be found in the `dist` folder after installation. The dist file is not commited to GitHub. ## Table of Contents - [Installation](#installation) - [Syntax](#syntax) - [Configuration](#configuration) - [Feature Detection](#feature-detection) - [Performance Testing](#performance-testing) - [Assertion](#assertion) - [Keywords](#keywords) - [API](#api) - [a, an](#a-an) - [eitherOfType, oneOfType](#eitheroftype-oneoftype) - [instanceOf, instanceof, inherits, inherit](#instanceof-instanceof-inherits-inherit) - [include, includes, contain, contains](#include-includes-contain-contains) - [ok, okay, truthy, truely](#ok-okay-truthy-truely) - [falsely, falsey](#falsely-falsey) - [true](#true) - [false](#false) - [exists, exist](#exists-exist) - [length, lengthOf, size](#length-lengthof-size) - [empty](#empty) - [above, gt, greater, greaterThan](#above-gt-greater-greaterthan) - [least, gte, atleast](#least-gte-atleast) - [below, lt, less, lessThan](#below-lt-less-lessthan) - [most, lte, atmost](#most-lte-atmost) - [within, between](#within-between) - [hasOwn, own, ownProperty, haveOwnProperty, property, owns, hasown](#hasown-own-ownproperty-haveownproperty-property-owns-hasown) - [match, matches](#match-matches) - [equal, equals, eq, eqs, exactly](#equal-equals-eq-eqs-exactly) - [eql, eqls](#eql-eqls) - [either](#either) - [throw, throws, fail, fails](#throw-throws-fail-fails) - [finite, isFinite, finiteness](#finite-isfinite-finiteness) - [generator](#generator) - [optimisation, optimization](#optimisation-optimization) - [optimised, optimized](#optimised-optimized) - [start, starts, startsWith, startWith](#start-stats-startswith-startwith) - [end, ends, endsWith, endWith](#end-ends-endswith-endwith) - [closeTo, close, approximately, near](#closeto-close-approximately-near) - [rejected, rejects, throwAsync, throwsAsync, failAsync, failsAsync](#rejected-rejects-throwasync-throwsasync-failasync-failsasync) - [resolveSync, resolvesSync, resolvedSync, completeSync, completesSync, completedSync](#resolvesync-resolvessync-resolvedsync-completesync-completessync-completedsync) - [i.hope](#ihope) - [Planning](#planning) - [Waiting](#waiting) - [Plugins](#plugins) - [Publishing](#publishing) - [use](#use) - [add](#add) - [test](#test) - [assign](#assign) - [clone](#clone) ## Syntax We support a lot of different syntaxes and assertion styles. The only thing we will no (read never) support is the `should` syntax as we will never extend build-in objects/primitives of JavaScript. The default syntax that we support is modeled after `expect` so you can replace any assertion library which implements this API by simply changing the require to: ```js var expect = require('assume'); expect('foo').equals('foo'); expect('foo').is.a('string'); ``` As you can see in the example above the `is` property is used to make the assertion more readable. We support the following aliases which allow these kind of chains: - `to` - `be` - `been` - `is` - `was` - `and` - `has` - `have` - `had` - `with` - `that` - `at` - `of` - `some` - `does` - `did` - `itself` - `which` So you can just write: ```js assume(100).is.at.most(100); ``` But do note that these aliases are **optionally** so the above example can also be written as: ```js assume(100).most(1000); ``` ### Configuration The module can be configured globally be changing the properties on the `config` object: ```js var assume = require('assume'); assume.config.includeStack = false; ``` Or locally for each assertions by supplying the `assume` function with an optional configuration object: ```js assume('foo', { includeStack: false }).is.a('buffer'); ``` The following options can be configured: - **`includeStack`** Should we output a stack trace. Defaults to `true`. - **`showDIff`** Show difference between the given and expected values. Defaults to `true`. ### Feature Detection Certain assertions only work in certain JavaScript/EcmaScript environments. Things like the `generator` assertions only work in ES6 as the `function *` is invalid syntax. The results of the feature detection is publicly stored in the `assume.supports` object. You can use this object to add some conditional tests to your test suite. The following features are currently detected: - **generators** Are generators supported in the host environment. - **native** Is V8 native syntax supported. ```js if (assume.supports.native) { it('does things', function () { .. }); } ``` If you are a plugin author, feel free to add your own feature detections to this object (as long as you do not override any pre-existing values). ### Performance Testing The performance testing is only available for environments that use V8 and more specifically the `--allow-natives-syntax` flags. These flags can be supplied in [chrome before you start browser][flags]. These flags are necessary to get access to the V8 internals which expose optimization and de-optimization information. If you are running `iojs` or `node` on the server, you can pass in these flags directly: ``` iojs --allow-natives-syntax ``` #### Mocha If you are using `mocha` as test runner you usually add `mocha` as executable. But unfortunately, the `mocha` binary doesn't allow you to pass V8 flags. So instead of using the `mocha` binary directly you can use the `node` and call the `_mocha` binary instead: ``` node --allow-natives-syntax --harmony ./node_modules/mocha/bin/_mocha test/test.js ``` You can check if your host environment supports these performance tests by checking the `assume.supports.native` variable. ### Assertion There are various of assertions available in assume. If you want the failed assertion to include a custom message or reason you can **always** add this as last argument of the assertion function. ```js assume(true).is.false('how odd, true is not a false'); ``` The behaviours of the assertions can be chained using special "flags" or "prefixes". We currently support the following prefixes. - `.not`, `.doesnt`, `.dont` Instead of assuming that your assertions assert to `true` they will now assert for `false`. - `.deep`, `.deeply`, `.strict` `.strictly` Instructs the assertions to do a **deep** equal, so it checks if the contents match instead of an `object` it self matches. For example: ```js assume(false).is.not.true(); assume({foo:'bar'}).deep.equals({foo:'bar'}); ``` #### Keywords Now, a special word of caution for those of you who are using this library to write cross browser tests. Internet Explorer has issues when you use **keywords** as functions. Using the `true()`, `instanceof()` etc. functions to assert you will run in to issues. So the rule of thumb here is that if you need to do cross browser support do not assert with the keyword based names. ## API Let's take a closer look to all assertions that we're supporting: #### a, an Asserts if the given value is the correct type. We need to use Object.toString here because there are some implementation bugs the `typeof` operator: - Chrome <= 9: /Regular Expressions/ are evaluated to `function` As well as all common flaws like Arrays being seen as Objects etc. This eliminates all these edge cases. ```js assume([]).is.a('array'); ``` [`instanceof` is a keyword and might cause cross browser issues](#keywords) #### eitherOfType, oneOfType Asserts if the given value is one of the acceptable types. The same caveats regarding `typeof` apply as described in [a, an](#a-an). ```js assume([]).is.oneOfType(['array', 'string']); ``` #### instanceOf, instanceof, inherits, inherit Asserts that the value is instanceof the given constructor. ```js function Classy() {} var classes = new Classy(); assume(classes).is.an.instanceOf(Classy); ``` #### include, includes, contain, contains Assert that value includes a given value. I know this sounds vague but an example might be more useful here. It can check this for strings, objects and arrays. ```js assume({foo: 'bar'}).contains('foo'); assume('hello world').includes('world'); assume([1,3,4]).contains(1); ``` #### ok, okay, truthy, truely Assert that the value is truthy. ```js assume(1).is.ok(); assume(0).is.not.ok(); assume(true).is.ok(); ``` #### falsely, falsey Assert that the value is falsey. ```js assume(0).is.falsely(); assume(true).is.not.falsey(); assume(null).is.falsely; ``` #### true Explicitly check that the value is the boolean `true`. ```js assume(true).true(); ``` [`true` is a keyword and might cause cross browser issues](#keywords) #### false Explicitly check that the value is the boolean `false`. ```js assume(false).false(); ``` [`false` is a keyword and might cause cross browser issues](#keywords) #### exists, exist Check if the value not not `null`. ```js assume('hello').exists(); assume(undefined).exists(); // throws ``` #### length, lengthOf, size Assert if the given value has the given length. It accepts arrays, strings, functions, object and anything else that has a `.length` property. ```js assume({ foo: 'bar' }).has.length(1); assume([1,2,3,4,5,6]).is.size(6) ``` #### empty Short hand function for `assume(val).length(0)` so it can check if objects, arrays, strings are empty. ```js assume([]).empty(); assume('').empty(); assume({}).empty(); // // Also works against everything that has a `.length` property // localStorage.clear(); assume(localStorage).is.empty(); ``` #### above, gt, greater, greaterThan Assert if the value is above the given value. If you need greater or equal check out the `least` method. If value to assert is not a number we automatically extract the length out of it so you can use it check the length of arrays etc. ```js assume(100).is.above(10); ``` #### least, gte, atleast Assert if the value is above or equal to the given value. If you just need greater check out the `above` method. If value to assert is not a number we automatically extract the length out of it so you can use it check the length of arrays etc. ```js assume(100).is.least(10); assume(100).is.least(100); ``` #### below, lt, less, lessThan Assert if the value is less than the given value. If you need less or equal check out the `most` method. If value to assert is not a number we automatically extract the length out of it so you can use it check the length of arrays etc. ```js assume(10).is.below(100); ``` #### most, lte, atmost Assert if the value is less or equal to the given value. If you just need less, check out the `less` method. If value to assert is not a number we automatically extract the length out of it so you can use it check the length of arrays etc. ```js assume(10).is.most(100); assume(100).is.most(100); ``` #### within, between Check if the value is between or equal to a given range. If value to assert is not a number we automatically extract the length out of it so you can use it check the length of arrays etc. ```js assume(100).is.between(90, 100); assume([1, 213, 13, 94, 5, 6, 7]).is.between(2, 10); ``` #### hasOwn, own, ownProperty, haveOwnProperty, property, owns, hasown Assert that the value has the specified property and optionally deeply check its value. ```js assume({foo: 'bar'}).owns('foo'); assume({foo: 'bar'}).owns('foo', 'bar'); ``` #### match, matches Matches the value against a given Regular Expression. If a string is given instead of an actual Regular Expression we automatically transform it to an `new RegExp`. ```js assume('hello world').matches(/world$/); ``` #### equal, equals, eq, eqs, exactly Assert that given value is strictly (===) equal to the supplied value. ```js assume('foo').equals('foo'); assume(13424).equals(13424); ``` #### eql, eqls Assert that the given value deeply equals the supplied value. ```js assume([1,2]).eql([1,2]); ``` #### either Assert that the value is either one of the values of the given array. It can be prefixed with `.deep` for deep assertions. ```js assume('foo').is.either(['bar', 'banana', 'foo']); assume({ foo: 'bar' }).is.either(['bar', 'banana', { foo: 'bar' }]); ``` #### throw, throws, fail, fails Assert that the given function throws an error. The error can match a string, regexp or function instance. ```js function arrow() { throw new Error('you have failed this city'); } assume(arrow).throws(/failed this city/); assume(arrow).throws('failed this city'); assume(arrow).does.not.throw('your mom'); assume(function(){}).does.not.throw(); ``` [`throw` is a keyword and might cause cross browser issues](#keywords) #### finite, isFinite, finiteness Assert that the given value is finite. ```js assume(Infinity).is.finite(); ``` If `deep` assertion style is used it will use the much stricter `Number.isFinite` instead of the regular `isFinite` functionality. #### generator Assert that the given value is an EcmaScript 6 based generator. ```js assume(function *() {}).is.generator(); ``` **Please note that this will only work if Generators are enabled in the host environment or you might end up with false positives** #### optimisation, optimization **Please see the [Performance Testing](#performance-testing) section information to enable these assertions as they require specific V8 flags to be enabled.** #### optimised, optimized **Please see the [Performance Testing](#performance-testing) section information to enable these assertions as they require specific V8 flags to be enabled.** #### start, starts, startsWith, startWith Assert that the value starts with the given string. ```js assume('foobar').startWith('foo'); ``` #### end, ends, endsWith, endWith Assert that the value ends with the given string. ```js assume('foor bar, banana').endsWith('ana'); ``` #### closeTo, close, approximately, near Assert a float point number is near a given value within a delta margin. ```js assume(1.5).is.approximately(1.4, 0.2); ``` ### i.hope The asserts we write are assumptions that we receive a given value. While you're writing tests you hope that they all pass. We could write these tests using an `i.hope.that(value)` syntax: ```js var i = require('assume'); i.hope.that('foo').is.a('string'); i.expect.that('foo').is.a('string'); i.assume.that('foo').equals('bar'); i.sincerely.hope.that('foo').is.a('string'); ``` ### rejected, rejects, throwAsync, throwsAsync, failAsync, failsAsync Assert that the `thenable` results in a rejected state. ```js await assume(thisFunctionAsyncThrows()).to.throwAsync(); ``` ### resolveSync, resolvesSync, resolvedSync, completeSync, completesSync, completedSync Assert that the `thenable` completed and the result was filled synchronously. ```js await assume(thisFuncCompletesSynchronously()).to.completeSync(); ``` > Note that `Promise` always complete asynchronously even if it's already in a resolved or rejected state. ## Planning The `assume.plan` method allows you to plan the amount of assertions that should be executed by your test suite. This method accepts 2 arguments: 1. The amount of assertions you expect to run. This should always be an exact number. 2. An optional async callback that should be called with error as first argument on failure instead of throwing an error. This makes it ideal for async testing as you can just pass your continuation function. The method will return a function that should be called at the end of your tests. This method will still allow you to pass in an error as first argument so the supplied callback in second argument will be called directly with it. When the method is called we will count the amount of assertions that we're executed. If it's less or more than the supplied amount we will throw an error. ```js var end = assume.plan(10); assume(10).equals(10); end(); // This throws an error as we only executed 1 out of the 10 asserts. ``` And with optional async callback: ```js next = assume.plan(7, next); for (var i = 0; i < 10; i++) { assume(i).equqls(i); } next(); // Also throws an error as we've executed 10 assertions instead of 7. ``` ## Waiting Writing async tests can be hard, especially if you have to juggle with callbacks and wait untill 2 callbacks are completed before you can continue with the test suite. The `assume.wait` function helps you with orchestration of tests and callbacks. The method accepts 3 arguments: 1. The amount of times the returned callback should be called before calling the supplied callback. 2. Optionally, the amount of assertions you expect to run. We will wrap the returned callback with `assume.plan` this way. 3. Completion callback which is called after the callbacks have been called. The method will return a function that should be used as callback for your async tests. It follows an error first callback pattern and instantly calls the supplied callback once an error has be passed in as error argument. ```js it('does async things', function (next) { next = assume.wait(2, 4, next); asynctask(function (err, data) { assume(err).is.a('undefined'); assume(data).equals('testing'); next(); }); asynctaskfail(function (err, data) { assume(err).is.a('undefined'); assume(data).equals('testing'); next(); }); }); ``` ## Plugins We've done our best to include a bunch of assertions that should make it easier to test your code but it's always possible that we're missing assertions or you just want to eliminate repetition in your code. So we've got a plugin interface which allows you to extend the `assume` instance with even more assertions. ### Publishing For the sake of discoverablity ability of your plugins on npm we suggest to either suffix or prefix your module with `assume` and adding the `assume` keyword in to your keywords list. ### use Let's assume that we've want to extend the library with a method for checking the headers of a passed in HTTP request object. If it was released in npm we could add it as following: ```js assume.use(require('assume-headers')); ``` The `use` method returns `assume` so it can be used to chain multiple plugin calls together: ```js assume .use(require('assume-headers')) .use(require('assume-method')); ``` The `assume-headers` plugin/module should export a function which receives the assume instance to extend as illustrated by the example below: ```js module.exports = function plugin(assume, util) { /** * Assert that the received HTTP request contains a given header. * * @param {String} name Name of the header that we should have received. * @param {String} ms Reason of failure. * @returns {Assume} * @api public */ assume.add('header', function header(name, msg) { var expect = '`'+ util.string(this.value.header)'` to @ have header '+ util.string(name); return this.test(name in this.value.headers, msg, expect); }); } ``` The plugin receives 2 arguments: 1. A reference to the `assume` instance so it can be extended. 2. Small assertion helper library which contains all the internals we're using. The helper library contains the following methods: - **name**, Reference to the `fn.name` module so you extract names from functions. - **get**, Reference to the `get` method of the `pathval` module. - **string**, Inspection function which safely transforms objects, numbers, dates etc. to a string. - **deep**, A deep assertion if the two argument deeply equal to each other. - **type**, Extract the type of an object to an lowercase string. Useful for detecting the difference between `object`, `array`, `arguments`, `date`, `buffer` etc. - **size**, A function which returns the size of given object or array. - **each**, Simple iterator which accepts an array/object and calls the supplied callback with the value and key/index. - **nodejs**, Boolean indicating if we are running on `nodejs`. New flags can be introduced by adding properties to the `flags` object. The `flags` object has the following structure: - `key` This is the name of the property which will be added to the `assume` instance. The property is set to `false` by default and will be to `true` once once of the `flags` is accessed. - `value` These are the aliases that can be used to the set the property to `true`. For our `.not` flags we've set the following key/value's: ```js Assert.flags.untrue = 'doesnt, not, dont'; ``` Please do note that you should try to limit the amount of flags that you add as they are quite expensive to process every single time. Adding new assertions to assume can be done using the following methods: #### add The `assume.add` method is a convince method for adding new methods to the assume prototype. It was created using the [`assign`](#assign) method so it can automatically add aliases/shorthand's of the method to the prototype in one go. The method requires 2 arguments: 1. A string which is comma or space separated or an array which contains the names of the methods that should be added to the prototype. 2. The function or value that is assigned for all these properties. ```js module.exports = function (assume, util) { util.each(['GET', 'POST', 'PUT', 'DELETE'], function each(method) { assume.add(method, function () { var expect = '`'+ util.string(this.value.method)+'` to @ be '+ method; return this.test(this.value.method === method, msg, expect); }); }); } ``` If you want to add more aliases for the `.function()` method you can simply do a: ```js assume.add('execute, executes, exec', function () { return this.clone().is.a('function'); }); ``` The value to assert is stored in the `value` property of the instance. If the `deep` flag is set, the `deeply` property is set to `true`. #### test This is the method that handles all the assertion passing and failing. It's _the_ most important method of all. It accepts the following arguments: - `passed`, a boolean which indicates if the assertion failed or passed. - `msg`, a string which is the reason or message provided by the users. - `expectation`, a compiled template which explains what the assertion expected. - `slice`, a number which slices of stacks from the stack trace. This is keeps the stack trace clear of all references to our own assertion library and only contains the part of the test/suite where the assertion was initiated. This value is optional and defaults to `2` so it removes the `test` and the `assertion` from the stack. If the `assertion` passes the method will return it self, or it will throw. ```js assume.add('true', function (msg) { var expectation = format('value to @ be true'); return this.test(this.value === true, msg, expectation); }); ``` In example above you might have noticed the odd `@` in the `expection` value. This is a special character and will be replaced with `not` if the `.not` flag was used or completely removed (including an extra whitespace at the end). #### assign Assign multiple values to a given thing. This method accepts one argument which is an object or prototype on where we should assign things. It will return a function that is responsible for the assignment on that given thing. The return function will require 2 arguments: 1. A string which is comma or space separated or an array which contains the names of the methods that should be added to the prototype. 2. The function or value that is assigned for all these properties. To create your own custom `add` method you could simply do: ```js var add = assume.assign(assign.prototype); ``` And the `add` function would now do exactly the same as the [`assume.add`](#add) method. #### clone Create an exact clone of the assume instance so it all flags and options are identical to the current assume instance. The method accepts one optional argument which is the value it should assert. If nothing is given it uses the current value. This can be helpful if you want to run assertions in your assertions so you can assert while you assert. ```js // Yo dawg, I herd you like assertions so I put assertions in the assertions so // you can assert while you assert. assume.add('something', function somethign(value, msg) { this.clone().is.a('string'); this.clone().is.endsWith('thing'); return this.test(this.value ==== 'something', msg, 'the value should be something'); }); ``` ## License MIT [flags]: http://www.chromium.org/developers/how-tos/run-chromium-with-flags assume-2.3.0/index.d.ts000066400000000000000000000170001375731470000147170ustar00rootroot00000000000000/*~ This declaration specifies that the function *~ is the exported object from the file */ export = Assume; declare module 'assume'; declare function Assume(value: any, flags?: Assume.Flags): Assume.Assumption; declare namespace Assume { export interface Flags { stacktrace?: boolean, diff?: boolean, sliceStack?: number, slice?: number } export const config: Config; export const supports: Supports; export const flags: Flags; export interface ErrCallback { (err?: Error | string): void } interface AssumeInstance extends Flags { value: T, test: TestFunction } export interface AddonAssumption { (this: AssumeInstance, ...args: any): Assumption; } export interface Expectation { (expectation: string): string } interface TestFunction { (passed: boolean, msg: string, expectation: Expectation | string, slicesOfStack?: number): Assumption } export function plan(numAssertionsPlanned: number, next?: ErrCallback): ErrCallback; export function wait(callbackCallCount: number, numAssertionsPlanned: number, onFinished: ErrCallback): ErrCallback; export function wait(callbackCallCount: number, onFinished: ErrCallback): ErrCallback; export function use(plugin: Function): void; export const test: TestFunction export function add(methods: string | string[], func: AddonAssumption): void; export interface AssignFunction { (methods: string | string[], func: Function) } export function assign(assignTo: object): AssignFunction; export function clone(value: any): Assumption; export interface Config { includeStack: boolean, showDiff: boolean, sliceStack: number } export interface Supports { readonly generators: boolean, readonly native: boolean } export const hope: HopeAssumption; export const expect: HopeAssumption; export const assume: HopeAssumption; export const sincerely: HopeAssumption; export interface HopeAssumption { readonly hope: HopeAssumption, readonly expect: HopeAssumption, readonly assume: HopeAssumption, readonly sincerely: HopeAssumption, that(value: any, flags?: Flags): Assumption, } export interface Assumption { readonly to: Assumption, readonly be: Assumption, readonly been: Assumption, readonly is: Assumption, readonly was: Assumption, readonly and: Assumption, readonly has: Assumption, readonly have: Assumption, readonly had: Assumption, readonly with: Assumption, readonly that: Assumption, readonly at: Assumption, readonly of: Assumption, readonly same: Assumption, readonly does: Assumption, readonly did: Assumption, readonly itself: Assumption, readonly which: Assumption, readonly not: Assumption, readonly doesnt: Assumption, readonly dont: Assumption, readonly deep: Assumption, readonly deeply: Assumption, readonly strict: Assumption, readonly strictly: Assumption, a(type: string, msg?: string): void, an(type: string, msg?: string): void, eitherOfType(types: string[], msg?: string): void, oneOfType(types: string[], msg?: string): void, instanceOf(type: Function, msg?: string): void, instanceof(type: Function, msg?: string): void, inherits(type: Function, msg?: string): void, inherit(type: Function, msg?: string): void, include(value: any, msg?: string): void, includes(value: any, msg?: string): void, contain(value: any, msg?: string): void, contains(value: any, msg?: string): void, ok(msg?: string): void, okay(msg?: string): void, truthy(msg?: string): void, truely(msg?: string): void, falsely(msg?: string): void, falsey(msg?: string): void, falsy(msg?: string): void, true(msg?: string): void, false(msg?: string): void, exists(msg?: string): void, exist(msg?: string): void, length(length: number, msg?: string): void, lengthOf(length: number, msg?: string): void, size(length: number, msg?: string): void, empty(msg?: string): void, above(value: number, msg?: string): void, gt(value: number, msg?: string): void, greater(value: number, msg?: string): void, greaterThan(value: number, msg?: string): void, least(value: number, msg?: string): void, gte(value: number, msg?: string): void, atleast(value: number, msg?: string): void, below(value: number, msg?: string): void, lt(value: number, msg?: string): void, less(value: number, msg?: string): void, lessThan(value: number, msg?: string): void, most(value: number, msg?: string): void, lte(value: number, msg?: string): void, atmost(value: number, msg?: string): void, within(lowerBound: number, upperBound: number, msg?: string): void, between(lowerBound: number, upperBound: number, msg?: string): void, hasOwn(key: string, value?: any, msg?: string): void, own(key: string, value?: any, msg?: string): void, ownProperty(key: string, value?: any, msg?: string): void, haveOwnProperty(key: string, value?: any, msg?: string): void, property(key: string, value?: any, msg?: string): void, owns(key: string, value?: any, msg?: string): void, hasown(key: string, value?: any, msg?: string): void, match(regExp: RegExp | string, msg?: string): void, matches(regExp: RegExp | string, msg?: string): void, equal(value: any, msg?: string): void, equals(value: any, msg?: string): void, eq(value: any, msg?: string): void, eqs(value: any, msg?: string): void, exactly(value: any, msg?: string): void, eql(value: any, msg?: string): void, eqls(value: any, msg?: string): void, either(values: any[], msg?: string): void, throw(err?: RegExp | string | Function, msg?: string): void, throws(err?: RegExp | string | Function, msg?: string): void, fail(err?: RegExp | string | Function, msg?: string): void, fails(err?: RegExp | string | Function, msg?: string): void, finite(msg?: string): void, isFinite(msg?: string): void, finiteness(msg?: string): void, generator(msg?: string): void, optimisation(msg?: string): void, optimization(msg?: string): void, optimised(msg?: string): void, optimized(msg?: string): void, start(str: string, msg?: string): void, starts(str: string, msg?: string): void, startsWith(str: string, msg?: string): void, startWith(str: string, msg?: string): void, end(str: string, msg?: string): void, ends(str: string, msg?: string): void, endsWith(str: string, msg?: string): void, endWith(str: string, msg?: string): void, closeTo(value: number, deltaMargin: number, msg?: string): void, close(value: number, deltaMargin: number, msg?: string): void, approximately(value: number, deltaMargin: number, msg?: string): void, near(value: number, deltaMargin: number, msg?: string): void, rejected(msg?: string): void, rejects(msg?: string): void, throwAsync(msg?: string): void, throwsAsync(msg?: string): void, failAsync(msg?: string): void, failsAsync(msg?: string): void, resolveSync(msg?: string): void, resolvesSync(msg?: string): void, resolvedSync(msg?: string): void, completeSync(msg?: string): void, completesSync(msg?: string): void, completedSync(msg?: string): void, } } assume-2.3.0/index.js000066400000000000000000000775401375731470000145020ustar00rootroot00000000000000'use strict'; var stringify = require('object-inspect') , pruddy = require('pruddy-error') , displayName = require('fn.name') , isBuffer = require('is-buffer') , propget = require('propget') , deep = require('deep-eql'); var undefined , called = 0 , toString = Object.prototype.toString , hasOwn = Object.prototype.hasOwnProperty , nodejs = !!(typeof process != 'undefined' && process.versions && process.versions.node); /** * Get class information for a given type. * * @param {Mixed} of Type to check. * @returns {String} The name of the type. * @api private */ function type(of) { if (isBuffer(of)) return 'buffer'; if (of === undefined) return 'undefined'; if (of === null) return 'null'; if (of !== of) return 'nan'; return toString.call(of).slice(8, -1).toLowerCase(); } /** * Determine the size of a collection. * * @param {Mixed} collection The object we want to know the size of. * @returns {Number} The size of the collection. * @api private */ function size(collection) { var x, i = 0; if ('object' === type(collection)) { if ('number' === type(collection.length)) return collection.length; for (x in collection) { if (hasOwn.call(collection, x)) i++; } return i; } try { return +collection.length || 0; } catch (e) { return 0; } } /** * Iterate over each item in an array. * * @param {Array} arr Array to iterate over. * @param {Function} fn Callback for each item. * @api private */ function each(what, fn) { if ('array' === type(what)) { for (var i = 0, length = what.length; i < length; i++) { if (false === fn(what[i], i, what)) break; } } else { for (var key in what) { if (false === fn(what[key], key, what)) break; } } } /** * Return a formatter function which compiles the expectation message. The * message can contain various of patterns which will be replaced with * a stringified/parsed version of the supplied argument for that given * placeholder pattern. The following patterns are supported: * * - %% : Escape the % so you can write %d in your messages as %%d * - %d : Cast argument in to a number. * - %s : Cast argument in to a string. * - %f : Transform function in to the name of the function. * - %j : Transform object to a string. * * @param {String} expectation The expectation message. * @returns {Function} * @api private */ function format() { var args = Array.prototype.slice.call(arguments, 0) , expectation = args.shift() , length = args.length , i = 0; return function compile(not) { if (not) expectation = expectation.replace(/@/g, 'not'); else expectation = expectation.replace(/@\s/g, ''); return expectation.replace(/%[sdjf%]/g, function replace(char) { if (i >= length) return char; switch (char) { case '%%': return '%'; case '%s': return String(args[i++]); case '%d': return Number(args[i++]); case '%f': return displayName(args[i++]); case '%j': try { return stringify(args[i++]); } catch (e) { return ''; } default: return char; } }); }; } /** * Assert values. * * Flags: * * - **stacktrace**: Include stacktrace in the assertion. * - **diff**: Attempt to show the difference in object/values so we know why * the assertion failed. * - **sliceStack**: The amount of stacks we should slice off errors messages. * * @constructor * @param {Mixed} value Value we need to assert. * @param {Object} flags Assertion flags. * @api public */ function Assume(value, flags) { if (!(this instanceof Assume)) return new Assume(value, flags); flags = flags || {}; this.stacktrace = 'stacktrace' in flags ? flags.stacktrace : Assume.config.includeStack; this.sliceStack = 'slice' in flags ? flags.slice : Assume.config.sliceStack; this.diff = 'diff' in flags ? flags.diff : Assume.config.showDiff; // // These flags are by the alias function so we can generate .not and .deep // properties which are basically new Assume instances with these flags set. // for (var alias in Assume.flags) { this[alias] = alias in flags ? flags[alias] : false; } this.value = value; Assume.assign(this)('to, be, been, is, was, and, has, have, had, with, that, at, of, same, does, did, itself, which'); Assume.alias(value, this); } /** * Attempt to mimic the configuration API of chai.js so it's dead simple to * migrate from chai.js to assume. * * @type {Object} * @public */ Assume.config = { includeStack: true, // mapped to `stacktrace` as default value. showDiff: true, // mapped to `diff` as default value. sliceStack: 2 // Number of stacks that we should slice of the err stack.. }; /** * List of flags and properties that need to be created for chaining purposes. * Plugins could add extra properties that needed to be chained as well. * * @type {Object} * @public */ Assume.flags = { _not: 'doesnt, not, dont', _deep: 'deep, deeply, strict, strictly' }; /** * Certain assertions can be disabled based on their environment that they are * executing in. This object allows you in spect which of these conditional * assertions are supported. * * @type {Object} * @public */ Assume.supports = (function detect() { var supports = { generators: true, native: true }; try { eval('(function*(){})()'); } catch (e) { supports.generators = false; } try { eval('%GetV8Version()'); } catch (e) { supports.native = false; } return supports; }(/* Douglas Crockford wants the dog balls inside youtu.be/taaEzHI9xyY#t=2020s */)); /** * Registry of manually read files that are registered using Assume#register. * * @type {Object} * @private */ Assume.registry = {}; /** * By default we will try to read file's from disk or using Ajax calls to get * correct line numbers for assertion errors but there are environments where * both of these options are not available or preferred. You can manually * register those files. * * @param {String} file File path for the given source code * @param {String} source The source of the given file. * @returns {Assume} * @public */ Assume.register = function register(file, source) { if ('object' === type(file)) { each(file, function iterate(value, key) { Assume.register(key, value); }); } else { Assume.registry[file] = source; } return Assume; }; /** * Assign values to a given thing. * * @param {Mixed} where Where do the new properties need to be assigned on. * @returns {Function} * @api public */ Assume.assign = function assign(where) { return function assigns(aliases, value) { if ('string' === typeof aliases) { if (~aliases.indexOf(',')) aliases = aliases.split(/[\s|\,]+/); else aliases = [aliases]; } for (var i = 0, length = aliases.length; i < length; i++) { where[aliases[i]] = value || where; } return where; }; }; /** * Add aliases to the given constructed asserts. This allows us to chain * assertion calls together. * * @param {Mixed} value Value that we need to assert. * @param {Assume} assert The constructed assert instance. * @returns {Assume} The given assert instance. * @api private */ Assume.alias = function alias(value, assert) { var assign = Assume.assign(assert) , flags, flag, prop; for (prop in Assume.flags) { if (!hasOwn.call(Assume.flags, prop)) continue; if (!assert[prop]) { flags = {}; for (flag in Assume.flags) { if (!hasOwn.call(Assume.flags, flag)) continue; flags[flag] = assert[flag]; } // // Add some default values to the flags. // flags.stacktrace = assert.stacktrace; flags.diff = assert.diff; flags[prop] = true; assign(Assume.flags[prop], new Assume(value, flags)); } else assign(Assume.flags); } return assert; }; /** * API sugar of adding aliased prototypes to the Assume. This makes the code * a bit more workable and human readable. * * @param {String|Array} aliases List of methods. * @param {Function} fn Actual assertion function. * @returns {Assume} * @api public */ Assume.add = Assume.assign(Assume.prototype); /** * Asserts if the given value is the correct type. We need to use * Object.toString here because there are some implementation bugs the `typeof` * operator: * * - Chrome <= 9: /Regular Expressions/ are evaluated to `function` * * As well as all common flaws like Arrays being seen as Objects etc. This * eliminates all these edge cases. * * @param {String} of Type of class it should equal * @param {String} msg Reason of failure. * @returns {Assume} * @api public */ Assume.add('a, an', function typecheck(of, msg) { of = of.toString().toLowerCase(); var value = type(this.value) , expect = format('`%j` (%s) to @ be a %s', this.value, value, of); return this.test(value === of, msg, expect); }); /** * Asserts if the given value is the correct type from a list of types. * The same caveats regarding `typeof` apply as described in `a`, `an`. * * @param {String[]} ofs Acceptable types to check against * @param {String} msg Reason of failure. * @returns {Assume} * @api public */ Assume.add('eitherOfType, oneOfType', function multitypecheck(ofs, msg) { var value = type(this.value) , expect = format('`%j` (%s) to @ be a %s', this.value, value, ofs.join(' or a ')); var test = false; for (var i = 0; i < ofs.length; i++) { if (ofs[i].toString().toLowerCase() === value) { test = true; break; } } return this.test(test, msg, expect); }); /** * Asserts that the value is instanceof the given constructor. * * @param {Function} constructor Constructur the value should inherit from. * @param {String} msg Reason of failure. * @returns {Assume} * @api public */ Assume.add('instanceOf, instanceof, inherits, inherit', function of(constructor, msg) { var expect = format('%f to @ be an instanceof %f', this.value, constructor); return this.test(this.value instanceof constructor, msg, expect); }); /** * Assert that the value includes the given value. * * @param {Mixed} val Value to match. * @param {String} msg Reason of failure. * @returns {Assume} * @api public */ Assume.add('include, includes, contain, contains', function contain(val, msg) { var includes = false , of = type(this.value) , expect = format('`%j` to @ include %j', this.value, val); switch (of) { case 'array': for (var i = 0, length = this.value.length; i < length; i++) { if (this._deep ? deep(this.value[i], val) : this.value[i] === val) { includes = true; break; } } break; case 'object': if (val in this.value) { includes = true; } break; case 'string': if (~this.value.indexOf(val)) { includes = true; } break; } return this.test(includes === true, msg, expect); }); /** * Assert that the value is truthy. * * @param {String} msg Reason of failure. * @returns {Assume} * @api public */ Assume.add('ok, okay, truthy, truly', function ok(msg) { var expect = format('`%j` to @ be truthy', this.value); return this.test(Boolean(this.value), msg, expect); }); /** * Assert that the value is falsey. * * @param {String} msg Reason of failure. * @returns {Assume} * @api public */ Assume.add('falsely, falsey, falsy', function nope(msg) { var expect = format('`%j` to @ be falsely', this.value); return this.test(Boolean(this.value) === false, msg, expect); }); /** * Assert that the value is `true`. * * @param {String} msg Reason of failure. * @returns {Assume} * @api public */ Assume.add('true', function ok(msg) { var expect = format('`%j` to @ equal (===) true', this.value); return this.test(this.value === true, msg, expect); }); /** * Assert that the value is `true`. * * @param {String} msg Reason of failure. * @returns {Assume} * @api public */ Assume.add('false', function nope(msg) { var expect = format('`%j` to @ equal (===) false', this.value); return this.test(this.value === false, msg, expect); }); /** * Assert that the value exists. * * @param {String} msg Reason of failure. * @returns {Assume} * @api public */ Assume.add('exists, exist', function exists(msg) { var expect = format('`%j` to @ exist', this.value); return this.test(this.value != null, msg, expect); }); /** * Asserts that the value's length is the given value. * * @param {Number} value Size of the value. * @param {String} msg Reason of failure. * @returns {Assume} * @api public */ Assume.add('length, lengthOf, size', function length(value, msg) { var actualValue = size(this.value); var expect = format('`%j` to @ have a length of %d, found %d', this.value, value, actualValue); return this.test(actualValue === +value, msg, expect); }); /** * Asserts that the value's length is 0 or doesn't contain any enumerable keys. * * @param {String} msg Reason of failure. * @returns {Assume} * @api public */ Assume.add('empty', function empty(msg) { var expect = format('`%j` to @ be empty', this.value); return this.test(size(this.value) === 0, msg, expect); }); /** * Assert that the value is greater than the specified value. * * @param {Number} value The greater than value. * @param {String} msg Reason of failure. * @returns {Assume} * @api public */ Assume.add('above, gt, greater, greaterThan', function above(value, msg) { var amount = type(this.value) !== 'number' ? size(this.value) : this.value , expect = format('%d to @ be greater than %d', amount, value); return this.test(amount > value, msg, expect); }); /** * Assert that the value is equal or greater than the specified value. * * @param {Number} value The specified value. * @param {String} msg Reason of failure. * @returns {Assume} * @api public */ Assume.add('least, gte, atleast', function least(value, msg) { var amount = type(this.value) !== 'number' ? size(this.value) : this.value , expect = format('%d to @ be greater or equal to %d', amount, value); return this.test(amount >= value, msg, expect); }); /** * Assert that the value starts with the given value. * * @param {String|Array} value String it should start with. * @param {String} msg Reason of failure. * @returns {Assume} * @api public */ Assume.add('start, starts, startsWith, startWith', function start(value, msg) { var expect = format('`%j` to @ start with %j', this.value, value); return this.test(0 === this.value.indexOf(value), msg, expect); }); /** * Assert that the value ends with the given value. * * @param {String} value String it should start with. * @param {String} msg Reason of failure. * @returns {Assume} * @api public */ Assume.add('end, ends, endsWith, endWith', function end(value, msg) { var index = this.value.indexOf(value, this.value.length - value.length) , expect = format('`%j` to @ end with %j', this.value, value); return this.test(index >= 0, msg, expect); }); /** * Assert a floating point number is near the give value within the delta * margin. * * @param {Number} value The specified value. * @param {Number} delta Radius. * @param {String} msg Reason of failure. * @returns {Assume} * @api public */ Assume.add('closeTo, close, approximately, near', function close(value, delta, msg) { var expect = format('`%j` to @ be close to %d ± %d', this.value, value, delta); return this.test(Math.abs(this.value - value) <= delta, msg, expect); }); /** * Assert that the value is below the specified value. * * @param {Number} value The specified value. * @param {String} msg Reason of failure. * @returns {Assume} * @api public */ Assume.add('below, lt, less, lessThan', function below(value, msg) { var amount = type(this.value) !== 'number' ? size(this.value) : this.value , expect = format('%d to @ be less than %d', amount, value); return this.test(amount < value, msg, expect); }); /** * Assert that the value is below or equal to the specified value. * * @param {Number} value The specified value. * @param {String} msg Reason of failure. * @returns {Assume} * @api public */ Assume.add('most, lte, atmost', function most(value, msg) { var amount = type(this.value) !== 'number' ? size(this.value) : this.value , expect = format('%d to @ be less or equal to %d', amount, value); return this.test(amount <= value, msg, expect); }); /** * Assert that that value is within the given range. * * @param {Number} start Lower bound. * @param {Number} finish Upper bound. * @param {String} msg Reason of failure. * @returns {Assume} * @api public */ Assume.add('within, between', function within(start, finish, msg) { var amount = type(this.value) !== 'number' ? size(this.value) : this.value , expect = format('%d to @ be greater or equal to %d and @ be less or equal to %d', amount, start, finish); return this.test(amount >= start && amount <= finish, msg, expect); }); /** * Assert that the value has an own property with the given prop. * * @param {String} prop Property name. * @param {String} msg Reason of failure. * @returns {Assume} * @api public */ Assume.add('hasOwn, own, ownProperty, haveOwnProperty, property, owns, hasown', function has(prop, value, msg) { var expect = format('`%j` @ to have own property %s', this.value, prop) , tested = this.test(hasOwn.call(this.value, prop), msg, expect); return arguments.length > 1 ? this.clone(this.value[prop]).equals(value) : tested; }); /** * Asserts that the value matches a regular expression. * * @param {RegExp} regex Regular expression to match against. * @param {String} msg Reason of failure. * @returns {Assume} * @api public */ Assume.add('match, matches', function test(regex, msg) { if ('string' === typeof regex) regex = new RegExp(regex); var expect = format('`%j` to @ match %j', this.value, regex); return this.test(!!regex.test(this.value), msg, expect); }); /** * Assert that the value equals a given thing. * * @param {Mixed} thing Thing it should equal. * @param {String} msg Reason of failure. * @returns {Assume} * @api public */ Assume.add('equal, equals, eq, eqs, exactly', function equal(thing, msg) { var expect = format('`%j` to @ equal (===) `%j`', this.value, thing); if (!this._deep) return this.test(this.value === thing, msg, expect); this.sliceStack++; return this.eql(thing, msg); }); /** * Assert that the value **deeply** equals a given thing. * * @param {Mixed} thing Thing it should equal. * @param {String} msg Reason of failure. * @returns {Assume} * @api public */ Assume.add('eql, eqls', function eqls(thing, msg) { var expect = format('`%j` to deeply equal `%j`', this.value, thing); return this.test(deep(this.value, thing), msg, expect); }); /** * Assert that the value is either one of the given values. * * @param {Array} arrgs All the values it can match. * @param {String} msg Reason of failure. * @returns {Assume} * @api public */ Assume.add('either', function either(args, msg) { var expect = '`%j` to equal either `%j` ' , i = args.length , result = false , values = []; while (i-- || result) { if (!this._deep) result = this.value === args[i]; else result = deep(this.value, args[i]); if (result) break; values.push(args[i]); } expect = format.apply(null, [expect + (new Array(values)).join('or `%j` ')].concat(values)); return this.test(result, msg, expect); }); /** * Assert if the given function throws. * * @param {Mixed} thing Thing it should equal. * @param {String} msg Reason of failure. * @returns {Assume} * @api public */ Assume.add('throw, throws, fails, fail', function throws(thing, msg) { try { this.value(); } catch (e) { var message = 'object' === typeof e ? e.message : e; switch (type(thing)) { case 'string': return this.clone(message).includes(thing, msg); case 'regexp': return this.clone(message).matches(thing, msg); case 'function': return this.clone(e).instanceOf(thing, msg); case 'undefined': return this.test(true, msg, format('%f to @ throw', this.value)); default: return this.clone(e).equals(thing); } } return this.test(false, msg, format('%f to @ throw', this.value)); }); /** * Assert if the given value is finite. * * @param {String} msg Reason of failure. * @returns {Assume} * @api public */ Assume.add('isFinite, finite, finiteness', function finite(msg) { var expect = format('`%j`s @ a is a finite number', this.value) , result; if (this._deep) { result = Number.isFinite ? Number.isFinite(this.value) : 'number' === type(this.value) && isFinite(this.value); } else { result = isFinite(this.value); } return this.test(result, msg, expect); }); /** * Assert if the given function is an ES6 generator. * * @param {String} msg Reason of failure. * @returns {Assume} * @api public */ Assume.add('generator', function generators(msg) { var expect = format('%f to @ be a generator', this.value) , result; // // Non standard function from Mozilla allows us to check if a function is // a generator. // // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/isGenerator // if ('function' === typeof this.value.isGenerator) { result = this.value.isGenerator(); } else if ('generatorfunction' === type(this.value)) { result = true; } else { result = 'function' === type(this.value) && this.value.toString().indexOf('function*') === 0; } return this.test(result, msg, expect); }); /** * Assert if the given thenable/async function results in a rejected/error state * * @param {String} msg Reason of failure. * @api public */ Assume.add('rejected, rejects, throwAsync, throwsAsync, failAsync, failsAsync', function rejects(msg) { var expectation = format('Thenable did @ end in a rejected state'); var value = typeof this.value == 'function' ? this.value() : this.value; var self = this; function test(success, resolveValue, resolve, reject) { try { self.test(success, msg, expectation); resolve(resolveValue); } catch (ex) { reject(ex); } } return { then: function then(resolve, reject) { value.then(function (s) { test(false, s, resolve, reject); }, function (r) { test(true, r, resolve, reject); }); } }; }); /** * Assert if the given thenable/async function completed and a result filled synchronously * * @param {String} msg Reason of failure * @api public */ Assume.add('resolveSync, resolvesSync, resolvedSync, completeSync, completesSync, completedSync', function completedSync(msg) { var expectation = format('Thenable did @ complete synchronously'); var value = typeof this.value == 'function' ? this.value() : this.value; var self = this; return { then: function then(resolve, reject) { var completed = false; var resolveValue; value.then(function (s) { resolveValue = s; completed = true; }, function (r) { resolveValue = r; completed = true; }); try { self.test(completed, msg, expectation); resolve(resolveValue); } catch (ex) { reject(ex); } } }; }); // // The following assertions require's v8's allow-natives-syntax flag to be // enabled as this allows us to hook in to the more internal parts of the // engine. The native syntax is wrapped in a try catch with a new Function // construction so the rest of the code will execute when JavaScript engines do // not understand the instructions. // (function v8() { var states = 'void,yes,no,always,never,void,maybe'.split(',') , detect; if (!Assume.supports.native) detect = function optimized() { return 0; }; else detect = new Function('fn', 'args', 'selfie', [ 'fn.apply(selfie, args);', '%OptimizeFunctionOnNextCall(fn);', 'fn.apply(selfie, args);', 'return %GetOptimizationStatus(fn);' ].join('\n')); /** * Assert that a given function has reached a certain optimization level. * * @param {String} level Optimization level * @param {Array} args Arguments for the function * @param {Mixed} selfie This context for the function * @param {String} msg Reason of failure * @returns {Assume} * @api public */ Assume.add('optimisation, optimization', function optimization(level, args, selfie, msg) { var expect = format('%f to be optimized as %s', this.value, level) , status = states[detect(this.value, args, selfie)]; return this.test(status === level, msg, expect); }); /** * Assert that the function is optimized. * * @param {String} msg Reason of failure * @returns {Assume} * @api public */ Assume.add('optimized, optimised', function optimized(msg) { var expect = format('%f to be optimized', this.value) , status = states[detect(this.value, [])]; return this.test(status === 'yes', msg, expect); }); }()); /** * Create a clone of the current assertion instance which has the same * configuration but a different value. * * @param {Mixed} value The new value * @returns {Assume} * @api public */ Assume.add('clone', function clone(value) { var configuration = { stacktrace: this.stacktrace, slice: this.sliceStack + 1, diff: this.diff }; for (var alias in Assume.flags) { if (!hasOwn.call(Assume.flags, alias)) continue; configuration[alias] = this[alias]; } return new Assume(arguments.length ? value : this.value, configuration); }); /** * Validate the assertion. * * @param {Boolean} passed Didn't the test pass or fail. * @param {String} msg Custom message provided by users. * @param {Function} expectation Compiled expectation template * @param {Number} slice The amount of stack traces we need to remove. * @returns {Assume} * @api public */ Assume.add('test', function test(passed, msg, expectation, slice) { called++; // Needed for tracking the amount of executed assertions. if (this._not) passed = !passed; if (passed) return this; msg = msg || 'Unknown assertation failure occured'; slice = slice || this.sliceStack; if (expectation) msg += ', assumed ' + expectation(this._not); var failure = new Error(msg) , err = { message: failure.message, stack: '' }; if (this.stacktrace) { err.stack = failure.stack || err.stack; } // // Pre-scrub, it's possible that the error message is a multi line error // message and that really messes up the slicing of the call stack, to prevent // this from happening, we're just going to replace the error message that is // on the stack with a single line as we use the `err.message` instead of the // message that is in the stack anyways. // err.stack = err.stack.replace(err.message, 'assume-replaced-the-err-message'); // // Clean up the stack by slicing off the parts that are pointless to most // people. (Like where it enters this assertion library). // err.stack = err.stack.split('\n').slice(slice).join('\n') || err.stack; err.stack = pruddy(err, { read: function read(failing) { if (!size(Assume.registry)) return; return Assume.registry[failing.filename]; } }); if ('function' !== typeof Object.create) { if ('object' === typeof console && 'function' === typeof console.error) { console.error(err.stack); } throw failure; } failure = Object.create(Error.prototype); failure.message = err.message; failure.stack = err.stack; throw failure; }); /** * Plan for the amount of assertions that needed to run. This is great way to * figure out if you have edge cases in your code which prevented an assertion or * callback from running. * * ```js * it('run a lot of assertions', function (next) { * next = assume.plan(10, next); * }); * ``` * * @param {Number} tests The amount of assertions you expect to run. * @param {Function} fn Optional completion callback which receives the error. * @returns {Function} Completion callback. * @api public */ Assume.plan = function plan(tests, fn) { fn = fn || function next(err) { if (err) throw err; }; var atm = called; return function validate(err) { var ran = called - atm , msg; if (err) return fn(err); if (tests === ran) return fn(); msg = [ 'We ran', ran - tests, ran > tests ? 'more' : 'less', 'assertations than the expected', tests ]; fn(new Error(msg.join(' '))); }; }; /** * Wait until the returned callback is called x times before advancing. This * makes it a bit easier to write async tests that require multiple callbacks. * * ```js * it('does async things', function (next) { * next = assume.wait(2, 4, next); * * asynctask(function (err, data) { * assume(err).is.a('undefined'); * assume(data).equals('testing'); * * next(); * }); * * asynctaskfail(function (err, data) { * assume(err).is.a('undefined'); * assume(data).equals('testing'); * * next(); * }); * }); * ``` * * @param {Number} calls The amount of calls the returned callback should called. * @param {Number} tests The amount of tests that should be completed before cb. * @param {Function} fn Completion callback. * @returns {Function} New function that does the counting. * @api public */ Assume.wait = function wait(calls, tests, fn) { // // Make the `tests` argument optional by allowing callback to be used there. // if ('function' === typeof tests) { fn = tests; tests = 0; } // // If `tests` are specified, pass it directly in to the Assume.plan function // so we can use that as given callback. // if (tests) fn = Assume.plan(tests, fn); var ignore = false; return function counter(err) { if (ignore) return; if (err || !--calls) return ignore = true, fn(err); }; }; /** * Load/execute a new plugin. * * @param {Function} plugin Plugin to be executed. * @returns {Function} Assume, for chaining purposes. * @api public */ Assume.use = function use(plugin) { plugin(this, { name: displayName, // Extract the name of a function. string: stringify, // Transform thing to a string. get: propget, // Get a value from an object. format: format, // Format an expectation message. nodejs: nodejs, // Are we running on Node.js. deep: deep, // Deep assertion. type: type, // Get class information. size: size, // Get the size of an object. each: each // Iterate over arrays. }); return Assume; }; // // Create type checks for all build-in JavaScript classes. // each(('new String§new Number§new Array§new Date§new Error§new RegExp§new Boolean§' + 'new Float32Array§new Float64Array§new Int16Array§new Int32Array§new Int8Array§' + 'new Uint16Array§new Uint32Array§new Uint8Array§new Uint8ClampedArray§' + 'new ParallelArray§new Map§new Set§new WeakMap§new WeakSet§new TypedArray(1)§' + 'new DataView(new ArrayBuffer(1))§new ArrayBuffer(1)§new Promise(function(){})§' + 'new Blob§arguments§null§undefined§new Buffer(1)§NaN§navigator§location§' + 'new Function§new Proxy({}, function(){})§Symbol("assume")§Math§async function () {}§' + 'WebAssembly' ).split('§'), function iterate(code) { var name, arg; // // Not all of these constructors are supported in the browser, we're going to // compile dedicated functions that returns a new instance of the given // constructor. If it's not supported the code will throw and we will simply // return. // try { arg = (new Function('return '+ code))(); } catch (e) { return; } name = type(arg); Assume.add(name, function typecheck(msg) { var expect = format('`%j` to @ be an %s', this.value, name) , of = type(this.value); return this.test(of === name, msg, expect, 3); }); }); // // Introduce an alternate API: // // ```js // var i = require('assume'); // // i.assume.that('foo').equals('bar'); // i.sincerely.hope.that('foo').equals('bar'); // i.expect.that('foo').equals('bar'); // ``` // Assume.hope = { that: Assume }; Assume.assign(Assume)('sincerely, expect'); Assume.assign(Assume)('assume, expect', Assume.hope); // // Expose the module. // module.exports = Assume; assume-2.3.0/package-lock.json000066400000000000000000002065341375731470000162460ustar00rootroot00000000000000{ "name": "assume", "version": "2.3.0", "lockfileVersion": 1, "requires": true, "dependencies": { "JSONStream": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", "dev": true, "requires": { "jsonparse": "^1.2.0", "through": ">=2.2.7 <3" } }, "abbrev": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.9.tgz", "integrity": "sha1-kbR5JYinc4wl813W9jdSovh3YTU=", "dev": true }, "acorn": { "version": "6.1.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz", "integrity": "sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA==", "dev": true }, "acorn-dynamic-import": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-4.0.0.tgz", "integrity": "sha512-d3OEjQV4ROpoflsnUA8HozoIR504TFxNivYEUi6uwz0IYhBkTDXGuWlNdMtybRt3nqVx/L6XqMt0FxkXuWKZhw==", "dev": true }, "acorn-node": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-1.6.2.tgz", "integrity": "sha512-rIhNEZuNI8ibQcL7ANm/mGyPukIaZsRNX9psFNQURyJW0nu6k8wjSDld20z6v2mDBWqX13pIEnk9gGZJHIlEXg==", "dev": true, "requires": { "acorn": "^6.0.2", "acorn-dynamic-import": "^4.0.0", "acorn-walk": "^6.1.0", "xtend": "^4.0.1" } }, "acorn-walk": { "version": "6.1.1", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-6.1.1.tgz", "integrity": "sha512-OtUw6JUTgxA2QoqqmrmQ7F2NYqiBPi/L2jqHyFtllhOUvXYQXf0Z1CYUinIfyT4bTCGmrA7gX9FvHA81uzCoVw==", "dev": true }, "amdefine": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", "dev": true, "optional": true }, "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "~1.0.2" } }, "array-filter": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/array-filter/-/array-filter-0.0.1.tgz", "integrity": "sha1-fajPLiZijtcygDWB/SH2fKzS7uw=", "dev": true }, "array-map": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/array-map/-/array-map-0.0.0.tgz", "integrity": "sha1-iKK6tz0c97zVwbEYoAP2b2ZfpmI=", "dev": true }, "array-reduce": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/array-reduce/-/array-reduce-0.0.0.tgz", "integrity": "sha1-FziZ0//Rx9k4PkR5Ul2+J4yrXys=", "dev": true }, "asn1.js": { "version": "4.10.1", "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz", "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==", "dev": true, "requires": { "bn.js": "^4.0.0", "inherits": "^2.0.1", "minimalistic-assert": "^1.0.0" } }, "assert": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/assert/-/assert-1.4.1.tgz", "integrity": "sha1-mZEtWRg2tab1s0XA8H7vwI/GXZE=", "dev": true, "requires": { "util": "0.10.3" }, "dependencies": { "inherits": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", "dev": true }, "util": { "version": "0.10.3", "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", "dev": true, "requires": { "inherits": "2.0.1" } } } }, "async": { "version": "1.5.2", "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", "dev": true }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true }, "base64-js": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz", "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==", "dev": true }, "bn.js": { "version": "4.11.8", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", "dev": true }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, "brorand": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=", "dev": true }, "browser-pack": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/browser-pack/-/browser-pack-6.1.0.tgz", "integrity": "sha512-erYug8XoqzU3IfcU8fUgyHqyOXqIE4tUTTQ+7mqUjQlvnXkOO6OlT9c/ZoJVHYoAaqGxr09CN53G7XIsO4KtWA==", "dev": true, "requires": { "JSONStream": "^1.0.3", "combine-source-map": "~0.8.0", "defined": "^1.0.0", "safe-buffer": "^5.1.1", "through2": "^2.0.0", "umd": "^3.0.0" } }, "browser-resolve": { "version": "1.11.3", "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.3.tgz", "integrity": "sha512-exDi1BYWB/6raKHmDTCicQfTkqwN5fioMFV4j8BsfMU4R2DK/QfZfK7kOVkmWCNANf0snkBzqGqAJBao9gZMdQ==", "dev": true, "requires": { "resolve": "1.1.7" }, "dependencies": { "resolve": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", "dev": true } } }, "browser-stdout": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz", "integrity": "sha1-81HTKWnTL6XXpVZxVCY9korjvR8=", "dev": true }, "browserify": { "version": "14.5.0", "resolved": "https://registry.npmjs.org/browserify/-/browserify-14.5.0.tgz", "integrity": "sha512-gKfOsNQv/toWz+60nSPfYzuwSEdzvV2WdxrVPUbPD/qui44rAkB3t3muNtmmGYHqrG56FGwX9SUEQmzNLAeS7g==", "dev": true, "requires": { "JSONStream": "^1.0.3", "assert": "^1.4.0", "browser-pack": "^6.0.1", "browser-resolve": "^1.11.0", "browserify-zlib": "~0.2.0", "buffer": "^5.0.2", "cached-path-relative": "^1.0.0", "concat-stream": "~1.5.1", "console-browserify": "^1.1.0", "constants-browserify": "~1.0.0", "crypto-browserify": "^3.0.0", "defined": "^1.0.0", "deps-sort": "^2.0.0", "domain-browser": "~1.1.0", "duplexer2": "~0.1.2", "events": "~1.1.0", "glob": "^7.1.0", "has": "^1.0.0", "htmlescape": "^1.1.0", "https-browserify": "^1.0.0", "inherits": "~2.0.1", "insert-module-globals": "^7.0.0", "labeled-stream-splicer": "^2.0.0", "module-deps": "^4.0.8", "os-browserify": "~0.3.0", "parents": "^1.0.1", "path-browserify": "~0.0.0", "process": "~0.11.0", "punycode": "^1.3.2", "querystring-es3": "~0.2.0", "read-only-stream": "^2.0.0", "readable-stream": "^2.0.2", "resolve": "^1.1.4", "shasum": "^1.0.0", "shell-quote": "^1.6.1", "stream-browserify": "^2.0.0", "stream-http": "^2.0.0", "string_decoder": "~1.0.0", "subarg": "^1.0.0", "syntax-error": "^1.1.1", "through2": "^2.0.0", "timers-browserify": "^1.0.1", "tty-browserify": "~0.0.0", "url": "~0.11.0", "util": "~0.10.1", "vm-browserify": "~0.0.1", "xtend": "^4.0.0" } }, "browserify-aes": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", "dev": true, "requires": { "buffer-xor": "^1.0.3", "cipher-base": "^1.0.0", "create-hash": "^1.1.0", "evp_bytestokey": "^1.0.3", "inherits": "^2.0.1", "safe-buffer": "^5.0.1" } }, "browserify-cipher": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz", "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", "dev": true, "requires": { "browserify-aes": "^1.0.4", "browserify-des": "^1.0.0", "evp_bytestokey": "^1.0.0" } }, "browserify-des": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz", "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==", "dev": true, "requires": { "cipher-base": "^1.0.1", "des.js": "^1.0.0", "inherits": "^2.0.1", "safe-buffer": "^5.1.2" } }, "browserify-rsa": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", "dev": true, "requires": { "bn.js": "^4.1.0", "randombytes": "^2.0.1" } }, "browserify-sign": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.0.4.tgz", "integrity": "sha1-qk62jl17ZYuqa/alfmMMvXqT0pg=", "dev": true, "requires": { "bn.js": "^4.1.1", "browserify-rsa": "^4.0.0", "create-hash": "^1.1.0", "create-hmac": "^1.1.2", "elliptic": "^6.0.0", "inherits": "^2.0.1", "parse-asn1": "^5.0.0" } }, "browserify-zlib": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz", "integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==", "dev": true, "requires": { "pako": "~1.0.5" } }, "buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.1.tgz", "integrity": "sha512-c+Ko0loDaFfuPWiL02ls9Xd3GO3cPVmUobQ6t3rXNUk304u6hGq+8N/kFi+QEIKhzK3uwolVhLzszmfLmMLnqg==", "dev": true, "requires": { "base64-js": "^1.0.2", "ieee754": "^1.1.4" } }, "buffer-from": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", "dev": true }, "buffer-xor": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=", "dev": true }, "builtin-status-codes": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=", "dev": true }, "cached-path-relative": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/cached-path-relative/-/cached-path-relative-1.0.2.tgz", "integrity": "sha512-5r2GqsoEb4qMTTN9J+WzXfjov+hjxT+j3u5K+kIVNIwAd99DLCJE9pBIMP1qVeybV6JiijL385Oz0DcYxfbOIg==", "dev": true }, "cipher-base": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", "dev": true, "requires": { "inherits": "^2.0.1", "safe-buffer": "^5.0.1" } }, "combine-source-map": { "version": "0.8.0", "resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.8.0.tgz", "integrity": "sha1-pY0N8ELBhvz4IqjoAV9UUNLXmos=", "dev": true, "requires": { "convert-source-map": "~1.1.0", "inline-source-map": "~0.6.0", "lodash.memoize": "~3.0.3", "source-map": "~0.5.3" } }, "commander": { "version": "2.17.1", "resolved": "https://registry.npmjs.org/commander/-/commander-2.17.1.tgz", "integrity": "sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==", "dev": true, "optional": true }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, "concat-stream": { "version": "1.5.2", "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.5.2.tgz", "integrity": "sha1-cIl4Yk2FavQaWnQd790mHadSwmY=", "dev": true, "requires": { "inherits": "~2.0.1", "readable-stream": "~2.0.0", "typedarray": "~0.0.5" }, "dependencies": { "process-nextick-args": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", "dev": true }, "readable-stream": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", "dev": true, "requires": { "core-util-is": "~1.0.0", "inherits": "~2.0.1", "isarray": "~1.0.0", "process-nextick-args": "~1.0.6", "string_decoder": "~0.10.x", "util-deprecate": "~1.0.1" } }, "string_decoder": { "version": "0.10.31", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", "dev": true } } }, "console-browserify": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=", "dev": true, "requires": { "date-now": "^0.1.4" } }, "constants-browserify": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz", "integrity": "sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U=", "dev": true }, "convert-source-map": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.1.3.tgz", "integrity": "sha1-SCnId+n+SbMWHzvzZziI4gRpmGA=", "dev": true }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, "create-ecdh": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz", "integrity": "sha512-GbEHQPMOswGpKXM9kCWVrremUcBmjteUaQ01T9rkKCPDXfUHX0IoP9LpHYo2NPFampa4e+/pFDc3jQdxrxQLaw==", "dev": true, "requires": { "bn.js": "^4.1.0", "elliptic": "^6.0.0" } }, "create-hash": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", "dev": true, "requires": { "cipher-base": "^1.0.1", "inherits": "^2.0.1", "md5.js": "^1.3.4", "ripemd160": "^2.0.1", "sha.js": "^2.4.0" } }, "create-hmac": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", "dev": true, "requires": { "cipher-base": "^1.0.3", "create-hash": "^1.1.0", "inherits": "^2.0.1", "ripemd160": "^2.0.0", "safe-buffer": "^5.0.1", "sha.js": "^2.4.8" } }, "cross-spawn": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", "dev": true, "requires": { "lru-cache": "^4.0.1", "shebang-command": "^1.2.0", "which": "^1.2.9" } }, "crypto-browserify": { "version": "3.12.0", "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", "dev": true, "requires": { "browserify-cipher": "^1.0.0", "browserify-sign": "^4.0.0", "create-ecdh": "^4.0.0", "create-hash": "^1.1.0", "create-hmac": "^1.1.0", "diffie-hellman": "^5.0.0", "inherits": "^2.0.1", "pbkdf2": "^3.0.3", "public-encrypt": "^4.0.0", "randombytes": "^2.0.0", "randomfill": "^1.0.3" } }, "dash-ast": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/dash-ast/-/dash-ast-1.0.0.tgz", "integrity": "sha512-Vy4dx7gquTeMcQR/hDkYLGUnwVil6vk4FOOct+djUnHOUWt+zJPJAaRIXaAFkPXtJjvlY7o3rfRu0/3hpnwoUA==", "dev": true }, "date-now": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", "integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=", "dev": true }, "debug": { "version": "2.6.8", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", "dev": true, "requires": { "ms": "2.0.0" } }, "deep-eql": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", "requires": { "type-detect": "^4.0.0" } }, "deep-is": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", "dev": true }, "defined": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", "dev": true }, "deps-sort": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/deps-sort/-/deps-sort-2.0.0.tgz", "integrity": "sha1-CRckkC6EZYJg65EHSMzNGvbiH7U=", "dev": true, "requires": { "JSONStream": "^1.0.3", "shasum": "^1.0.0", "subarg": "^1.0.0", "through2": "^2.0.0" } }, "des.js": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.0.tgz", "integrity": "sha1-wHTS4qpqipoH29YfmhXCzYPsjsw=", "dev": true, "requires": { "inherits": "^2.0.1", "minimalistic-assert": "^1.0.0" } }, "detective": { "version": "4.7.1", "resolved": "https://registry.npmjs.org/detective/-/detective-4.7.1.tgz", "integrity": "sha512-H6PmeeUcZloWtdt4DAkFyzFL94arpHr3NOwwmVILFiy+9Qd4JTxxXrzfyGk/lmct2qVGBwTSwSXagqu2BxmWig==", "dev": true, "requires": { "acorn": "^5.2.1", "defined": "^1.0.0" }, "dependencies": { "acorn": { "version": "5.7.3", "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", "integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==", "dev": true } } }, "diff": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/diff/-/diff-3.2.0.tgz", "integrity": "sha1-yc45Okt8vQsFinJck98pkCeGj/k=", "dev": true }, "diffie-hellman": { "version": "5.0.3", "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", "dev": true, "requires": { "bn.js": "^4.1.0", "miller-rabin": "^4.0.0", "randombytes": "^2.0.0" } }, "domain-browser": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.1.7.tgz", "integrity": "sha1-hnqksJP6oF8d4IwG9NeyH9+GmLw=", "dev": true }, "duplexer2": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", "integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=", "dev": true, "requires": { "readable-stream": "^2.0.2" } }, "elliptic": { "version": "6.4.1", "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.1.tgz", "integrity": "sha512-BsXLz5sqX8OHcsh7CqBMztyXARmGQ3LWPtGjJi6DiJHq5C/qvi9P3OqgswKSDftbu8+IoI/QDTAm2fFnQ9SZSQ==", "dev": true, "requires": { "bn.js": "^4.4.0", "brorand": "^1.0.1", "hash.js": "^1.0.0", "hmac-drbg": "^1.0.0", "inherits": "^2.0.1", "minimalistic-assert": "^1.0.0", "minimalistic-crypto-utils": "^1.0.0" } }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "dev": true }, "escodegen": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.8.1.tgz", "integrity": "sha1-WltTr0aTEQvrsIZ6o0MN07cKEBg=", "dev": true, "requires": { "esprima": "^2.7.1", "estraverse": "^1.9.1", "esutils": "^2.0.2", "optionator": "^0.8.1", "source-map": "~0.2.0" }, "dependencies": { "source-map": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.2.0.tgz", "integrity": "sha1-2rc/vPwrqBm03gO9b26qSBZLP50=", "dev": true, "optional": true, "requires": { "amdefine": ">=0.0.4" } } } }, "esprima": { "version": "2.7.3", "resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz", "integrity": "sha1-luO3DVd59q1JzQMmc9HDEnZ7pYE=", "dev": true }, "estraverse": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.9.3.tgz", "integrity": "sha1-r2fy3JIlgkFZUJJgkaQAXSnJu0Q=", "dev": true }, "esutils": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", "dev": true }, "events": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=", "dev": true }, "evp_bytestokey": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", "dev": true, "requires": { "md5.js": "^1.3.4", "safe-buffer": "^5.1.1" } }, "fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, "fn.name": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/fn.name/-/fn.name-1.1.0.tgz", "integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==" }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", "dev": true }, "get-assigned-identifiers": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/get-assigned-identifiers/-/get-assigned-identifiers-1.2.0.tgz", "integrity": "sha512-mBBwmeGTrxEMO4pMaaf/uUEFHnYtwr8FTe8Y/mer4rcV/bye0qGm6pw1bGZFGStxC5O76c5ZAVBGnqHmOaJpdQ==", "dev": true }, "glob": { "version": "7.1.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", "dev": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", "minimatch": "^3.0.4", "once": "^1.3.0", "path-is-absolute": "^1.0.0" } }, "graceful-readlink": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=", "dev": true }, "growl": { "version": "1.9.2", "resolved": "https://registry.npmjs.org/growl/-/growl-1.9.2.tgz", "integrity": "sha1-Dqd0NxXbjY3ixe3hd14bRayFwC8=", "dev": true }, "handlebars": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.1.0.tgz", "integrity": "sha512-l2jRuU1NAWK6AW5qqcTATWQJvNPEwkM7NEKSiv/gqOsoSQbVoWyqVEY5GS+XPQ88zLNmqASRpzfdm8d79hJS+w==", "dev": true, "requires": { "async": "^2.5.0", "optimist": "^0.6.1", "source-map": "^0.6.1", "uglify-js": "^3.1.4" }, "dependencies": { "async": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/async/-/async-2.6.2.tgz", "integrity": "sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg==", "dev": true, "requires": { "lodash": "^4.17.11" } }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true } } }, "has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", "dev": true, "requires": { "function-bind": "^1.1.1" } }, "has-flag": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", "dev": true }, "hash-base": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz", "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", "dev": true, "requires": { "inherits": "^2.0.1", "safe-buffer": "^5.0.1" } }, "hash.js": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", "dev": true, "requires": { "inherits": "^2.0.3", "minimalistic-assert": "^1.0.1" } }, "he": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", "dev": true }, "hmac-drbg": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", "dev": true, "requires": { "hash.js": "^1.0.3", "minimalistic-assert": "^1.0.0", "minimalistic-crypto-utils": "^1.0.1" } }, "htmlescape": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/htmlescape/-/htmlescape-1.1.1.tgz", "integrity": "sha1-OgPtwiFLyjtmQko+eVk0lQnLA1E=", "dev": true }, "https-browserify": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz", "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=", "dev": true }, "ieee754": { "version": "1.1.12", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.12.tgz", "integrity": "sha512-GguP+DRY+pJ3soyIiGPTvdiVXjZ+DbXOxGpXn3eMvNW4x4irjqXm4wHKscC+TfxSJ0yw/S1F24tqdMNsMZTiLA==", "dev": true }, "indexof": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=", "dev": true }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true, "requires": { "once": "^1.3.0", "wrappy": "1" } }, "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, "inline-source-map": { "version": "0.6.2", "resolved": "https://registry.npmjs.org/inline-source-map/-/inline-source-map-0.6.2.tgz", "integrity": "sha1-+Tk0ccGKedFyT4Y/o4tYY3Ct4qU=", "dev": true, "requires": { "source-map": "~0.5.3" } }, "insert-module-globals": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.2.0.tgz", "integrity": "sha512-VE6NlW+WGn2/AeOMd496AHFYmE7eLKkUY6Ty31k4og5vmA3Fjuwe9v6ifH6Xx/Hz27QvdoMoviw1/pqWRB09Sw==", "dev": true, "requires": { "JSONStream": "^1.0.3", "acorn-node": "^1.5.2", "combine-source-map": "^0.8.0", "concat-stream": "^1.6.1", "is-buffer": "^1.1.0", "path-is-absolute": "^1.0.1", "process": "~0.11.0", "through2": "^2.0.0", "undeclared-identifiers": "^1.1.2", "xtend": "^4.0.0" }, "dependencies": { "concat-stream": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", "dev": true, "requires": { "buffer-from": "^1.0.0", "inherits": "^2.0.3", "readable-stream": "^2.2.2", "typedarray": "^0.0.6" } }, "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true } } }, "is-buffer": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==" }, "is-node": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-node/-/is-node-1.0.2.tgz", "integrity": "sha1-19ACdF733ru3R36YiVarCk/MtlM=" }, "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "dev": true }, "isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "dev": true }, "istanbul": { "version": "0.4.5", "resolved": "https://registry.npmjs.org/istanbul/-/istanbul-0.4.5.tgz", "integrity": "sha1-ZcfXPUxNqE1POsMQuRj7C4Azczs=", "dev": true, "requires": { "abbrev": "1.0.x", "async": "1.x", "escodegen": "1.8.x", "esprima": "2.7.x", "glob": "^5.0.15", "handlebars": "^4.0.1", "js-yaml": "3.x", "mkdirp": "0.5.x", "nopt": "3.x", "once": "1.x", "resolve": "1.1.x", "supports-color": "^3.1.0", "which": "^1.1.1", "wordwrap": "^1.0.0" }, "dependencies": { "glob": { "version": "5.0.15", "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", "dev": true, "requires": { "inflight": "^1.0.4", "inherits": "2", "minimatch": "2 || 3", "once": "^1.3.0", "path-is-absolute": "^1.0.0" } }, "resolve": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", "dev": true } } }, "js-yaml": { "version": "3.12.2", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.2.tgz", "integrity": "sha512-QHn/Lh/7HhZ/Twc7vJYQTkjuCa0kaCcDcjK5Zlk2rvnUpy7DxMJ23+Jc2dcyvltwQVg1nygAVlB2oRDFHoRS5Q==", "dev": true, "requires": { "argparse": "^1.0.7", "esprima": "^4.0.0" }, "dependencies": { "esprima": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", "dev": true } } }, "json-stable-stringify": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-0.0.1.tgz", "integrity": "sha1-YRwj6BTbN1Un34URk9tZ3Sryf0U=", "dev": true, "requires": { "jsonify": "~0.0.0" } }, "json3": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/json3/-/json3-3.3.2.tgz", "integrity": "sha1-PAQ0dD35Pi9cQq7nsZvLSDV19OE=", "dev": true }, "jsonify": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", "dev": true }, "jsonparse": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", "dev": true }, "labeled-stream-splicer": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-2.0.1.tgz", "integrity": "sha512-MC94mHZRvJ3LfykJlTUipBqenZz1pacOZEMhhQ8dMGcDHs0SBE5GbsavUXV7YtP3icBW17W0Zy1I0lfASmo9Pg==", "dev": true, "requires": { "inherits": "^2.0.1", "isarray": "^2.0.4", "stream-splicer": "^2.0.0" }, "dependencies": { "isarray": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.4.tgz", "integrity": "sha512-GMxXOiUirWg1xTKRipM0Ek07rX+ubx4nNVElTJdNLYmNO/2YrDkgJGw9CljXn+r4EWiDQg/8lsRdHyg2PJuUaA==", "dev": true } } }, "left-pad": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/left-pad/-/left-pad-1.3.0.tgz", "integrity": "sha512-XI5MPzVNApjAyhQzphX8BkmKsKUxD4LdyK24iZeQGinBN9yTQT3bFlCBy/aVx2HrNcqQGsdot8ghrjyrvMCoEA==" }, "levn": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", "dev": true, "requires": { "prelude-ls": "~1.1.2", "type-check": "~0.3.2" } }, "lodash": { "version": "4.17.11", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", "dev": true }, "lodash._baseassign": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz", "integrity": "sha1-jDigmVAPIVrQnlnxci/QxSv+Ck4=", "dev": true, "requires": { "lodash._basecopy": "^3.0.0", "lodash.keys": "^3.0.0" } }, "lodash._basecopy": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", "integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=", "dev": true }, "lodash._basecreate": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz", "integrity": "sha1-G8ZhYU2qf8MRt9A78WgGoCE8+CE=", "dev": true }, "lodash._getnative": { "version": "3.9.1", "resolved": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz", "integrity": "sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=", "dev": true }, "lodash._isiterateecall": { "version": "3.0.9", "resolved": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz", "integrity": "sha1-UgOte6Ql+uhCRg5pbbnPPmqsBXw=", "dev": true }, "lodash.create": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/lodash.create/-/lodash.create-3.1.1.tgz", "integrity": "sha1-1/KEnw29p+BGgruM1yqwIkYd6+c=", "dev": true, "requires": { "lodash._baseassign": "^3.0.0", "lodash._basecreate": "^3.0.0", "lodash._isiterateecall": "^3.0.0" } }, "lodash.isarguments": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=", "dev": true }, "lodash.isarray": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz", "integrity": "sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=", "dev": true }, "lodash.keys": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", "dev": true, "requires": { "lodash._getnative": "^3.0.0", "lodash.isarguments": "^3.0.0", "lodash.isarray": "^3.0.0" } }, "lodash.memoize": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-3.0.4.tgz", "integrity": "sha1-LcvSwofLwKVcxCMovQxzYVDVPj8=", "dev": true }, "lru-cache": { "version": "4.1.5", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", "dev": true, "requires": { "pseudomap": "^1.0.2", "yallist": "^2.1.2" } }, "md5.js": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", "dev": true, "requires": { "hash-base": "^3.0.0", "inherits": "^2.0.1", "safe-buffer": "^5.1.2" } }, "miller-rabin": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", "dev": true, "requires": { "bn.js": "^4.0.0", "brorand": "^1.0.1" } }, "minimalistic-assert": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", "dev": true }, "minimalistic-crypto-utils": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=", "dev": true }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true }, "mkdirp": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, "requires": { "minimist": "0.0.8" }, "dependencies": { "minimist": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", "dev": true } } }, "mocha": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/mocha/-/mocha-3.5.3.tgz", "integrity": "sha512-/6na001MJWEtYxHOV1WLfsmR4YIynkUEhBwzsb+fk2qmQ3iqsi258l/Q2MWHJMImAcNpZ8DEdYAK72NHoIQ9Eg==", "dev": true, "requires": { "browser-stdout": "1.3.0", "commander": "2.9.0", "debug": "2.6.8", "diff": "3.2.0", "escape-string-regexp": "1.0.5", "glob": "7.1.1", "growl": "1.9.2", "he": "1.1.1", "json3": "3.3.2", "lodash.create": "3.1.1", "mkdirp": "0.5.1", "supports-color": "3.1.2" }, "dependencies": { "commander": { "version": "2.9.0", "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz", "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=", "dev": true, "requires": { "graceful-readlink": ">= 1.0.0" } }, "glob": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz", "integrity": "sha1-gFIR3wT6rxxjo2ADBs31reULLsg=", "dev": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", "minimatch": "^3.0.2", "once": "^1.3.0", "path-is-absolute": "^1.0.0" } }, "supports-color": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.1.2.tgz", "integrity": "sha1-cqJiiU2dQIuVbKBf83su2KbiotU=", "dev": true, "requires": { "has-flag": "^1.0.0" } } } }, "module-deps": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-4.1.1.tgz", "integrity": "sha1-IyFYM/HaE/1gbMuAh7RIUty4If0=", "dev": true, "requires": { "JSONStream": "^1.0.3", "browser-resolve": "^1.7.0", "cached-path-relative": "^1.0.0", "concat-stream": "~1.5.0", "defined": "^1.0.0", "detective": "^4.0.0", "duplexer2": "^0.1.2", "inherits": "^2.0.1", "parents": "^1.0.0", "readable-stream": "^2.0.2", "resolve": "^1.1.3", "stream-combiner2": "^1.1.1", "subarg": "^1.0.0", "through2": "^2.0.0", "xtend": "^4.0.0" } }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, "nopt": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", "dev": true, "requires": { "abbrev": "1" } }, "object-inspect": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.6.0.tgz", "integrity": "sha512-GJzfBZ6DgDAmnuaM3104jR4s1Myxr3Y3zfIyN4z3UdqN69oSRacNK8UhnobDdC+7J2AHCjGwxQubNJfE70SXXQ==" }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, "requires": { "wrappy": "1" } }, "optimist": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", "dev": true, "requires": { "minimist": "~0.0.1", "wordwrap": "~0.0.2" }, "dependencies": { "minimist": { "version": "0.0.10", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=", "dev": true }, "wordwrap": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", "dev": true } } }, "optionator": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", "dev": true, "requires": { "deep-is": "~0.1.3", "fast-levenshtein": "~2.0.4", "levn": "~0.3.0", "prelude-ls": "~1.1.2", "type-check": "~0.3.2", "wordwrap": "~1.0.0" } }, "os-browserify": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz", "integrity": "sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=", "dev": true }, "os-shim": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/os-shim/-/os-shim-0.1.3.tgz", "integrity": "sha1-a2LDeRz3kJ6jXtRuF2WLtBfLORc=", "dev": true }, "pako": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.10.tgz", "integrity": "sha512-0DTvPVU3ed8+HNXOu5Bs+o//Mbdj9VNQMUOe9oKCwh8l0GNwpTDMKCWbRjgtD291AWnkAgkqA/LOnQS8AmS1tw==", "dev": true }, "parents": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parents/-/parents-1.0.1.tgz", "integrity": "sha1-/t1NK/GTp3dF/nHjcdc8MwfZx1E=", "dev": true, "requires": { "path-platform": "~0.11.15" } }, "parse-asn1": { "version": "5.1.4", "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.4.tgz", "integrity": "sha512-Qs5duJcuvNExRfFZ99HDD3z4mAi3r9Wl/FOjEOijlxwCZs7E7mW2vjTpgQ4J8LpTF8x5v+1Vn5UQFejmWT11aw==", "dev": true, "requires": { "asn1.js": "^4.0.0", "browserify-aes": "^1.0.0", "create-hash": "^1.1.0", "evp_bytestokey": "^1.0.0", "pbkdf2": "^3.0.3", "safe-buffer": "^5.1.1" } }, "path-browserify": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz", "integrity": "sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ==", "dev": true }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, "path-parse": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", "dev": true }, "path-platform": { "version": "0.11.15", "resolved": "https://registry.npmjs.org/path-platform/-/path-platform-0.11.15.tgz", "integrity": "sha1-6GQhf3TDaFDwhSt43Hv31KVyG/I=", "dev": true }, "pbkdf2": { "version": "3.0.17", "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz", "integrity": "sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA==", "dev": true, "requires": { "create-hash": "^1.1.2", "create-hmac": "^1.1.4", "ripemd160": "^2.0.1", "safe-buffer": "^5.0.1", "sha.js": "^2.4.8" } }, "pre-commit": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/pre-commit/-/pre-commit-1.2.2.tgz", "integrity": "sha1-287g7p3nI15X95xW186UZBpp7sY=", "dev": true, "requires": { "cross-spawn": "^5.0.1", "spawn-sync": "^1.0.15", "which": "1.2.x" }, "dependencies": { "which": { "version": "1.2.14", "resolved": "https://registry.npmjs.org/which/-/which-1.2.14.tgz", "integrity": "sha1-mofEN48D6CfOyvGs31bHNsAcFOU=", "dev": true, "requires": { "isexe": "^2.0.0" } } } }, "prelude-ls": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", "dev": true }, "process": { "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", "dev": true }, "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "propget": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/propget/-/propget-1.1.0.tgz", "integrity": "sha1-bBx6yaCcBb21yWfwzY4cCUCf72s=" }, "pruddy-error": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/pruddy-error/-/pruddy-error-2.0.2.tgz", "integrity": "sha512-cEMUxXtU7iD+he5Hh1Jr3RHdTvAID2/VHBpC2TDLWP7UmbvZmR4/B50mQK7lguZhqcBTwdtsN9JI8diVTWedNw==", "requires": { "is-node": "^1.0.2", "left-pad": "^1.2.0" } }, "pseudomap": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", "dev": true }, "public-encrypt": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", "integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==", "dev": true, "requires": { "bn.js": "^4.1.0", "browserify-rsa": "^4.0.0", "create-hash": "^1.1.0", "parse-asn1": "^5.0.0", "randombytes": "^2.0.1", "safe-buffer": "^5.1.2" } }, "punycode": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", "dev": true }, "querystring": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=", "dev": true }, "querystring-es3": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz", "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=", "dev": true }, "randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", "dev": true, "requires": { "safe-buffer": "^5.1.0" } }, "randomfill": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", "dev": true, "requires": { "randombytes": "^2.0.5", "safe-buffer": "^5.1.0" } }, "read-only-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/read-only-stream/-/read-only-stream-2.0.0.tgz", "integrity": "sha1-JyT9aoET1zdkrCiNQ4YnDB2/F/A=", "dev": true, "requires": { "readable-stream": "^2.0.2" } }, "readable-stream": { "version": "2.3.6", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "requires": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", "isarray": "~1.0.0", "process-nextick-args": "~2.0.0", "safe-buffer": "~5.1.1", "string_decoder": "~1.1.1", "util-deprecate": "~1.0.1" }, "dependencies": { "string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { "safe-buffer": "~5.1.0" } } } }, "resolve": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.0.tgz", "integrity": "sha512-3sUr9aq5OfSg2S9pNtPA9hL1FVEAjvfOC4leW0SNf/mpnaakz2a9femSd6LqAww2RaFctwyf1lCqnTHuF1rxDg==", "dev": true, "requires": { "path-parse": "^1.0.6" } }, "ripemd160": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", "dev": true, "requires": { "hash-base": "^3.0.0", "inherits": "^2.0.1" } }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", "dev": true }, "sha.js": { "version": "2.4.11", "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", "dev": true, "requires": { "inherits": "^2.0.1", "safe-buffer": "^5.0.1" } }, "shasum": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/shasum/-/shasum-1.0.2.tgz", "integrity": "sha1-5wEjENj0F/TetXEhUOVni4euVl8=", "dev": true, "requires": { "json-stable-stringify": "~0.0.0", "sha.js": "~2.4.4" } }, "shebang-command": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", "dev": true, "requires": { "shebang-regex": "^1.0.0" } }, "shebang-regex": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", "dev": true }, "shell-quote": { "version": "1.6.1", "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.6.1.tgz", "integrity": "sha1-9HgZSczkAmlxJ0MOo7PFR29IF2c=", "dev": true, "requires": { "array-filter": "~0.0.0", "array-map": "~0.0.0", "array-reduce": "~0.0.0", "jsonify": "~0.0.0" } }, "simple-concat": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.0.tgz", "integrity": "sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY=", "dev": true }, "source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", "dev": true }, "spawn-sync": { "version": "1.0.15", "resolved": "https://registry.npmjs.org/spawn-sync/-/spawn-sync-1.0.15.tgz", "integrity": "sha1-sAeZVX63+wyDdsKdROih6mfldHY=", "dev": true, "requires": { "concat-stream": "^1.4.7", "os-shim": "^0.1.2" } }, "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, "stream-browserify": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.2.tgz", "integrity": "sha512-nX6hmklHs/gr2FuxYDltq8fJA1GDlxKQCz8O/IM4atRqBH8OORmBNgfvW5gG10GT/qQ9u0CzIvr2X5Pkt6ntqg==", "dev": true, "requires": { "inherits": "~2.0.1", "readable-stream": "^2.0.2" } }, "stream-combiner2": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.1.1.tgz", "integrity": "sha1-+02KFCDqNidk4hrUeAOXvry0HL4=", "dev": true, "requires": { "duplexer2": "~0.1.0", "readable-stream": "^2.0.2" } }, "stream-http": { "version": "2.8.3", "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.8.3.tgz", "integrity": "sha512-+TSkfINHDo4J+ZobQLWiMouQYB+UVYFttRA94FpEzzJ7ZdqcL4uUUQ7WkdkI4DSozGmgBUE/a47L+38PenXhUw==", "dev": true, "requires": { "builtin-status-codes": "^3.0.0", "inherits": "^2.0.1", "readable-stream": "^2.3.6", "to-arraybuffer": "^1.0.0", "xtend": "^4.0.0" } }, "stream-splicer": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/stream-splicer/-/stream-splicer-2.0.0.tgz", "integrity": "sha1-G2O+Q4oTPktnHMGTUZdgAXWRDYM=", "dev": true, "requires": { "inherits": "^2.0.1", "readable-stream": "^2.0.2" } }, "string_decoder": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", "dev": true, "requires": { "safe-buffer": "~5.1.0" } }, "subarg": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/subarg/-/subarg-1.0.0.tgz", "integrity": "sha1-9izxdYHplrSPyWVpn1TAauJouNI=", "dev": true, "requires": { "minimist": "^1.1.0" } }, "supports-color": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz", "integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=", "dev": true, "requires": { "has-flag": "^1.0.0" } }, "syntax-error": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-1.4.0.tgz", "integrity": "sha512-YPPlu67mdnHGTup2A8ff7BC2Pjq0e0Yp/IyTFN03zWO0RcK07uLcbi7C2KpGR2FvWbaB0+bfE27a+sBKebSo7w==", "dev": true, "requires": { "acorn-node": "^1.2.0" } }, "through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", "dev": true }, "through2": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", "dev": true, "requires": { "readable-stream": "~2.3.6", "xtend": "~4.0.1" } }, "timers-browserify": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-1.4.2.tgz", "integrity": "sha1-ycWLV1voQHN1y14kYtrO50NZ9B0=", "dev": true, "requires": { "process": "~0.11.0" } }, "to-arraybuffer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz", "integrity": "sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M=", "dev": true }, "tty-browserify": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz", "integrity": "sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw==", "dev": true }, "type-check": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", "dev": true, "requires": { "prelude-ls": "~1.1.2" } }, "type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==" }, "typedarray": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, "uglify-js": { "version": "3.4.9", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.9.tgz", "integrity": "sha512-8CJsbKOtEbnJsTyv6LE6m6ZKniqMiFWmm9sRbopbkGs3gMPPfd3Fh8iIA4Ykv5MgaTbqHr4BaoGLJLZNhsrW1Q==", "dev": true, "optional": true, "requires": { "commander": "~2.17.1", "source-map": "~0.6.1" }, "dependencies": { "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true, "optional": true } } }, "umd": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/umd/-/umd-3.0.3.tgz", "integrity": "sha512-4IcGSufhFshvLNcMCV80UnQVlZ5pMOC8mvNPForqwA4+lzYQuetTESLDQkeLmihq8bRcnpbQa48Wb8Lh16/xow==", "dev": true }, "undeclared-identifiers": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/undeclared-identifiers/-/undeclared-identifiers-1.1.3.tgz", "integrity": "sha512-pJOW4nxjlmfwKApE4zvxLScM/njmwj/DiUBv7EabwE4O8kRUy+HIwxQtZLBPll/jx1LJyBcqNfB3/cpv9EZwOw==", "dev": true, "requires": { "acorn-node": "^1.3.0", "dash-ast": "^1.0.0", "get-assigned-identifiers": "^1.2.0", "simple-concat": "^1.0.0", "xtend": "^4.0.1" } }, "url": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", "integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=", "dev": true, "requires": { "punycode": "1.3.2", "querystring": "0.2.0" }, "dependencies": { "punycode": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=", "dev": true } } }, "util": { "version": "0.10.4", "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz", "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==", "dev": true, "requires": { "inherits": "2.0.3" } }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, "vm-browserify": { "version": "0.0.4", "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz", "integrity": "sha1-XX6kW7755Kb/ZflUOOCofDV9WnM=", "dev": true, "requires": { "indexof": "0.0.1" } }, "which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", "dev": true, "requires": { "isexe": "^2.0.0" } }, "wordwrap": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", "dev": true }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, "xtend": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", "dev": true }, "yallist": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", "dev": true } } } assume-2.3.0/package.json000066400000000000000000000026661375731470000153200ustar00rootroot00000000000000{ "name": "assume", "version": "2.3.0", "description": "Expect-like assertions that works seamlessly in node and browsers", "main": "index.js", "types": "index.d.ts", "scripts": { "coverage": "istanbul cover ./node_modules/.bin/_mocha -- --reporter spec --ui bdd ./test/*.test.js", "prepublishOnly": "mkdir -p dist && browserify index.js -o dist/assume.js --standalone assume", "node": "node --allow-natives-syntax --harmony ./node_modules/mocha/bin/_mocha ./test/*.test.js", "test": "mocha ./test/*.test.js", "test-travis": "npm run node && istanbul cover node_modules/.bin/_mocha --report lcovonly -- --reporter spec --ui bdd ./test/*.test.js" }, "repository": { "type": "git", "url": "git://github.com/bigpipe/assume.git" }, "bugs": { "url": "https://github.com/bigpipe/assume/issues" }, "keywords": [ "assert", "assertion", "asserts", "assume", "bdd", "expect", "expect.js", "should", "shouldjs", "spec", "tdd", "test", "testing", "tests", "unit testing", "unit" ], "author": "Arnout Kazemier", "license": "MIT", "devDependencies": { "browserify": "14.x.x", "istanbul": "0.4.x", "mocha": "3.x.x", "pre-commit": "1.x.x" }, "dependencies": { "deep-eql": "^3.0.1", "fn.name": "^1.0.1", "is-buffer": "^2.0.0", "object-inspect": "^1.5.0", "propget": "^1.1.0", "pruddy-error": "^2.0.2" } } assume-2.3.0/test/000077500000000000000000000000001375731470000137775ustar00rootroot00000000000000assume-2.3.0/test/assume.test.js000066400000000000000000001201571375731470000166160ustar00rootroot00000000000000// // This should be out-side of the `use strict` statement so our `this` value // is set to the global or window instead of `undefined`. // if ('undefined' === typeof global) global = (function that() { return this; }()); describe('Assume', function assertions() { 'use strict'; var assume = require('../'); if ('stackTraceLimit' in Error) it('can configure the amount stacks to slice off', function (next) { Error.stackTraceLimit = 5; var assumption = assume('foo'); assumption.sliceStack = 3; try { assumption.equals('bar'); } catch (e) { var stack = e.stack.split('\n') , ats = 0; // // We need to count the `ats` as in Node we also include the failing line // of code. // for (var i = 0; i < stack.length; i++) { if (stack[i].trim().indexOf('at ') === 0) { ats++; } } assume(ats).equals(3); // // Reset value again to normal level. // Error.stackTraceLimit = 10; next(); } }); it('throw Error instances', function (next) { try { assume('foo').equals('bar'); } catch (e) { assume(e).is.instanceOf(Error); next(); } }); it('aliases chain properly', function() { assume(1).is.to.be.been.is.was.and.has.have.had.with.that.at.of.same.does.did.itself.which.equals(1); }); describe('#csliceStacklone', function () { it('increases slice for each clone', function () { var a = assume('x') , b = a.clone('b'); a.equals('x'); b.equals('b'); assume(b.sliceStack).to.equal(a.sliceStack + 1); assume(b.clone().sliceStack).to.equal(a.sliceStack + 2); }); it('defaults to the same value if no clone value is provided', function () { var a = assume('x'); a.clone().equals('x'); }); it('can clone falsy values', function () { var a = assume('x'); a.clone('').equals(''); a.clone(null).equals(null); a.clone(undefined).equals(undefined); a.clone(false).equals(false); a.clone(0).equals(0); }); }); describe('#a', function () { it('is aliased as `an`', function () { var x = assume('foo'); if (x.a !== x.an) throw new Error('Incorrectly aliased'); }); it('classifies NaN', function (next) { assume(NaN).to.be.a('nan'); try { assume('foo').to.be.a('nan'); } catch (e) { next(); } }); it('classifies undefined', function (next) { assume(undefined).to.be.a('undefined'); assume(void 0).to.be.a('undefined'); try { assume(null).to.be.a('undefined'); } catch (e) { next(); } }); it('classifies undefined', function (next) { assume(null).to.be.a('null'); try { assume(undefined).to.be.a('null'); } catch (e) { next(); } }); it('classifies arguments', function (next) { assume(arguments).to.be.a('arguments'); try { assume(null).to.be.a('arguments'); } catch (e) { next(); } }); it('classifies strings', function (next) { assume(String('foo')).to.be.a('string'); assume('string').to.be.a('string'); try { assume(['array']).to.be.a('string'); } catch (e) { next(); } }); it('classifies numbers', function (next) { assume(Number('0.1')).to.be.a('number'); assume(0).to.be.a('number'); try { assume(['array']).to.be.a('number'); } catch (e) { next(); } }); it('classifies arrays', function (next) { assume(new Array(99)).to.be.a('array'); assume([]).to.be.a('array'); try { assume(arguments).to.be.a('array'); } catch (e) { next(); } }); it('classifies dates', function (next) { assume(new Date()).to.be.a('date'); try { assume('2014/04/04').to.be.a('date'); } catch (e) { next(); } }); it('classifies errors', function (next) { assume(new Error('foo')).to.be.a('error'); try { assume('foo').to.be.a('error'); } catch (e) { next(); } }); it('classifies regexps', function (next) { assume(new RegExp('foo', 'm')).to.be.a('regexp'); assume(/foo/).to.be.a('regexp'); try { assume('/regexp/').to.be.a('regexp'); } catch (e) { next(); } }); it('classifies booleans', function (next) { assume(Boolean(0)).to.be.a('boolean'); assume(Boolean(1)).to.be.a('boolean'); assume(false).to.be.a('boolean'); assume(true).to.be.a('boolean'); try { assume('true').to.be.a('boolean'); } catch (e) { next(); } }); if (global.Buffer) it('classifies buffers', function (next) { assume(new Buffer(0)).to.be.a('buffer'); try { assume({}).to.be.a('buffer'); } catch (e) { next(); } }); if (global.Float32Array) it('classifies float32arrays', function (next) { assume(new Float32Array(2)).to.be.a('float32array'); try { assume([]).to.be.a('float32array'); } catch (e) { next(); } }); if (global.Float64Array) it('classifies float64arrays', function (next) { assume(new Float64Array(2)).to.be.a('float64array'); try { assume([]).to.be.a('float64array'); } catch (e) { next(); } }); if (global.Int16Array) it('classifies int16arrays', function (next) { assume(new Int16Array()).to.be.a('int16array'); try { assume([]).to.be.a('int16array'); } catch (e) { next(); } }); if (global.Int32Array) it('classifies int32arrays', function (next) { assume(new Int32Array()).to.be.a('int32array'); try { assume(new Int16Array()).to.be.a('int32array'); } catch (e) { next(); } }); if (global.Int8Array) it('classifies int8arrays', function (next) { assume(new Int8Array()).to.be.a('int8array'); try { assume([]).to.be.a('int8array'); } catch (e) { next(); } }); if (global.Uint16Array) it('classifies uint16arrays', function (next) { assume(new Uint16Array()).to.be.a('uint16array'); try { assume(new Int16Array()).to.be.a('uint16array'); } catch (e) { next(); } }); if (global.Uint32Array) it('classifies uint32arrays', function (next) { assume(new Uint32Array()).to.be.a('uint32array'); try { assume(new Uint16Array()).to.be.a('uint32array'); } catch (e) { next(); } }); if (global.Uint8Array) it('classifies uint8arrays', function (next) { assume(new Uint8Array()).to.be.a('uint8array'); try { assume([]).to.be.a('uint8array'); } catch (e) { next(); } }); }); describe('#eitherOfType', function () { it('is aliased as `eitherOfType`, `oneOfType`', function () { var x = assume('foo'); if (x.eitherOfType !== x.oneOfType) throw new Error('Incorrectly aliased'); }); it('classifies a valid type', function (next) { assume([]).to.be.eitherOfType(['string', 'array']); try { assume({}).to.be.eitherOfType(['string', 'array']); } catch (e) { next(); } }); it('supports negation properly', function (next) { assume([]).to.not.be.eitherOfType(['string', 'object']) try { assume({}).to.not.be.eitherOfType(['string', 'object']); } catch (e) { next(); } }); }); describe('#instanceof', function () { function Foo() {} function Bar() {} it('is aliased as `instanceOf`, `inherit`, `inherits`', function () { var foo = new Foo() , x = assume(foo); if ( x.instanceOf !== x.instanceof || x.inherit !== x.instanceof || x.inherits !== x.instanceof ) throw new Error('Incorrectly aliased'); }); it('correctly checks the instance', function (next) { assume(new Foo).is.instanceOf(Foo); try { assume(new Foo).is.instanceOf(Bar); } catch (e) { next(); } }); }); describe('#includes', function () { it('is aliased as `instanceOf`, `inherit`, `inherits`', function () { var x = assume('aaaabe'); if ( x.include !== x.includes || x.contain !== x.includes || x.contains !== x.includes ) throw new Error('Incorrectly aliased'); }); it('check if a key in an object', function (next) { var obj = { foo: 'bar' }; assume(obj).includes('foo'); try { assume(obj).includes('bar'); } catch (e) { next(); } }); it('chars are in a given string', function (next) { var string = 'hello world i like apples AND cows'; assume(string).includes('hello'); assume(string).includes('AND'); try { assume(string).includes('farts'); } catch (e) { next(); } }); it('check array indexes', function (next) { var arr = [1, 3, 5, 9, 0]; assume(arr).includes(3); assume(arr).includes(0); try { assume(arr).includes(7); } catch (e) { next(); } }); it('can deeply check array values', function () { var arr = [{ one: 1 }, { two: 2 }]; assume(arr).deep.includes({ one: 1 }); assume(arr).deep.includes({ two: 2 }); }); }); describe('#ok', function () { it('is aliased as `truthy`, `truly`, `okay`', function () { var x = assume('aaaabe'); if ( x.ok !== x.truthy || x.ok !== x.truly || x.ok !== x.okay ) throw new Error('Incorrectly aliased'); }); it('is ok', function (next) { assume(1).is.ok(); assume(2).is.ok(); assume('f').is.ok(); assume([]).is.ok(); assume(true).is.ok(); try { assume(0).is.ok(); } catch (e) { try { assume(null).is.ok(); } catch (e) { try { assume(undefined).is.ok(); } catch (e) { try { assume('').is.ok(); } catch (e) { next(); } } } } }); }); describe('#falsely', function () { it('is aliased as `falsey` and `falsy`', function () { var x = assume('aaaabe'); if ( x.falsely !== x.falsey || x.falsely !== x.falsy ) throw new Error('Incorrectly aliased'); }); it('is falsely', function (next) { assume(0).is.falsely(); assume('').is.falsely(); assume(null).is.falsely(); assume(undefined).is.falsely(); assume(false).is.falsely(); try { assume(1).is.falsely(); } catch (e) { try { assume('fo').is.falsely(); } catch (e) { try { assume([]).is.falsely(); } catch (e) { try { assume(true).is.falsely(); } catch (e) { next(); } } } } }); }); describe('#true', function () { it('only checks booleans', function (next) { assume(true).is.true(); try { assume(false).is.true(); } catch (e) { try { assume(1).is.true(); } catch (e) { try { assume([]).is.true(); } catch (e) { next(); } } } }); }); describe('#false', function () { it('only checks booleans', function (next) { assume(false).is.false(); try { assume(true).is.false(); } catch (e) { try { assume(0).is.false(); } catch (e) { try { assume(undefined).is.false(); } catch (e) { next(); } } } }); }); describe('#exists', function () { it('is aliased as `exist`', function () { var x = assume('aaaabe'); if (x.exists !== x.exist) throw new Error('Incorrectly aliased'); }); it('checks if values are not null', function (next) { assume(1).exists(); assume(0).exists(); assume(false).exists(); assume('').exists(); try { assume(null).exists(); } catch (e) { try { assume(undefined).exists(); } catch (e) { next(); } } }); }); describe('#length', function () { it('is aliased as `lengthOf`, `size`', function () { var x = assume('aaaabe'); if ( x.length !== x.size || x.length !== x.lengthOf ) throw new Error('Incorrectly aliased'); }); it('checks the length of a string', function (next) { var str = 'foobar'; assume(str).length(str.length); try { assume(str).length(1); } catch (e) { next(); } }); it('checks the length of an array', function (next) { var arr = [1,2,3]; assume(arr).has.length(3); try { assume(arr).length(1); } catch (e) { next(); } }); it('checks the amount of keys in a object', function (next) { var obj = { foo: 'bar', bar: 'foo' }; assume(obj).length(2); try { assume(obj).length(4); } catch (e) { next(); } }); it('prefers a `.length` key over the size of an object', function (next) { function Foo() { this.length = 1; this.bar = 'hello'; } var foo = new Foo(); assume(foo).length(1); try { assume(foo).length(2); } catch (e) { next(); } }); it('checks the amount of arguments in a function', function (next) { function test(one, two, three) {} assume(test).length(3); try { assume(test).length(4); } catch (e) { next(); } }); }); describe('#empty', function () { it('checks if strings are empty', function (next) { assume('').empty(); try { assume('foo').empty(); } catch (e) { next(); } }); it('checks if array is empty', function (next) { assume([]).empty(); try { assume([1]).empty(); } catch (e) { next(); } }); it('check if objects are empty', function (next) { assume({}).empty(); try { assume({ foo: '' }).empty(); } catch (e) { next(); } }); }); describe('#above', function () { it('is aliased as `gt`, `greater`, `greaterThan`', function () { var x = assume('aaaabe'); if ( x.above !== x.gt || x.above !== x.greater || x.above !== x.greaterThan ) throw new Error('Incorrectly aliased'); }); it('accepts numbers', function (next) { assume(10).is.above(9); try { assume(10).is.above(10); } catch (e) { try { assume(100).is.above(1000); } catch (e) { next(); } } }); it('accepts everything from .length', function (next) { assume([4,1,4,6]).is.above(3); assume({foo: 'bar', bar: 'foo' }).is.above(1); assume('string').is.above(4); try { assume([4,1,4,6]).is.above(10); } catch (e) { try { assume({foo: 'bar', bar: 'foo' }).is.above(3); } catch (e) { try { assume('string').is.above(49); } catch (e) { next(); } } } }); }); describe('#least', function () { it('is aliased as `gte`, `atleast`', function () { var x = assume('aaaabe'); if ( x.least !== x.gte || x.least !== x.atleast ) throw new Error('Incorrectly aliased'); }); it('accepts numbers', function (next) { assume(11).is.least(10); assume(10).is.least(10); try { assume(9).is.least(10); } catch (e) { try { assume(100).is.above(1000); } catch (e) { next(); } } }); it('accepts everything from .length', function (next) { assume([4,1,4,6]).is.least(3); assume([4,1,4,6]).is.least(4); assume({foo: 'bar', bar: 'foo' }).is.least(1); assume({foo: 'bar', bar: 'foo' }).is.least(2); assume('string').is.least(4); assume('string').is.least(5); try { assume([4,1,4,6]).is.least(10); } catch (e) { try { assume({foo: 'bar', bar: 'foo' }).is.least(3); } catch (e) { try { assume('string').is.least(49); } catch (e) { next(); } } } }); }); describe('#below', function () { it('is aliased as `lt`, `less`, `lessThan`', function () { var x = assume('aaaabe'); if ( x.below !== x.lt || x.below !== x.less || x.below !== x.lessThan ) throw new Error('Incorrectly aliased'); }); it('accepts numbers', function (next) { assume(9).is.less(10); try { assume(10).is.less(10); } catch (e) { try { assume(1000).is.less(100); } catch (e) { next(); } } }); it('accepts everything from .length', function (next) { assume([4,1,4,6]).is.less(5); assume({foo: 'bar', bar: 'foo' }).is.less(3); assume('string').is.less(9); try { assume([4,1,4,6]).is.less(3); } catch (e) { try { assume({foo: 'bar', bar: 'foo' }).is.less(2); } catch (e) { try { assume('string').is.less(3); } catch (e) { next(); } } } }); }); describe('#most', function () { it('is aliased as `lte`, `atmost`', function () { var x = assume('aaaabe'); if ( x.most !== x.lte || x.most !== x.atmost ) throw new Error('Incorrectly aliased'); }); it('accepts numbers', function (next) { assume(9).is.most(10); assume(10).is.most(10); try { assume(10).is.most(9); } catch (e) { try { assume(1000).is.most(100); } catch (e) { next(); } } }); it('accepts everything from .length', function (next) { assume([4,1,4,6]).is.most(6); assume([4,1,4,6]).is.most(5); assume({foo: 'bar', bar: 'foo' }).is.most(3); assume({foo: 'bar', bar: 'foo' }).is.most(2); assume('string').is.most(7); assume('string').is.most(6); try { assume([4,1,4,6]).is.most(1); } catch (e) { try { assume({foo: 'bar', bar: 'foo' }).is.most(1); } catch (e) { try { assume('string').is.most(2); } catch (e) { next(); } } } }); }); describe('#within', function () { it('is aliased as `between`', function () { var x = assume('aaaabe'); if (x.within !== x.between) throw new Error('Incorrectly aliased'); }); it('accepts numbers', function (next) { assume(9).is.within(2, 10); assume(10).is.within(9, 15); try { assume(10).is.within(1, 8); } catch (e) { try { assume(1000).is.within(20, 100); } catch (e) { next(); } } }); it('accepts everything from .length', function (next) { assume([4,1,4,6]).is.within(1, 6); assume([4,1,4,6]).is.within(1, 5); assume({foo: 'bar', bar: 'foo' }).is.within(1, 100); assume({foo: 'bar', bar: 'foo' }).is.within(1, 2); assume('string').is.within(1, 7); assume('string').is.within(2, 100); try { assume([4,1,4,6]).is.within(100, 1000); } catch (e) { try { assume({foo: 'bar', bar: 'foo' }).is.within(20, 100); } catch (e) { try { assume('string').is.within(2, 4); } catch (e) { next(); } } } }); }); describe('#hasOwn', function () { it('is aliased as `own`, `ownProperty`, `haveOwnProperty`, `property`, `owns`, `hasown`', function () { var x = assume('aaaabe'); if ( x.hasOwn !== x.own || x.hasOwn !== x.ownProperty || x.hasOwn !== x.haveOwnProperty || x.hasOwn !== x.property || x.hasOwn !== x.owns || x.hasOwn !== x.hasown ) throw new Error('Incorrectly aliased'); }); if (Object.create) { it('works with object.create(null)', function () { var obj = Object.create(null); obj.foo = 'bar'; assume(obj).hasown('foo'); }); } it('checks the property value', function () { var obj = { foo: 'bar' }; // negative assertion required to make sure the 2nd argument is checked. assume(obj).to.not.hasown('fool', false); assume(obj).to.not.hasown('fool', 'bar'); assume(obj).hasown('foo', 'bar'); }); it('can do deep property checks', function () { var obj = { foo: { deep: 'bar' }}; assume(obj).deep.hasown('foo', { deep: 'bar' }); assume(obj).deep.not.hasown('fool', { different: 'deep' }); }); it('only accepts added properties', function (next) { var obj = { foo: 'br' }; assume(obj).hasown('foo'); try { assume(obj).hasown('toString()'); } catch (e) { try { assume(obj).hasown('unknown'); } catch (e) { next(); } } }); it('can check against null values in an object', function () { var obj = { _foo: null, _bar: null }; assume(obj).to.have.property('_foo', null); assume(obj).to.have.property('_bar', null); }); }); describe('#match', function () { it('is aliased as `matches`', function () { var x = assume('aaaabe'); if (x.match !== x.matches) throw new Error('Incorrectly aliased'); }); it('accpets strings instead of regexps', function () { var str = 'bar'; assume(str).matches('\\w+'); }); it('accepts regexp', function (next) { assume('cows').matches(/\w+/); assume('1').matches(/\d+/); try { assume('cows').match(/\d+/); } catch (e) { next(); } }); }); describe('#equal', function () { it('is aliased as `equals`, `eq`, `eqs`', function () { var x = assume('aaaabe'); if ( x.equal !== x.equals || x.equal !== x.eq || x.equal !== x.eqs ) throw new Error('Incorrectly aliased'); }); it('equals', function (next) { assume('foo').equals('foo'); assume('bar').equals('bar'); assume(true).equals(true); assume(0).equals(0); try { assume(true).equals(false); } catch (e) { try { assume('foo', 'bar'); } catch (e) { try { assume([]).equals([]); } catch (e) { next(); } } } }); it('supports .deep', function (next) { assume([1]).deep.equals([1]); try { assume([1]).equals([1]); } catch (e) { next(); } }); it('supports .not', function (next) { assume('foo').does.not.equal('bar'); try { assume('foo').does.not.equal('foo'); } catch (e) { if (e.message.indexOf('not equal') < 0) { next(new Error('expected `@ equals` to have been replaced by `not equals`')); } else { next(); } } }); }); describe('#eql', function () { it('is aliased as `eqls`', function () { var x = assume('foo'); if (x.eql !== x.eqls) throw new Error('Incorrectly aliased'); }); it('deeply equals', function (next) { assume([1]).eqls([1]); assume([1, [2]]).eqls([1, [2]]); try { assume([1]).eqls([2]); } catch (e) { next(); } }); }); describe('#either', function () { it('equals one of the given values', function (next) { assume('bar').is.either(['foo', 'bar']); try { assume('bar').is.either([1, 2, new Date(), []]); } catch (e) { next(); } }); it('deeply equals one of the given values', function (next) { assume({foo: 'bar'}).is.deep.either([{ bar: 'foo' }, { foo: 'bar' }]); try { assume({foo: 'bar'}).is.deep.either([{ bar: 'foo' }, { foo: 'bar', food: 'bar' }]); } catch (e) { next(); } }); }); describe('#throws', function () { function fail() { throw new Error('Oi, cow face'); } function pass() { } it('is aliased as `throw`, `fail`, `fails`', function () { var x = assume('foo'); if ( x.throws !== x.throw || x.throws !== x.fails || x.throws !== x.fail ) throw new Error('Incorrectly aliased'); }); it('captures the thrown error', function (next) { assume(fail).throws('cow face'); assume(pass).does.not.throws(); try { assume(fail).throws('your mom'); } catch (e) { next(); } }); it('fails when nothing is thrown', function (next) { try { assume(pass).throws('cow-dung'); } catch (e) { try { assume(pass).throws(); } catch (e) { return next(); } } }); it('fails when throw is not expected', function (next) { try { assume(fail).to.not.throw(); } catch (e) { next(); } }); it('executes non throwing functions', function (next) { assume(fail).does.not.throw('hi'); assume(next).does.not.throw('hi'); }); it('can match using regexp', function (next) { assume(fail).throws(/oi/i); try { assume(fail).throws(/waffles/); } catch (e) { next(); } }); it('can match instances', function (next) { assume(fail).throws(Error); try { assume(fail).throws(ReferenceError); } catch (e) { next(); } }); it('can throw non errors', function () { assume(function () { throw true; }).throws(true); }); }); describe('.finite', function () { it('is aliased as `isFinite`, `finiteness`', function () { var x = assume(1); if ( x.finite !== x.isFinite || x.finite !== x.finiteness ) throw new Error('Incorrectly aliased'); }); it('is finite', function (next) { assume(100).is.finite(); assume('100').is.finite(); try { assume(NaN).is.finite(); } catch (e) { try { assume(Infinity).is.finite(); } catch (e) { next(); } } }); it('support strict mode', function (next) { assume(1).is.strict.finite(); assume(Infinity).is.not.strict.finite(); assume(-Infinity).is.not.strict.finite(); assume(NaN).is.not.strict.finite(); try { assume('1').is.strict.finite(); } catch (e) { next(); } }); }); describe('#approximately', function () { it('is aliased as `near`, `close`, `closeTo`', function () { var x = assume('foo'); if ( x.approximately !== x.near || x.approximately !== x.close || x.approximately !== x.closeTo ) throw new Error('Incorrectly aliased'); }); it('should be approximately', function (next) { assume(1.5).is.approximately(1.4, 0.2); assume(1.5).is.approximately(1.5, 10E-10); assume(1.5).is.not.approximately(1.4, 1E-2); try { assume(99.99).is.not.approximately(100, 0.1); } catch (e) { try { assume(99.99).is.approximately(105, 0.1); } catch (e) { next(); } } }); }); describe('#start', function () { it('is aliased as `starts`, `startsWith`, `startWith`', function () { var x = assume('foo'); if ( x.start !== x.starts || x.startWith !== x.start || x.startsWith !== x.start ) throw new Error('Incorrectly aliased'); }); it('starts with str', function (next) { assume('foobar').startsWith('foo'); assume('hello multi string hello').starts('hello'); try { assume('foobar').startsWith('bar'); } catch (e) { next(); } }); }); describe('#end', function () { it('is aliased as `ends`, `endsWith`, `endWith`', function () { var x = assume('foo'); if ( x.end !== x.ends || x.endsWith !== x.end || x.endWith !== x.end ) throw new Error('Incorrectly aliased'); }); it('ends with str', function (next) { assume('foobar').endsWith('bar'); assume('hello multi string hellos').endsWith('hellos'); try { assume('foobar').endsWith('foo'); } catch (e) { next(); } }); }); describe('.plan', function () { it('plans the amount of asserts to execute', function (next) { next = assume.plan(2, next); assume('foo').equals('foo'); assume('bar').equals('bar'); next(); }); it('errors on not enough asserts', function (done) { var next = assume.plan(2, function (err) { assume(err.message).includes('less'); assume(err.message).includes('1'); assume(err.message).includes('2'); done(); }); assume('foo').equals('foo'); next(); }); it('errors on not enough asserts', function (done) { var next = assume.plan(2, function (err) { assume(err.message).includes('more'); assume(err.message).includes('1'); assume(err.message).includes('2'); done(); }); assume('foo').equals('foo'); assume('foo').equals('foo'); assume('foo').equals('foo'); next(); }); it('still allows error in the callback', function (done) { var next = assume.plan(2, function (err) { assume(err.message).includes('shit'); done(); }); next(new Error('shit')); }); it('throws when not supplied with a callback', function () { var next = assume.plan(2); assume('foo').equals('foo'); assume('foo').equals('foo'); assume('foo').equals('foo'); assume('foo').equals('foo'); assume('foo').equals('foo'); try { next(); } catch (err) { assume(err.message).includes('more'); assume(err.message).includes('3'); assume(err.message).includes('2'); } }); }); describe('.wait', function () { it('is and returns a function', function () { assume(assume.wait).is.a('function'); assume(assume.wait()).is.a('function'); }); it('waits until all callbacks are called', function (next) { next = assume.plan(3, next); var called = false , fn; fn = assume.wait(2, function meh() { assume(called).is.false(); called = true; next(); }); setTimeout(function () { assume(called).is.false(); fn(); }, 10); setTimeout(function () { assume(called).is.false(); fn(); }, 10); }); it('allows execution greater than the set wait', function (next) { var fn = assume.wait(2, function (err) { assume(err).is.a('undefined'); fn(); fn(); next(); }); fn(); fn(); fn(); }); it('calls the supplied callback on the first error passed in', function (next) { var called = false , fn; fn = assume.wait(2, function (err) { called = true; assume(err.message).equals('first'); }); setTimeout(function () { assume(called).is.false(); fn(new Error('first')); }, 10); setTimeout(function () { assume(called).is.true(); next(); }, 20); }); it('can plan the assertions in the callbacks', function (next) { var fn = assume.wait(2, 3, function (err) { assume(err).is.a('error'); assume(err.message).includes('less assertations than the expected 3'); next(); }); setTimeout(function () { assume(1).equals(1); fn(); }, 10); setTimeout(function () { assume(1).equals(1); fn(); }, 10); }); }); describe('type checks', function () { it('.nan', function (next) { assume(NaN).is.nan(); try { assume(undefined).is.nan(); } catch (e) { next(); } }); it('.undefined', function (next) { assume(undefined).is.undefined(); assume(void 0).is.undefined(); try { assume(null).is.undefined(); } catch (e) { next(); } }); it('.null', function (next) { assume(null).is.null(); try { assume(undefined).is.null(); } catch (e) { next(); } }); it('.arguments', function (next) { assume(arguments).is.arguments(); try { assume(null).is.arguments(); } catch (e) { next(); } }); it('.string', function (next) { assume(String('foo')).is.string(); assume('string').is.string(); try { assume(['array']).is.string(); } catch (e) { next(); } }); it('.number', function (next) { assume(Number('0.1')).is.number(); assume(0).is.number(); try { assume(['array']).is.number(); } catch (e) { next(); } }); it('.array', function (next) { assume(new Array(99)).is.array(); assume([]).is.array(); try { assume(arguments).is.array(); } catch (e) { next(); } }); it('.function', function foo(next) { assume(foo).is.function(); assume(new Function()).is.function(); try { assume('2014/04/04').is.function(); } catch (e) { next(); } }); it('.date', function (next) { assume(new Date()).is.date(); try { assume('2014/04/04').is.date(); } catch (e) { next(); } }); it('.error', function (next) { assume(new Error('foo')).is.error(); try { assume('foo').is.error(); } catch (e) { next(); } }); it('.regexp', function (next) { assume(new RegExp('foo', 'm')).is.regexp(); assume(/foo/).is.regexp(); try { assume('/regexp/').to.be.a('regexp'); } catch (e) { next(); } }); it('.boolean', function (next) { assume(Boolean(0)).is.boolean(); assume(Boolean(1)).is.boolean(); assume(false).is.boolean(); assume(true).is.boolean(); try { assume('true').to.be.a('boolean'); } catch (e) { next(); } }); if (global.Buffer) it('.buffers', function (next) { assume(new Buffer(0)).is.buffer(); try { assume({}).is.buffer(); } catch (e) { next(); } }); if (global.Float32Array) it('.float32arrays', function (next) { assume(new Float32Array(2)).is.float32array(); try { assume([]).is.float32array(); } catch (e) { next(); } }); if (global.Float64Array) it('.float64arrays', function (next) { assume(new Float64Array(2)).float64array(); try { assume([]).isfloat64array(); } catch (e) { next(); } }); if (global.Int16Array) it('.int16arrays', function (next) { assume(new Int16Array()).is.int16array(); try { assume([]).is.int16array(); } catch (e) { next(); } }); if (global.Int32Array) it('.int32arrays', function (next) { assume(new Int32Array()).is.int32array(); try { assume(new Int16Array()).is.int32array(); } catch (e) { next(); } }); if (global.Int8Array) it('.int8arrays', function (next) { assume(new Int8Array()).is.int8array(); try { assume([]).is.int8array(); } catch (e) { next(); } }); if (global.Uint16Array) it('.uint16arrays', function (next) { assume(new Uint16Array()).is.uint16array(); try { assume(new Int16Array()).is.uint16array(); } catch (e) { next(); } }); if (global.Uint32Array) it('.uint32arrays', function (next) { assume(new Uint32Array()).is.uint32array(); try { assume(new Uint16Array()).is.uint32array(); } catch (e) { next(); } }); if (global.Uint8Array) it('.uint8arrays', function (next) { assume(new Uint8Array()).is.uint8array(); try { assume([]).is.uint8array(); } catch (e) { next(); } }); }); describe('.use', function () { it('has a `use` method', function () { assume(assume.use).is.a('function'); }); it('executes the supplied function', function (next) { assume.use(function plugin(ass, helpers) { assume(ass).equals(assume); next(); }); }); it('exposes helper functions', function (next) { assume.use(function plugin(ass, helpers) { assume(helpers).is.a('object'); assume(helpers.string).is.a('function'); assume(helpers.nodejs).is.a('boolean'); assume(helpers.deep).is.a('function'); assume(helpers.each).is.a('function'); assume(helpers.name).is.a('function'); assume(helpers.size).is.a('function'); assume(helpers.type).is.a('function'); assume(helpers.get).is.a('function'); next(); }); }); describe('.each', function () { it('iterates over arrays', function (next) { next = assume.plan(10, next); assume.use(function (ass, helper) { helper.each([1,2,3,4,5,6,7,8,9,10], function (nr, i) { assume(nr).is.a('number'); }); next(); }); }); it('can break out of a array#each', function (next) { next = assume.plan(1, next); assume.use(function (ass, helper) { helper.each([1,2,3,4,5,6,7,8,9,10], function (nr, i) { assume(nr).is.a('number'); return false; }); next(); }); }); it('iterates over objects', function (next) { next = assume.plan(2, next); assume.use(function (ass, helper) { helper.each({foo: 'bar'}, function (value, key) { assume(value).equals('bar'); assume(key).equals('foo'); }); next(); }); }); it('can break out of a object#each', function (next) { next = assume.plan(2, next); assume.use(function (ass, helper) { helper.each({foo: 'bar', hello: 'world'}, function (value, key) { assume(value).equals('bar'); assume(key).equals('foo'); return false; }); next(); }); }); }); describe('.format', function () { it('returns a function', function (next) { assume.use(function (ass, helper) { var fn = helper.format('foo'); assume(fn).is.a('function'); assume(fn()).equals('foo'); next(); }); }); it('it replaces the @ with not', function (next) { assume.use(function (ass, helper) { var fn = helper.format('i am @ an idiot') , fnn = helper.format('i am @ an idiot'); assume(fn(false)).equals('i am an idiot'); assume(fnn(true)).equals('i am not an idiot'); next(); }); }); it('understands the patterns', function (next) { assume.use(function foo(ass, helper) { assume(helper.format('hi %d', 1)()).equals('hi 1'); assume(helper.format('hi %% %d', 1)()).equals('hi % 1'); assume(helper.format('hi %s', 'foo')()).equals('hi foo'); assume(helper.format('hi %f', foo)()).equals('hi foo'); assume(helper.format('hi %f')()).equals('hi %f'); assume(helper.format('hi %a')(1)).equals('hi %a'); var obj = { hello: 1 }; assume(helper.format('hi %j', obj)()).equals('hi { hello: 1 }'); if (Object.defineProperty) { Object.defineProperty(obj, 'throws', { get: function () { throw new Error('pew pew'); }, enumerable: true, configurable: true, set: function () {} }); assume(helper.format('hi %j', obj)()).equals('hi '); } next(); }); }); }); }); }); describe('i', function () { 'use strict'; var i = require('../'); describe('.hope', function () { describe('.that', function () { it('works', function () { i.hope.that('foo').is.a('string'); }); }); }); describe('.expect', function () { describe('.that', function () { it('works', function () { i.expect.that('foo').is.a('string'); }); }); }); describe('.sincerely', function () { describe('.hope', function () { describe('.that', function () { it('works', function () { i.sincerely.hope.that('foo').is.a('string'); }); }); }); }); }); describe('github issues', function () { 'use strict'; var assume = require('../'); if (Object.defineProperty) describe('#2', function () { it('does not throw errors when unspecified properties are accessed', function (next) { var foo = { bar: 'bar' }; Object.defineProperty(foo, 'oops', { configurable: true, enumerable: true, get: function () { throw new Error('I should not be accessed'); }, set: function () { throw new Error('Double WTF, this should never happen'); } }); try { assume(foo).equals(foo); } catch (e) { return next(e); } // // This _should_ still not throw. // try { assume(foo).deep.equals(foo); } catch (e) { next(e); } next(); }); }); }); describe('environment/language specific tests', function () { var assume = require('../'); // // We need to `eval` this as the `*` in the generator function is seen as // invalid syntax in older versions of the language. // if (assume.supports.generators) (new Function('describe', 'assume', [ "describe('#generators', function () {", " it('correctly identifies a generator', function bar(next) {", " function* foo() {", " yield 1;", " }", " assume(foo).is.generator();", " try { assume(bar).is.generator(); }", " catch (e) { next(); }", " });", "});" ].join('\n')))(describe, assume); // // Dedicated test suite for `async` `await` based tests. // try { require('./async'); } catch (e) { } }); assume-2.3.0/test/async.js000066400000000000000000000101621375731470000154520ustar00rootroot00000000000000var assume = require('../'); describe('#rejects', function () { async function throws() { throw new Error('I threw this!'); } async function doesntThrow() { return 'I returned!'; } function promiseResolves() { return new Promise(resolve => { setImmediate(() => resolve('I fulfilled my promise.')); }); } function promiseRejects() { return new Promise((resolve, reject) => { setImmediate(() => reject('I reject your reality.')); }); } it('is aliased as `rejected`, `rejects`, `throwAsync`, `throwsAsync`, `failAsync`, `failsAsync`', function () { var x = assume('foo'); if ( x.rejected !== x.rejects || x.throwAsync !== x.rejects || x.throwsAsync !== x.rejects || x.failAsync !== x.rejects || x.failsAsync !== x.rejects ) throw new Error('Incorrectly aliased'); }); it('Gives success when expected to throw', async function () { await assume(throws()).to.throwAsync(); }); it('Gives success when expected to not throw', async function () { await assume(doesntThrow()).to.not.throwAsync(); }); it('Fails expectation when not thrown and expected to throw', async function () { try { await assume(doesntThrow()).to.throwAsync(); } catch (err) { return; } throw new Error('Exception wasn\'t thrown'); }); it('Fails expectation when thrown and not expected', async function () { try { await assume(throws()).to.not.throwAsync(); } catch (err) { return; } throw new Error('Exception wasn\'t thrown'); }); it('allows pointer to async function', async function () { await assume(throws).to.throwAsync(); await assume(doesntThrow).to.not.throwAsync(); }); it('works with promises', async function () { await assume(promiseRejects()).rejects(); }); it('works with successful promises', async function () { await assume(promiseResolves()).is.not.rejected(); }); }); describe('#completedSync', function () { function synchronousThenable() { return { then(resolve) { resolve(1); } }; } function asynchronousThenable() { return { then(resolve) { setImmediate(() => { resolve(1); }); } }; } function asyncPromise() { return new Promise(resolve => { setImmediate(() => resolve(1)); }); } function synchronousRejection() { return { then(resolve, reject) { reject(1); } }; } function asynchronousRejection() { return { then(resole, reject) { setImmediate(() => { reject(1); }); } }; } it('is aliased as `resolveSync`, `resolvesSync`, `resolvedSync`, `completeSync`, `completesSync`, `completedSync`', function () { var x = assume('foo'); if ( x.resolveSync !== x.completedSync || x.resolvesSync !== x.completedSync || x.resolvedSync !== x.completedSync || x.completeSync !== x.completedSync || x.completesSync !== x.completedSync ) throw new Error('Incorrectly aliased'); }); it('succeeds when call is synchronous', async function () { assume(synchronousThenable()).completedSync(); }); it('succeeds when call is asynchronous and expected to be async', async function () { assume(asynchronousThenable()).to.not.completeSync(); }); it('fails when call is asynchronous and expected to be sync', async function () { await assume(async () => { await assume(asynchronousThenable()).completedSync(); }).to.throwAsync(); }); it('fails when call is synchronous and expected to be async', async function () { await assume(async () => { await assume(synchronousThenable()).to.not.completeSync(); }).to.throwAsync(); }); it('works with promises', async function () { await assume(asyncPromise()).to.not.completeSync(); }); it('succeed when rejecting synchronously', async function () { await assume(synchronousRejection()).completedSync(); }); it('succeed when rejecting asynchronously and expected to be async', async function () { await assume(asynchronousRejection()).to.not.completeSync(); }); });