Update checked-in dependencies

This commit is contained in:
github-actions[bot] 2021-07-27 22:26:09 +00:00
parent 3ba511a8f1
commit 1c4c64199f
175 changed files with 13227 additions and 15136 deletions

179
node_modules/sinon/AUTHORS generated vendored
View file

@ -7,147 +7,160 @@ Jonny Reeves <github@jonnyreeves.co.uk>
lucasfcosta <fernandesdacostalucas@gmail.com>
dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
ben hockey <neonstalwart@gmail.com>
takasmiley <takasmiley@live.jp>
dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Tim Fischbach <mail@timfischbach.de>
takasmiley <takasmiley@live.jp>
Håvard Wormdal Høiby <havardwhoiby@gmail.com>
Tim Ruffles <timruffles@googlemail.com>
Piotr Jamroz <piotr.jamroz@ig.com>
Jonathan Sokolowski <jonathan.sokolowski@gmail.com>
Domenic Denicola <domenic@domenicdenicola.com>
Andreas Lind <andreas@one.com>
Domenic Denicola <domenic@domenicdenicola.com>
William Sears <MrBigDog2U@gmail.com>
Tim Perry <pimterry@gmail.com>
Mikhail Gusarov <mikhail@hola.org>
Marc Redemske <marc.redemske@gmail.com>
Dominykas Blyžė <hello@dominykas.com>
Bryan Donovan <bdondo@gmail.com>
Felix Geisendörfer <felix@debuggable.com>
kpdecker <kpdecker@gmail.com>
Bryan Donovan <bdondo@gmail.com>
Cory <seeflanigan@gmail.com>
Tobias Ebnöther <ebi@gorn.ch>
Luis Cardoso <luis.cardoso@feedzai.com>
Tristan Koch <tristan.koch@1und1.de>
Adam Hull <adam@hmlad.com>
Keith Cirkel <github@keithcirkel.co.uk>
Aleck Greenham <greenhama13@gmail.com>
Flarna <deb2001-github@yahoo.de>
Tobias Ebnöther <ebi@gorn.ch>
Tristan Koch <tristan.koch@1und1.de>
Doug Orleans <dougorleans@gmail.com>
Keith Cirkel <github@keithcirkel.co.uk>
Martin Sander <forke@uni-bonn.de>
Andrew Gurinovich <altmind@gmail.com>
Travis Kaufman <travis.kaufman@gmail.com>
Viktor Zozulyak <zozulyakviktor@gmail.com>
Mahmoud Gamal <mgamal@babbel.com>
Dustin Farris <dustin@farris.io>
Eyal Arubas <eyalarubas@gmail.com>
ben fleis <ben.fleis@gmail.com>
Benjamin Coe <ben@yesware.com>
dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Marten Lienen <marten.lienen@gmail.com>
Adam Hull <adam@hmlad.com>
Cory <seeflanigan@gmail.com>
Aleck Greenham <greenhama13@gmail.com>
Luis Cardoso <luis.cardoso@feedzai.com>
GCHQDeveloper500 <32099399+GCHQDeveloper500@users.noreply.github.com>
Carolyn Stransky <carolynstransky@gmail.com>
zcicala <zcicala@fitbit.com>
Garrick Cheung <garrick@garrickcheung.com>
Dustin Farris <dustin@farris.io>
Konrad Holowinski <konrad.holowinski@gmail.com>
Jay Sherby <jaysherby@gmail.com>
Gavin Huang <gravof@gmail.com>
ben fleis <ben.fleis@gmail.com>
Krzysztof Kaczor <chris@kaczor.io>
Roman Potashow <justgook@gmail.com>
Soutaro Matsumoto <matsumoto@soutaro.com>
Rae Liu <happyaray@gmail.com>
Cormac Flynn <cormac.flynn@viadeoteam.com>
Ming Liu <vmliu1@gmail.com>
Garrick <gcheung@fitbit.com>
George Schneeloch <gschneel@mit.edu>
Jmeas <jellyes2@gmail.com>
Robin Pedersen <robinp@snap.tv>
Kir Chou <note351@hotmail.com>
Thomas Meyer <meyertee@gmail.com>
Duncan Beevers <duncan@dweebd.com>
Dmitriy Kubyshkin <grassator@gmail.com>
Glen Mailer <glen.mailer@bskyb.com>
Tim Costa <tcosta@2u.com>
Jay Sherby <jaysherby@gmail.com>
Marten Lienen <marten.lienen@gmail.com>
Carolyn Stransky <carolynstransky@gmail.com>
Viktor Zozulyak <zozulyakviktor@gmail.com>
zcicala <zcicala@fitbit.com>
Mahmoud Gamal <mgamal@babbel.com>
Eyal Arubas <eyalarubas@gmail.com>
Benjamin Coe <ben@yesware.com>
Travis Kaufman <travis.kaufman@gmail.com>
Garrick Cheung <garrick@garrickcheung.com>
Florent Jaby <florent.jaby@gmail.com>
Islam Sharabash <islam.sharabash@gmail.com>
Scott Andrews <scothis@gmail.com>
Craig Davis <craig-davis@users.noreply.github.com>
Dmitriy Kubyshkin <grassator@gmail.com>
Rens Groothuijsen <l.groothuijsen@alumni.maastrichtuniversity.nl>
Adhya Pranata <adhyapranata@gmail.com>
Thomas Meyer <meyertee@gmail.com>
Cormac Flynn <cormac.flynn@viadeoteam.com>
geries <geries.handal@videoplaza.com>
Márton Salomváry <salomvary@gmail.com>
Roman Potashow <justgook@gmail.com>
Islam Sharabash <islam.sharabash@gmail.com>
Kir Chou <note351@hotmail.com>
Rae Liu <happyaray@gmail.com>
Glen Mailer <glen.mailer@bskyb.com>
Garrick <gcheung@fitbit.com>
Soutaro Matsumoto <matsumoto@soutaro.com>
August Lilleaas <august.lilleaas@gmail.com>
Robin Pedersen <robinp@snap.tv>
Scott Andrews <scothis@gmail.com>
George Schneeloch <gschneel@mit.edu>
Tamas Szebeni <tamas_szebeni@epam.com>
Adhya Pranata <adhyapranata@gmail.com>
Jmeas <jellyes2@gmail.com>
Tim Costa <tcosta@2u.com>
sjoseph7 <17250762+sjoseph7@users.noreply.github.com>
Ming Liu <vmliu1@gmail.com>
Duncan Beevers <duncan@dweebd.com>
なつき <i@ntk.me>
Devin Weaver <suki@tritarget.org>
James Garbutt <43081j@users.noreply.github.com>
Nathan Friedly <nathan@nfriedly.com>
Nathan Mahdavi <mail@nathanmahdavi.com>
Nathan Perry <nateperry333@gmail.com>
Nicholas Hinds <hindsn@gmail.com>
Brandon Heyer <brandonheyer@gmail.com>
Nico Jansen <jansennico@gmail.com>
Alex Urbano <asgaroth.belem@gmail.com>
Jason Karns <jason.karns@gmail.com>
Jeffrey Falgout <jeffrey.falgout@gmail.com>
Jimmy Shimizu <jimmy.shimizu@springworks.se>
Elad Nachmias <theman@elad.im>
Andrzej Porebski <fkuciapa@yahoo.com>
Piotr Jamróz <pm.jamroz@gmail.com>
John-David Dalton <john.david.dalton@gmail.com>
Piotr Jamróz <pm.jamroz@gmail.com>
Jonathan Freeman <freethejazz@gmail.com>
Emma Bukacek <emma.bukacek@gmail.com>
Brandon Heyer <brandonheyer@gmail.com>
RealZogger <49367953+RealZogger@users.noreply.github.com>
Rens Groothuijsen <l.groothuijsen@alumni.maastrichtuniversity.nl>
Aaron <aaron.todd@gmail.com>
Alexander Schmidt <alexanderschmidt1@gmail.com>
Emma Bukacek <emma.bukacek@gmail.com>
RealZogger <49367953+RealZogger@users.noreply.github.com>
Evan Lloyd <evan.u.lloyd@gmail.com>
Farid Neshat <FaridN_SOAD@yahoo.com>
Josh Graham <josh@canva.com>
Josh Greenberger <jdgreenb@usc.edu>
43081j <43081j@users.noreply.github.com>
Satoshi Nakamura <snakamura@infoteria.com>
Sebastian Van Sande <sebastian@vansande.org>
Simen Bekkhus <sbekkhus91@gmail.com>
G.Serebryanskyi <x5x3x5x@gmail.com>
Spencer Elliott <me@elliottsj.com>
Szymon Przybylski <szymon.przybylski@gmail.com>
Chris Breiding <chrisbreiding@gmail.com>
Tarjei Huse <tarjei.huse@gmail.com>
Louis Brunner <louis.brunner.fr@gmail.com>
Sebastian Van Sande <sebastian@vansande.org>
G.Serebryanskyi <x5x3x5x@gmail.com>
Simen Bekkhus <sbekkhus91@gmail.com>
Spencer Elliott <me@elliottsj.com>
Christoph Guttandin <chrisguttandin@media-codings.com>
Victor Costan <costan@gmail.com>
Szymon Przybylski <szymon.przybylski@gmail.com>
Louis Brunner <louis.brunner.fr@gmail.com>
Tarjei Huse <tarjei.huse@gmail.com>
Gyandeep Singh <gyandeeps@gmail.com>
Zach Bloomquist <github@chary.us>
Marcus Hüsgen <marcus.huesgen@lusini.com>
Afnizar Nur Ghifari <afnizarnur@users.noreply.github.com>
Henry Tung <henryptung@gmail.com>
Marcus Hüsgen <marcus.huesgen@lusini.com>
Victor Costan <costan@gmail.com>
Hugo Muller <hugo.muller@free.fr>
blacksun1 <simon@blacksun.cx>
Mark Stacey <mark.stacey@amecfw.com>
Daniel Rey Lopez <daniel.rey.lopez@automattic.com>
gtothesquare <me@gerieshandal.com>
Afnizar Nur Ghifari <afnizarnur@users.noreply.github.com>
Martin Hansen <martin@martinhansen.no>
Igor Savin <kibertoad@gmail.com>
Matt Kern <matt@bloomcrush.com>
Irina Dumitrascu <me@dira.ro>
mohayonao <mohayonao@gmail.com>
Max Calabrese <max.calabrese@ymail.com>
nivsherf <nivsherf@gmail.com>
Alex Puchades <alex94puchades@gmail.com>
Igor Savin <kibertoad@gmail.com>
Zach Bloomquist <github@chary.us>
Martin Hansen <martin@martinhansen.no>
Irina Dumitrascu <me@dira.ro>
blacksun1 <simon@blacksun.cx>
Matt Kern <matt@bloomcrush.com>
Max Calabrese <max.calabrese@ymail.com>
Aaron <aaron.todd@gmail.com>
gtothesquare <me@gerieshandal.com>
Alex Urbano <asgaroth.belem@gmail.com>
Jacob Page <jpage@godaddy.com>
Michael Herman <hermanmu@gmail.com>
David Mott <dpmott@sep.com>
vitalets <vitalets@yandex-team.ru>
Andrzej Porebski <fkuciapa@yahoo.com>
Jakob Jónasson <jakob.jonasson@gmail.com>
yoshimura-toshihide <toshihide0105yoshimura@gmail.com>
James Barwell <jb@jamesbarwell.co.uk>
mohayonao <mohayonao@gmail.com>
Devin Weaver <suki@tritarget.org>
nivsherf <nivsherf@gmail.com>
romanbalayan <roman.balayan@gmail.com>
vitalets <vitalets@yandex-team.ru>
yoshimura-toshihide <toshihide0105yoshimura@gmail.com>
Nathan Friedly <nathan@nfriedly.com>
Rajeesh C V <cvrajeesh@gmail.com>
Raul Matei <raul.matei@8x8.com>
Raynos <raynos2@gmail.com>
ReadmeCritic <frankensteinbot@gmail.com>
Revath S Kumar <revathskumar@users.noreply.github.com>
Rich Hodgkins <rhodgkins@gmail.com>
Richard Lyon <richthegeek@gmail.com>
Richard Torres <richardtorres314@gmail.com>
Rodion Vynnychenko <roddiku@gmail.com>
Rodrigo García <yo@rodrigogarcia.me>
Roland Warmerdam <roland@segment.com>
Romain Pellerin <rpellerin@users.noreply.github.com>
Ruwan Pradeep Geeganage <rpgeeganage@users.noreply.github.com>
Ryan Roemer <ryan@loose-bits.com>
Ryan Wholey <rjwholey@gmail.com>
STuFF <nchalleil@gmail.com>
Sam Landfried <samlandfried@gmail.com>
Saurav Azad <3856934+sauravazad@users.noreply.github.com>
Scott Rudiger <scottrudiger@gmail.com>
Sergio Cinos <scinos@atlassian.com>
Serkan Özel <serkanozel380@gmail.com>
Shaine Hatch <shainehatch@overstock.com>
Shawn Krisman <skrisman@nodelings>
Shinnosuke Watanabe <snnskwtnb@gmail.com>
@ -164,13 +177,16 @@ T1st3 <contact@tiste.org>
TEHEK Firefox <tehek@tehek.net>
Tek Nynja <github@teknynja.com>
The Gitter Badger <badger@gitter.im>
Thomas Biesemann <thomas.biesemann@sap.com>
Tieme van Veen <tiemevanveen@hotmail.com>
Tim Branyen <tim@tabdeveloper.com>
Tim Li <zhengang@sine.co>
Tim Wienk <tim@wienk.name>
Timo Tijhof <krinklemail@gmail.com>
Tobias Mansfield-Williams <tmansfield-williams@esri.com>
Tomek Wytrębowicz <tomalecpub@gmail.com>
Valentin Agachi <github-com@agachi.name>
Vignesh Kumar <vigneshkumar646@gmail.com>
Volkan Ozcelik <volkan.ozcelik@jivesoftware.com>
Vynce Montgomery <vynce.montgomery@gmail.com>
White, Ben <ben.white@jpmchase.com>
@ -183,6 +199,7 @@ Zhengang Li <huttli@users.noreply.github.com>
andrew <andrew.derozario@online-pajak.com>
charlierudolph <charles.w.rudolph@gmail.com>
clint <clint@wealthfront.com>
codejedi365 <codejedi365@users.noreply.github.com>
ehmicky <ehmicky@gmail.com>
goligo <ich@malte.de>
hannes <github@htmlcss.de>
@ -204,6 +221,7 @@ vsa <vsa@users.noreply.github.com>
wwalser <waw325@gmail.com>
Xiao Ma <x@medium.com>
AJ Ortega <ajo@google.com>
Adam Lynch <contact@adamlynch.com>
AdilKhn <AdilKhn@users.noreply.github.com>
Aditya Vohra <avohra@yelp.com>
Adrian Phinney <adrian.phinney@bellaliant.net>
@ -237,14 +255,17 @@ Brian Bleakley <brianbleakley@gmail.com>
Brian M Hunt <brianmhunt@gmail.com>
Burak Yiğit Kaya <ben@byk.im>
C. T. Lin <chentsulin@gmail.com>
Crimson-riot <74468835+Crimson-riot@users.noreply.github.com>
Dan Bird <danielsbird@gmail.com>
Dan Peddle <dazld@users.noreply.github.com>
Daniel Rentz <daniel.rentz@open-xchange.com>
Daryl Lau <daryl@goodeggs.com>
David Colucci <davidanthonycolucci@gmail.com>
David Hayes <drhayes@users.noreply.github.com>
David Hunt <davidhunt@Davids-MBP.local>
Dean Sofer <ProLoser@users.noreply.github.com>
Duc Tri Le <duc1@email.tiger-inc.com>
Eduardo Diaz <eduardo.diaz@auth0.com>
Eli White <github@eli-white.com>
Eric Stobbart <Eric_Stobbart@comcast.com>
Eric Wendelin <ewendelin@twitter.com>
@ -266,8 +287,8 @@ HugoMuller <hmu@debian-hmu-dev>
Ian Lewis <IanMLewis@gmail.com>
Ian Thomas <ian@ian-thomas.net>
Irving <Irvingb232@gmail.com>
J France <jason.a.france@gmail.com>
Jack Brown <jack.brown@mi9.com.au>
Jacob Page <jpage@godaddy.com>
Jahangir Iqbal <35706211+jiqbal48@users.noreply.github.com>
Jake Champion <me@jakechampion.name>
James Beavers <jamesjbeavers@gmail.com>
@ -286,6 +307,7 @@ Jordan Hawker <hawker.jordan@gmail.com>
Joseph Evans <evonsdesigns@gmail.com>
Joseph Spens <joseph@workmarket.com>
Josh Goldberg <josh@fullscreenmario.com>
Joshua Campbell <joshcampbell191@users.noreply.github.com>
JoshuaCWebDeveloper <coosriverjoshua1@outlook.com>
Juntao Zeng <31234156+juntaozeng@users.noreply.github.com>
Kalisa Falzone <KalisaFalzone@users.noreply.github.com>
@ -298,6 +320,7 @@ Kevin Bosman <kevinbosman@users.noreply.github.com>
Kevin Ennis <kennis84@gmail.com>
Kevin Turner <kevin@decipherinc.com>
Kim Joar Bekkelund <kjbekkelund@gmail.com>
Kim Schmider <kim366@users.noreply.github.com>
Kris Kowal <kris.kowal@cixar.com>
Kristian <krisham87@hotmail.com>
Kuba Orlik <kontakt@jakub-orlik.pl>
@ -319,6 +342,7 @@ Martin Körner <martin.koerner@objectfab.de>
Matthew Gabeler-Lee <mgabeler-lee@6river.com>
Matthew Williams <mrwillihog@users.noreply.github.com>
Max Klymyshyn <klymyshyn@gmail.com>
Maxim Tsoy <maks.tsoy@gmail.com>
Michael David Kuckuk <mdk@kuckuk.com>
Michael Jackson <mjijackson@gmail.com>
Michael Paulukonis <xraysmalevich@gmail.com>
@ -327,6 +351,7 @@ Mike Eve <ungrim97@gmail.com>
Mike Flanigan <mkflan@gmail.com>
Mikolaj Banasik <d1sover@gmail.com>
MouseZero <rm@mousezero.com>
Munieru <20086673+munierujp@users.noreply.github.com>
Mustafa Sak <mustafa.sak@1und1.de>
Nelson Silva <nelson.silva@inevo.pt>
Nicholas Stephan <nicholas.stephan@gmail.com>
@ -343,7 +368,3 @@ Peter Zsoldos <peter.zsoldos@gmail.com>
Pia Mancini <piamancini@gmail.com>
Piper Chester <piperchester@users.noreply.github.com>
Prayag Verma <prayag.verma@gmail.com>
Rajeesh C V <cvrajeesh@gmail.com>
Raul Matei <raul.matei@8x8.com>
Raynos <raynos2@gmail.com>
ReadmeCritic <frankensteinbot@gmail.com>

85
node_modules/sinon/CHANGELOG.md generated vendored
View file

@ -1,4 +1,89 @@
11.1.2 / 2021-07-27
==================
* Upgrade @sinonjs/fake-timers to latest, see https://github.com/sinonjs/fake-timers/blob/master/CHANGELOG.md#712--2021-05-28
* Copy over acessor properties to target object #2387
11.1.1 / 2021-05-26
==================
* Fix #2379 by using v7 of supports-color
11.1.0 / 2021-05-25
==================
* Add sinon.promise() implementation (#2369)
* Set wrappedMethod on getters/setters (#2378)
* [Docs] Update fake-server usage & descriptions (#2365)
* Fake docs improvement (#2360)
* Update nise to 5.1.0 (fixed #2318)
11.0.0 / 2021-05-24
==================
* Explicitly use samsam 6.0.2 with fix for #2345
* Update most packages (#2371)
* Update compatibility docs (#2366)
* Update packages (includes breaking fake-timers change, see #2352)
* Warn of potential memory leaks (#2357)
* Fix clock test errors
10.0.1 / 2021-04-08
==================
* Upgrade sinon components (bumps y18n to 4.0.1)
* Bump y18n from 4.0.0 to 4.0.1
10.0.0 / 2021-03-22
==================
* Upgrade nise to 4.1.0
* Use @sinonjs/eslint-config@4 => Adopts ES2017 => Drops support for IE 11, Legacy Edge and legacy Safari
9.2.4 / 2021-01-23
==================
* Upgrade @sinonjs/samsam@5.3.1
9.2.3 / 2021-01-06
==================
* Use `util.inspect` for formatting human readable output
(this retires @sinonjs/formatio)
9.2.2 / 2020-12-11
==================
* Fix #2316: handle absent Promise (#2317)
9.2.1 / 2020-10-28
==================
* Fix #2203: skip writing 'name' property if not writable (#2304)
* Update error message on assert when representation of expected and actual value is equal, fixing issue #2084 (#2303)
* Make sandboxes each use their own assert object (#2302)
* Add usingPromise() method on fakes to fix issue #2293 (#2301)
9.2.0 / 2020-10-06
==================
* Update dependencies (#2299)
* Update sandbox docs with missing comma
* Add minor markdown formatting to release docs for sandbox
* Minor formatting improvements to legacy sandbox documentation
9.1.0 / 2020-09-29
==================
* Add a calledOnceWithMatch assertion (#2294)
9.0.3 / 2020-08-11
==================
* Upgrade nise to latest
* Upgrade @sinonjs/samsam to latest
9.0.2 / 2020-04-08
==================

57
node_modules/sinon/CONTRIBUTING.md generated vendored
View file

@ -2,13 +2,13 @@
There are several ways of contributing to Sinon.JS
* Look into [issues tagged `help-wanted`](https://github.com/sinonjs/sinon/issues?q=is%3Aopen+is%3Aissue+label%3A%22Help+wanted%22)
* Help [improve the documentation](https://github.com/sinonjs/sinon/tree/master/docs) published
- Look into [issues tagged `help-wanted`](https://github.com/sinonjs/sinon/issues?q=is%3Aopen+is%3Aissue+label%3A%22Help+wanted%22)
- Help [improve the documentation](https://github.com/sinonjs/sinon/tree/master/docs) published
at [the Sinon.JS website](https://sinonjs.org). [Documentation issues](https://github.com/sinonjs/sinon/issues?q=is%3Aopen+is%3Aissue+label%3ADocumentation).
* Help someone understand and use Sinon.JS on [Stack Overflow](https://stackoverflow.com/questions/tagged/sinon)
* Report an issue, please read instructions below
* Help with triaging the [issues](https://github.com/sinonjs/sinon/issues). The clearer they are, the more likely they are to be fixed soon.
* Contribute to the code base.
- Help someone understand and use Sinon.JS on [Stack Overflow](https://stackoverflow.com/questions/tagged/sinon)
- Report an issue, please read instructions below
- Help with triaging the [issues](https://github.com/sinonjs/sinon/issues). The clearer they are, the more likely they are to be fixed soon.
- Contribute to the code base.
## Contributor Code of Conduct
@ -20,13 +20,13 @@ To save everyone time and make it much more likely for your issue to be understo
As a minimum, please report the following:
* Which environment are you using? Browser? Node? Which version(s)?
* Which version of SinonJS?
* How are you loading SinonJS?
* What other libraries are you using?
* What you expected to happen
* What actually happens
* Describe **with code** how to reproduce the faulty behaviour
- Which environment are you using? Browser? Node? Which version(s)?
- Which version of SinonJS?
- How are you loading SinonJS?
- What other libraries are you using?
- What you expected to happen
- What actually happens
- Describe **with code** how to reproduce the faulty behaviour
See [our issue template](https://github.com/sinonjs/sinon/blob/master/.github/) for all details.
@ -44,9 +44,9 @@ Please try to [write great commit messages](http://chris.beams.io/posts/git-comm
There are numerous benefits to great commit messages
* They allow Sinon.JS users to understand the consequences of updating to a newer version
* They help contributors understand what is going on with the codebase, allowing features and fixes to be developed faster
* They save maintainers time when compiling the changelog for a new release
- They allow Sinon.JS users to understand the consequences of updating to a newer version
- They help contributors understand what is going on with the codebase, allowing features and fixes to be developed faster
- They save maintainers time when compiling the changelog for a new release
If you're already a few commits in by the time you read this, you can still [change your commit messages](https://help.github.com/articles/changing-a-commit-message/).
@ -66,7 +66,6 @@ Node installed, and install Sinon's dependencies:
This will also install a pre-commit hook, that runs style validation on staged files.
### Compatibility
For details on compatibility and browser support, please see [`COMPATIBILITY.md`](COMPATIBILITY.md)
@ -77,8 +76,7 @@ Sinon.JS uses [ESLint](http://eslint.org) to keep the codebase free of lint, and
If you are contributing to a Sinon project, you'll probably want to configure your editors ([ESLint](https://eslint.org/docs/user-guide/integrations#editors), [Prettier](https://prettier.io/docs/en/editors.html)) to make editing code a more enjoyable experience.
The ESLint verification (which includes Prettier) will be run before unit tests in the CI environment. The build will fail if the source code does not pass the style check.
Both Prettier and ESLint will check the code in pre-commit hooks (when installed) and will be run before unit tests in the CI environment. The build will fail if the source code does not pass the checks.
You can run the linter locally:
@ -86,12 +84,24 @@ You can run the linter locally:
$ npm run lint
```
You can fix a lot lint and style violations automatically:
You can fix a lot of lint violations automatically:
```
$ npm run lint -- --fix
```
You can run prettier locally:
```
$ npm run prettier:check
```
You can fix style violations automatically:
```
$ npm run prettier:write
```
To ensure consistent reporting of lint warnings, you should use the same versions of ESLint and Prettier as defined in `package.json` (which is what the CI servers use).
### Run the tests
@ -111,8 +121,9 @@ To start tests in dev mode run
$ npm run test-dev
Dev mode features:
* [watching related files](https://mochajs.org/#w---watch) to restart tests once changes are made
* using [Min reporter](https://mochajs.org/#min), which cleans the console each time tests run, so test results are always on top
- [watching related files](https://mochajs.org/#w---watch) to restart tests once changes are made
- using [Min reporter](https://mochajs.org/#min), which cleans the console each time tests run, so test results are always on top
Note that in dev mode tests run only in Node. Before creating your PR please ensure tests are passing in Phantom and WebWorker as well. To check this please use [Run the tests](#run-the-tests) instructions.
@ -123,5 +134,3 @@ Build requires Node. Under the hood [Browserify](http://browserify.org/) is used
To build run
$ node build.js

30
node_modules/sinon/README.md generated vendored
View file

@ -24,22 +24,11 @@
</p>
<p align=center>
<a href="https://saucelabs.com/u/sinonjs"><img src="https://saucelabs.com/browser-matrix/sinonjs.svg" alt="Sauce Test Status"></a>
<a href="https://app.saucelabs.com/u/sinonjs">
<img src="https://app.saucelabs.com/browser-matrix/sinonjs.svg" alt="Sauce Test Status"/>
</a>
</p>
## Better docs?
Do you wish that Sinon had better documentation?
So do we!
With your support, we can improve the documentation for everyone.
1. [Donate to the campaign for better documentation](https://www.gofundme.com/f/sinon-docs)
1. Spread the word of the campaign in your companies and on social media
Thank you!
## Compatibility
For details on compatibility and browser support, please see [`COMPATIBILITY.md`](COMPATIBILITY.md)
@ -62,12 +51,12 @@ You can also search through the [Sinon.JS mailing list archives](http://groups.g
## Goals
* No global pollution
* Easy to use
* Require minimal “integration”
* Easy to embed seamlessly with any testing framework
* Easily fake any interface
* Ship with ready-to-use fakes for XMLHttpRequest, timers and more
- No global pollution
- Easy to use
- Require minimal “integration”
- Easy to embed seamlessly with any testing framework
- Easily fake any interface
- Ship with ready-to-use fakes for XMLHttpRequest, timers and more
## Contribute?
@ -108,7 +97,6 @@ Support us with a monthly donation and help us continue our activities. [[Become
<a href="https://opencollective.com/sinon/backer/28/website" target="_blank"><img src="https://opencollective.com/sinon/backer/28/avatar.svg"></a>
<a href="https://opencollective.com/sinon/backer/29/website" target="_blank"><img src="https://opencollective.com/sinon/backer/29/avatar.svg"></a>
## Sponsors
Become a sponsor and get your logo on our README on GitHub with a link to your site. [[Become a sponsor](https://opencollective.com/sinon#sponsor)]

BIN
node_modules/sinon/lib/.DS_Store generated vendored Normal file

Binary file not shown.

12
node_modules/sinon/lib/sinon.js generated vendored
View file

@ -8,6 +8,7 @@ var format = require("./sinon/util/core/format");
var nise = require("nise");
var Sandbox = require("./sinon/sandbox");
var stub = require("./sinon/stub");
var promise = require("./sinon/promise");
var apiMethods = {
createSandbox: createSandbox,
@ -31,11 +32,16 @@ var apiMethods = {
fakeServer: nise.fakeServer,
fakeServerWithClock: nise.fakeServerWithClock,
createFakeServer: nise.fakeServer.create.bind(nise.fakeServer),
createFakeServerWithClock: nise.fakeServerWithClock.create.bind(nise.fakeServerWithClock),
createFakeServerWithClock: nise.fakeServerWithClock.create.bind(
nise.fakeServerWithClock
),
addBehavior: function(name, fn) {
addBehavior: function (name, fn) {
behavior.addBehavior(stub, name, fn);
}
},
// fake promise
promise: promise,
};
var sandbox = new Sandbox();

View file

@ -15,202 +15,281 @@ var forEach = arrayProto.forEach;
var join = arrayProto.join;
var splice = arrayProto.splice;
var assert;
function createAssertObject() {
var assert;
function verifyIsStub() {
var args = arraySlice(arguments);
function verifyIsStub() {
var args = arraySlice(arguments);
forEach(args, function(method) {
if (!method) {
assert.fail("fake is not a spy");
}
if (method.proxy && method.proxy.isSinonProxy) {
verifyIsStub(method.proxy);
} else {
if (typeof method !== "function") {
assert.fail(method + " is not a function");
forEach(args, function (method) {
if (!method) {
assert.fail("fake is not a spy");
}
if (typeof method.getCall !== "function") {
assert.fail(method + " is not stubbed");
}
}
});
}
function verifyIsValidAssertion(assertionMethod, assertionArgs) {
switch (assertionMethod) {
case "notCalled":
case "called":
case "calledOnce":
case "calledTwice":
case "calledThrice":
if (assertionArgs.length !== 0) {
assert.fail(
assertionMethod +
" takes 1 argument but was called with " +
(assertionArgs.length + 1) +
" arguments"
);
}
break;
default:
break;
}
}
function failAssertion(object, msg) {
var obj = object || globalObject;
var failMethod = obj.fail || assert.fail;
failMethod.call(obj, msg);
}
function mirrorPropAsAssertion(name, method, message) {
var msg = message;
var meth = method;
if (arguments.length === 2) {
msg = method;
meth = name;
}
assert[name] = function(fake) {
verifyIsStub(fake);
var args = arraySlice(arguments, 1);
var failed = false;
verifyIsValidAssertion(name, args);
if (typeof meth === "function") {
failed = !meth(fake);
} else {
failed = typeof fake[meth] === "function" ? !fake[meth].apply(fake, args) : !fake[meth];
}
if (failed) {
failAssertion(this, (fake.printf || fake.proxy.printf).apply(fake, concat([msg], args)));
} else {
assert.pass(name);
}
};
}
function exposedName(prefix, prop) {
return !prefix || /^fail/.test(prop) ? prop : prefix + stringSlice(prop, 0, 1).toUpperCase() + stringSlice(prop, 1);
}
assert = {
failException: "AssertError",
fail: function fail(message) {
var error = new Error(message);
error.name = this.failException || assert.failException;
throw error;
},
pass: function pass() {
return;
},
callOrder: function assertCallOrder() {
verifyIsStub.apply(null, arguments);
var expected = "";
var actual = "";
if (!calledInOrder(arguments)) {
try {
expected = join(arguments, ", ");
var calls = arraySlice(arguments);
var i = calls.length;
while (i) {
if (!calls[--i].called) {
splice(calls, i, 1);
}
if (method.proxy && method.proxy.isSinonProxy) {
verifyIsStub(method.proxy);
} else {
if (typeof method !== "function") {
assert.fail(`${method} is not a function`);
}
actual = join(orderByFirstCall(calls), ", ");
} catch (e) {
// If this fails, we'll just fall back to the blank string
}
failAssertion(this, "expected " + expected + " to be called in order but were called as " + actual);
} else {
assert.pass("callOrder");
}
},
callCount: function assertCallCount(method, count) {
verifyIsStub(method);
if (method.callCount !== count) {
var msg = "expected %n to be called " + timesInWords(count) + " but was called %c%C";
failAssertion(this, method.printf(msg));
} else {
assert.pass("callCount");
}
},
expose: function expose(target, options) {
if (!target) {
throw new TypeError("target is null or undefined");
}
var o = options || {};
var prefix = (typeof o.prefix === "undefined" && "assert") || o.prefix;
var includeFail = typeof o.includeFail === "undefined" || Boolean(o.includeFail);
var instance = this;
forEach(Object.keys(instance), function(method) {
if (method !== "expose" && (includeFail || !/^(fail)/.test(method))) {
target[exposedName(prefix, method)] = instance[method];
if (typeof method.getCall !== "function") {
assert.fail(`${method} is not stubbed`);
}
}
});
}
return target;
},
match: function match(actual, expectation) {
var matcher = createMatcher(expectation);
if (matcher.test(actual)) {
assert.pass("match");
} else {
var formatted = [
"expected value to match",
" expected = " + format(expectation),
" actual = " + format(actual)
];
failAssertion(this, join(formatted, "\n"));
function verifyIsValidAssertion(assertionMethod, assertionArgs) {
switch (assertionMethod) {
case "notCalled":
case "called":
case "calledOnce":
case "calledTwice":
case "calledThrice":
if (assertionArgs.length !== 0) {
assert.fail(
`${assertionMethod} takes 1 argument but was called with ${
assertionArgs.length + 1
} arguments`
);
}
break;
default:
break;
}
}
};
mirrorPropAsAssertion("called", "expected %n to have been called at least once but was never called");
mirrorPropAsAssertion(
"notCalled",
function(spy) {
return !spy.called;
},
"expected %n to not have been called but was called %c%C"
);
mirrorPropAsAssertion("calledOnce", "expected %n to be called once but was called %c%C");
mirrorPropAsAssertion("calledTwice", "expected %n to be called twice but was called %c%C");
mirrorPropAsAssertion("calledThrice", "expected %n to be called thrice but was called %c%C");
mirrorPropAsAssertion("calledOn", "expected %n to be called with %1 as this but was called with %t");
mirrorPropAsAssertion("alwaysCalledOn", "expected %n to always be called with %1 as this but was called with %t");
mirrorPropAsAssertion("calledWithNew", "expected %n to be called with new");
mirrorPropAsAssertion("alwaysCalledWithNew", "expected %n to always be called with new");
mirrorPropAsAssertion("calledWith", "expected %n to be called with arguments %D");
mirrorPropAsAssertion("calledWithMatch", "expected %n to be called with match %D");
mirrorPropAsAssertion("alwaysCalledWith", "expected %n to always be called with arguments %D");
mirrorPropAsAssertion("alwaysCalledWithMatch", "expected %n to always be called with match %D");
mirrorPropAsAssertion("calledWithExactly", "expected %n to be called with exact arguments %D");
mirrorPropAsAssertion("calledOnceWithExactly", "expected %n to be called once and with exact arguments %D");
mirrorPropAsAssertion("alwaysCalledWithExactly", "expected %n to always be called with exact arguments %D");
mirrorPropAsAssertion("neverCalledWith", "expected %n to never be called with arguments %*%C");
mirrorPropAsAssertion("neverCalledWithMatch", "expected %n to never be called with match %*%C");
mirrorPropAsAssertion("threw", "%n did not throw exception%C");
mirrorPropAsAssertion("alwaysThrew", "%n did not always throw exception%C");
function failAssertion(object, msg) {
var obj = object || globalObject;
var failMethod = obj.fail || assert.fail;
failMethod.call(obj, msg);
}
module.exports = assert;
function mirrorPropAsAssertion(name, method, message) {
var msg = message;
var meth = method;
if (arguments.length === 2) {
msg = method;
meth = name;
}
assert[name] = function (fake) {
verifyIsStub(fake);
var args = arraySlice(arguments, 1);
var failed = false;
verifyIsValidAssertion(name, args);
if (typeof meth === "function") {
failed = !meth(fake);
} else {
failed =
typeof fake[meth] === "function"
? !fake[meth].apply(fake, args)
: !fake[meth];
}
if (failed) {
failAssertion(
this,
(fake.printf || fake.proxy.printf).apply(
fake,
concat([msg], args)
)
);
} else {
assert.pass(name);
}
};
}
function exposedName(prefix, prop) {
return !prefix || /^fail/.test(prop)
? prop
: prefix +
stringSlice(prop, 0, 1).toUpperCase() +
stringSlice(prop, 1);
}
assert = {
failException: "AssertError",
fail: function fail(message) {
var error = new Error(message);
error.name = this.failException || assert.failException;
throw error;
},
pass: function pass() {
return;
},
callOrder: function assertCallOrder() {
verifyIsStub.apply(null, arguments);
var expected = "";
var actual = "";
if (!calledInOrder(arguments)) {
try {
expected = join(arguments, ", ");
var calls = arraySlice(arguments);
var i = calls.length;
while (i) {
if (!calls[--i].called) {
splice(calls, i, 1);
}
}
actual = join(orderByFirstCall(calls), ", ");
} catch (e) {
// If this fails, we'll just fall back to the blank string
}
failAssertion(
this,
`expected ${expected} to be called in order but were called as ${actual}`
);
} else {
assert.pass("callOrder");
}
},
callCount: function assertCallCount(method, count) {
verifyIsStub(method);
if (method.callCount !== count) {
var msg = `expected %n to be called ${timesInWords(
count
)} but was called %c%C`;
failAssertion(this, method.printf(msg));
} else {
assert.pass("callCount");
}
},
expose: function expose(target, options) {
if (!target) {
throw new TypeError("target is null or undefined");
}
var o = options || {};
var prefix =
(typeof o.prefix === "undefined" && "assert") || o.prefix;
var includeFail =
typeof o.includeFail === "undefined" || Boolean(o.includeFail);
var instance = this;
forEach(Object.keys(instance), function (method) {
if (
method !== "expose" &&
(includeFail || !/^(fail)/.test(method))
) {
target[exposedName(prefix, method)] = instance[method];
}
});
return target;
},
match: function match(actual, expectation) {
var matcher = createMatcher(expectation);
if (matcher.test(actual)) {
assert.pass("match");
} else {
var formatted = [
"expected value to match",
` expected = ${format(expectation)}`,
` actual = ${format(actual)}`,
];
failAssertion(this, join(formatted, "\n"));
}
},
};
mirrorPropAsAssertion(
"called",
"expected %n to have been called at least once but was never called"
);
mirrorPropAsAssertion(
"notCalled",
function (spy) {
return !spy.called;
},
"expected %n to not have been called but was called %c%C"
);
mirrorPropAsAssertion(
"calledOnce",
"expected %n to be called once but was called %c%C"
);
mirrorPropAsAssertion(
"calledTwice",
"expected %n to be called twice but was called %c%C"
);
mirrorPropAsAssertion(
"calledThrice",
"expected %n to be called thrice but was called %c%C"
);
mirrorPropAsAssertion(
"calledOn",
"expected %n to be called with %1 as this but was called with %t"
);
mirrorPropAsAssertion(
"alwaysCalledOn",
"expected %n to always be called with %1 as this but was called with %t"
);
mirrorPropAsAssertion("calledWithNew", "expected %n to be called with new");
mirrorPropAsAssertion(
"alwaysCalledWithNew",
"expected %n to always be called with new"
);
mirrorPropAsAssertion(
"calledWith",
"expected %n to be called with arguments %D"
);
mirrorPropAsAssertion(
"calledWithMatch",
"expected %n to be called with match %D"
);
mirrorPropAsAssertion(
"alwaysCalledWith",
"expected %n to always be called with arguments %D"
);
mirrorPropAsAssertion(
"alwaysCalledWithMatch",
"expected %n to always be called with match %D"
);
mirrorPropAsAssertion(
"calledWithExactly",
"expected %n to be called with exact arguments %D"
);
mirrorPropAsAssertion(
"calledOnceWithExactly",
"expected %n to be called once and with exact arguments %D"
);
mirrorPropAsAssertion(
"calledOnceWithMatch",
"expected %n to be called once and with match %D"
);
mirrorPropAsAssertion(
"alwaysCalledWithExactly",
"expected %n to always be called with exact arguments %D"
);
mirrorPropAsAssertion(
"neverCalledWith",
"expected %n to never be called with arguments %*%C"
);
mirrorPropAsAssertion(
"neverCalledWithMatch",
"expected %n to never be called with match %*%C"
);
mirrorPropAsAssertion("threw", "%n did not throw exception%C");
mirrorPropAsAssertion("alwaysThrew", "%n did not always throw exception%C");
return assert;
}
module.exports = createAssertObject();
module.exports.createAssertObject = createAssertObject;

View file

@ -39,7 +39,11 @@ function getCallback(behavior, args) {
return argumentList[i];
}
if (callArgProp && argumentList[i] && typeof argumentList[i][callArgProp] === "function") {
if (
callArgProp &&
argumentList[i] &&
typeof argumentList[i][callArgProp] === "function"
) {
return argumentList[i][callArgProp];
}
}
@ -52,23 +56,25 @@ function getCallbackError(behavior, func, args) {
var msg;
if (behavior.callArgProp) {
msg =
functionName(behavior.stub) +
" expected to yield to '" +
valueToString(behavior.callArgProp) +
"', but no object with such a property was passed.";
msg = `${functionName(
behavior.stub
)} expected to yield to '${valueToString(
behavior.callArgProp
)}', but no object with such a property was passed.`;
} else {
msg = functionName(behavior.stub) + " expected to yield, but no callback was passed.";
msg = `${functionName(
behavior.stub
)} expected to yield, but no callback was passed.`;
}
if (args.length > 0) {
msg += " Received [" + join(args, ", ") + "]";
msg += ` Received [${join(args, ", ")}]`;
}
return msg;
}
return "argument at index " + behavior.callArgAt + " is not a function: " + func;
return `argument at index ${behavior.callArgAt} is not a function: ${func}`;
}
function ensureArgs(name, behavior, args) {
@ -79,7 +85,9 @@ function ensureArgs(name, behavior, args) {
if (index >= args.length) {
throw new TypeError(
name + " failed: " + (index + 1) + " arguments required but only " + args.length + " present"
`${name} failed: ${index + 1} arguments required but only ${
args.length
} present`
);
}
}
@ -94,11 +102,17 @@ function callCallback(behavior, args) {
}
if (behavior.callbackAsync) {
nextTick(function() {
func.apply(behavior.callbackContext, behavior.callbackArguments);
nextTick(function () {
func.apply(
behavior.callbackContext,
behavior.callbackArguments
);
});
} else {
return func.apply(behavior.callbackContext, behavior.callbackArguments);
return func.apply(
behavior.callbackContext,
behavior.callbackArguments
);
}
}
@ -163,7 +177,9 @@ var proto = {
return this.fakeFn.apply(context, args);
} else if (typeof this.resolveArgAt === "number") {
ensureArgs("resolvesArg", this, args);
return (this.promiseLibrary || Promise).resolve(args[this.resolveArgAt]);
return (this.promiseLibrary || Promise).resolve(
args[this.resolveArgAt]
);
} else if (this.resolveThis) {
return (this.promiseLibrary || Promise).resolve(context);
} else if (this.resolve) {
@ -180,7 +196,10 @@ var proto = {
// Turn the arguments object into a normal array
var argsArray = slice(args);
// Call the constructor
var F = WrappedClass.bind.apply(WrappedClass, concat([null], argsArray));
var F = WrappedClass.bind.apply(
WrappedClass,
concat([null], argsArray)
);
return new F();
} else if (typeof this.returnValue !== "undefined") {
return this.returnValue;
@ -222,19 +241,22 @@ var proto = {
'is not supported. Use "stub.withArgs(...).onCall(...)" ' +
"to define sequential behavior for calls with certain arguments."
);
}
},
};
function createBehavior(behaviorMethod) {
return function() {
return function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
this.defaultBehavior[behaviorMethod].apply(
this.defaultBehavior,
arguments
);
return this;
};
}
function addBehavior(stub, name, fn) {
proto[name] = function() {
proto[name] = function () {
fn.apply(this, concat([this], slice(arguments)));
return this.stub || this;
};

View file

@ -1,6 +1,6 @@
"use strict";
exports.isSupported = (function() {
exports.isSupported = (function () {
try {
return Boolean(new Blob());
} catch (e) {

View file

@ -2,11 +2,15 @@
var walk = require("./util/core/walk");
var getPropertyDescriptor = require("./util/core/get-property-descriptor");
var hasOwnProperty = require("@sinonjs/commons").prototypes.object.hasOwnProperty;
var hasOwnProperty =
require("@sinonjs/commons").prototypes.object.hasOwnProperty;
var push = require("@sinonjs/commons").prototypes.array.push;
function collectMethod(methods, object, prop, propOwner) {
if (typeof getPropertyDescriptor(propOwner, prop).value === "function" && hasOwnProperty(object, prop)) {
if (
typeof getPropertyDescriptor(propOwner, prop).value === "function" &&
hasOwnProperty(object, prop)
) {
push(methods, object[prop]);
}
}

View file

@ -7,25 +7,25 @@ function colorize(str, color) {
return str;
}
return "\x1b[" + color + "m" + str + "\x1b[0m";
return `\x1b[${color}m${str}\x1b[0m`;
}
exports.red = function(str) {
exports.red = function (str) {
return colorize(str, 31);
};
exports.green = function(str) {
exports.green = function (str) {
return colorize(str, 32);
};
exports.cyan = function(str) {
exports.cyan = function (str) {
return colorize(str, 96);
};
exports.white = function(str) {
exports.white = function (str) {
return colorize(str, 39);
};
exports.bold = function(str) {
exports.bold = function (str) {
return colorize(str, 1);
};

View file

@ -53,8 +53,9 @@ function createSandbox(config) {
var exposed = configuredSandbox.inject({});
if (config.properties) {
forEach(config.properties, function(prop) {
var value = exposed[prop] || (prop === "sandbox" && configuredSandbox);
forEach(config.properties, function (prop) {
var value =
exposed[prop] || (prop === "sandbox" && configuredSandbox);
exposeValue(configuredSandbox, config, prop, value);
});
} else {

View file

@ -14,13 +14,13 @@ function throwsException(fake, error, message) {
if (typeof error === "function") {
fake.exceptionCreator = error;
} else if (typeof error === "string") {
fake.exceptionCreator = function() {
fake.exceptionCreator = function () {
var newException = new Error(message || "");
newException.name = error;
return newException;
};
} else if (!error) {
fake.exceptionCreator = function() {
fake.exceptionCreator = function () {
return new Error("Error");
};
} else {
@ -85,44 +85,49 @@ var defaultBehaviors = {
fake.promiseLibrary = promiseLibrary;
},
yields: function(fake) {
yields: function (fake) {
fake.callArgAt = useLeftMostCallback;
fake.callbackArguments = slice(arguments, 1);
fake.callbackContext = undefined;
fake.callArgProp = undefined;
fake.callbackAsync = false;
fake.fakeFn = undefined;
},
yieldsRight: function(fake) {
yieldsRight: function (fake) {
fake.callArgAt = useRightMostCallback;
fake.callbackArguments = slice(arguments, 1);
fake.callbackContext = undefined;
fake.callArgProp = undefined;
fake.callbackAsync = false;
fake.fakeFn = undefined;
},
yieldsOn: function(fake, context) {
yieldsOn: function (fake, context) {
fake.callArgAt = useLeftMostCallback;
fake.callbackArguments = slice(arguments, 2);
fake.callbackContext = context;
fake.callArgProp = undefined;
fake.callbackAsync = false;
fake.fakeFn = undefined;
},
yieldsTo: function(fake, prop) {
yieldsTo: function (fake, prop) {
fake.callArgAt = useLeftMostCallback;
fake.callbackArguments = slice(arguments, 2);
fake.callbackContext = undefined;
fake.callArgProp = prop;
fake.callbackAsync = false;
fake.fakeFn = undefined;
},
yieldsToOn: function(fake, prop, context) {
yieldsToOn: function (fake, prop, context) {
fake.callArgAt = useLeftMostCallback;
fake.callbackArguments = slice(arguments, 3);
fake.callbackContext = context;
fake.callArgProp = prop;
fake.callbackAsync = false;
fake.fakeFn = undefined;
},
throws: throwsException,
@ -230,7 +235,10 @@ var defaultBehaviors = {
Object.defineProperty(rootStub.rootObj, rootStub.propName, {
get: getterFunction,
configurable: isPropertyConfigurable(rootStub.rootObj, rootStub.propName)
configurable: isPropertyConfigurable(
rootStub.rootObj,
rootStub.propName
),
});
return fake;
@ -245,7 +253,10 @@ var defaultBehaviors = {
// eslint-disable-next-line accessor-pairs
{
set: setterFunction,
configurable: isPropertyConfigurable(rootStub.rootObj, rootStub.propName)
configurable: isPropertyConfigurable(
rootStub.rootObj,
rootStub.propName
),
}
);
@ -258,11 +269,13 @@ var defaultBehaviors = {
Object.defineProperty(rootStub.rootObj, rootStub.propName, {
value: newVal,
enumerable: true,
configurable: rootStub.shadowsPropOnPrototype || isPropertyConfigurable(rootStub.rootObj, rootStub.propName)
configurable:
rootStub.shadowsPropOnPrototype ||
isPropertyConfigurable(rootStub.rootObj, rootStub.propName),
});
return fake;
}
},
};
var asyncBehaviors = exportAsyncBehaviors(defaultBehaviors);

323
node_modules/sinon/lib/sinon/fake.js generated vendored
View file

@ -5,15 +5,251 @@ var createProxy = require("./proxy");
var nextTick = require("./util/core/next-tick");
var slice = arrayProto.slice;
var promiseLib = Promise;
function getError(value) {
return value instanceof Error ? value : new Error(value);
module.exports = fake;
/**
* Returns a `fake` that records all calls, arguments and return values.
*
* When an `f` argument is supplied, this implementation will be used.
*
* @example
* // create an empty fake
* var f1 = sinon.fake();
*
* f1();
*
* f1.calledOnce()
* // true
*
* @example
* function greet(greeting) {
* console.log(`Hello ${greeting}`);
* }
*
* // create a fake with implementation
* var f2 = sinon.fake(greet);
*
* // Hello world
* f2("world");
*
* f2.calledWith("world");
* // true
*
* @param {Function|undefined} f
* @returns {Function}
* @namespace
*/
function fake(f) {
if (arguments.length > 0 && typeof f !== "function") {
throw new TypeError("Expected f argument to be a Function");
}
return wrapFunc(f);
}
/**
* Creates a `fake` that returns the provided `value`, as well as recording all
* calls, arguments and return values.
*
* @example
* var f1 = sinon.fake.returns(42);
*
* f1();
* // 42
*
* @memberof fake
* @param {*} value
* @returns {Function}
*/
fake.returns = function returns(value) {
// eslint-disable-next-line jsdoc/require-jsdoc
function f() {
return value;
}
return wrapFunc(f);
};
/**
* Creates a `fake` that throws an Error.
* If the `value` argument does not have Error in its prototype chain, it will
* be used for creating a new error.
*
* @example
* var f1 = sinon.fake.throws("hello");
*
* f1();
* // Uncaught Error: hello
*
* @example
* var f2 = sinon.fake.throws(new TypeError("Invalid argument"));
*
* f2();
* // Uncaught TypeError: Invalid argument
*
* @memberof fake
* @param {*|Error} value
* @returns {Function}
*/
fake.throws = function throws(value) {
// eslint-disable-next-line jsdoc/require-jsdoc
function f() {
throw getError(value);
}
return wrapFunc(f);
};
/**
* Creates a `fake` that returns a promise that resolves to the passed `value`
* argument.
*
* @example
* var f1 = sinon.fake.resolves("apple pie");
*
* await f1();
* // "apple pie"
*
* @memberof fake
* @param {*} value
* @returns {Function}
*/
fake.resolves = function resolves(value) {
// eslint-disable-next-line jsdoc/require-jsdoc
function f() {
return promiseLib.resolve(value);
}
return wrapFunc(f);
};
/**
* Creates a `fake` that returns a promise that rejects to the passed `value`
* argument. When `value` does not have Error in its prototype chain, it will be
* wrapped in an Error.
*
* @example
* var f1 = sinon.fake.rejects(":(");
*
* try {
* await ft();
* } catch (error) {
* console.log(error);
* // ":("
* }
*
* @memberof fake
* @param {*} value
* @returns {Function}
*/
fake.rejects = function rejects(value) {
// eslint-disable-next-line jsdoc/require-jsdoc
function f() {
return promiseLib.reject(getError(value));
}
return wrapFunc(f);
};
/**
* Causes `fake` to use a custom Promise implementation, instead of the native
* Promise implementation.
*
* @example
* const bluebird = require("bluebird");
* sinon.fake.usingPromise(bluebird);
*
* @memberof fake
* @param {*} promiseLibrary
* @returns {Function}
*/
fake.usingPromise = function usingPromise(promiseLibrary) {
promiseLib = promiseLibrary;
return fake;
};
/**
* Returns a `fake` that calls the callback with the defined arguments.
*
* @example
* function callback() {
* console.log(arguments.join("*"));
* }
*
* const f1 = sinon.fake.yields("apple", "pie");
*
* f1(callback);
* // "apple*pie"
*
* @memberof fake
* @returns {Function}
*/
fake.yields = function yields() {
var values = slice(arguments);
// eslint-disable-next-line jsdoc/require-jsdoc
function f() {
var callback = arguments[arguments.length - 1];
if (typeof callback !== "function") {
throw new TypeError("Expected last argument to be a function");
}
callback.apply(null, values);
}
return wrapFunc(f);
};
/**
* Returns a `fake` that calls the callback **asynchronously** with the
* defined arguments.
*
* @example
* function callback() {
* console.log(arguments.join("*"));
* }
*
* const f1 = sinon.fake.yields("apple", "pie");
*
* f1(callback);
*
* setTimeout(() => {
* // "apple*pie"
* });
*
* @memberof fake
* @returns {Function}
*/
fake.yieldsAsync = function yieldsAsync() {
var values = slice(arguments);
// eslint-disable-next-line jsdoc/require-jsdoc
function f() {
var callback = arguments[arguments.length - 1];
if (typeof callback !== "function") {
throw new TypeError("Expected last argument to be a function");
}
nextTick(function () {
callback.apply(null, values);
});
}
return wrapFunc(f);
};
var uuid = 0;
/**
* Creates a proxy (sinon concept) from the passed function.
*
* @private
* @param {Function} f
* @returns {Function}
*/
function wrapFunc(f) {
var proxy;
var fakeInstance = function() {
var fakeInstance = function () {
var firstArg, lastArg;
if (arguments.length > 0) {
@ -21,7 +257,8 @@ function wrapFunc(f) {
lastArg = arguments[arguments.length - 1];
}
var callback = lastArg && typeof lastArg === "function" ? lastArg : undefined;
var callback =
lastArg && typeof lastArg === "function" ? lastArg : undefined;
proxy.firstArg = firstArg;
proxy.lastArg = lastArg;
@ -32,75 +269,19 @@ function wrapFunc(f) {
proxy = createProxy(fakeInstance, f || fakeInstance);
proxy.displayName = "fake";
proxy.id = "fake#" + uuid++;
proxy.id = `fake#${uuid++}`;
return proxy;
}
function fake(f) {
if (arguments.length > 0 && typeof f !== "function") {
throw new TypeError("Expected f argument to be a Function");
}
return wrapFunc(f);
/**
* Returns an Error instance from the passed value, if the value is not
* already an Error instance.
*
* @private
* @param {*} value [description]
* @returns {Error} [description]
*/
function getError(value) {
return value instanceof Error ? value : new Error(value);
}
fake.returns = function returns(value) {
function f() {
return value;
}
return wrapFunc(f);
};
fake.throws = function throws(value) {
function f() {
throw getError(value);
}
return wrapFunc(f);
};
fake.resolves = function resolves(value) {
function f() {
return Promise.resolve(value);
}
return wrapFunc(f);
};
fake.rejects = function rejects(value) {
function f() {
return Promise.reject(getError(value));
}
return wrapFunc(f);
};
function yieldInternal(async, values) {
function f() {
var callback = arguments[arguments.length - 1];
if (typeof callback !== "function") {
throw new TypeError("Expected last argument to be a function");
}
if (async) {
nextTick(function() {
callback.apply(null, values);
});
} else {
callback.apply(null, values);
}
}
return wrapFunc(f);
}
fake.yields = function yields() {
return yieldInternal(false, slice(arguments));
};
fake.yieldsAsync = function yieldsAsync() {
return yieldInternal(true, slice(arguments));
};
module.exports = fake;

View file

@ -22,7 +22,7 @@ function callCountInWords(callCount) {
return "never called";
}
return "called " + timesInWords(callCount);
return `called ${timesInWords(callCount)}`;
}
function expectedCallCountInWords(expectation) {
@ -33,17 +33,17 @@ function expectedCallCountInWords(expectation) {
var str = timesInWords(min);
if (min !== max) {
str = "at least " + str + " and at most " + timesInWords(max);
str = `at least ${str} and at most ${timesInWords(max)}`;
}
return str;
}
if (typeof min === "number") {
return "at least " + timesInWords(min);
return `at least ${timesInWords(min)}`;
}
return "at most " + timesInWords(max);
return `at most ${timesInWords(max)}`;
}
function receivedMinCalls(expectation) {
@ -85,7 +85,7 @@ var mockExpectation = {
atLeast: function atLeast(num) {
if (typeof num !== "number") {
throw new TypeError("'" + valueToString(num) + "' is not number");
throw new TypeError(`'${valueToString(num)}' is not number`);
}
if (!this.limitsSet) {
@ -100,7 +100,7 @@ var mockExpectation = {
atMost: function atMost(num) {
if (typeof num !== "number") {
throw new TypeError("'" + valueToString(num) + "' is not number");
throw new TypeError(`'${valueToString(num)}' is not number`);
}
if (!this.limitsSet) {
@ -131,7 +131,7 @@ var mockExpectation = {
exactly: function exactly(num) {
if (typeof num !== "number") {
throw new TypeError("'" + valueToString(num) + "' is not a number");
throw new TypeError(`'${valueToString(num)}' is not a number`);
}
this.atLeast(num);
@ -147,16 +147,16 @@ var mockExpectation = {
if (receivedMaxCalls(this)) {
this.failed = true;
mockExpectation.fail(this.method + " already called " + timesInWords(this.maxCalls));
mockExpectation.fail(
`${this.method} already called ${timesInWords(this.maxCalls)}`
);
}
if ("expectedThis" in this && this.expectedThis !== thisValue) {
mockExpectation.fail(
this.method +
" called with " +
valueToString(thisValue) +
" as thisValue, expected " +
valueToString(this.expectedThis)
`${this.method} called with ${valueToString(
thisValue
)} as thisValue, expected ${valueToString(this.expectedThis)}`
);
}
@ -165,49 +165,48 @@ var mockExpectation = {
}
if (!args) {
mockExpectation.fail(this.method + " received no arguments, expected " + format(expectedArguments));
mockExpectation.fail(
`${this.method} received no arguments, expected ${format(
expectedArguments
)}`
);
}
if (args.length < expectedArguments.length) {
mockExpectation.fail(
this.method +
" received too few arguments (" +
format(args) +
"), expected " +
format(expectedArguments)
`${this.method} received too few arguments (${format(
args
)}), expected ${format(expectedArguments)}`
);
}
if (this.expectsExactArgCount && args.length !== expectedArguments.length) {
if (
this.expectsExactArgCount &&
args.length !== expectedArguments.length
) {
mockExpectation.fail(
this.method +
" received too many arguments (" +
format(args) +
"), expected " +
format(expectedArguments)
`${this.method} received too many arguments (${format(
args
)}), expected ${format(expectedArguments)}`
);
}
forEach(
expectedArguments,
function(expectedArgument, i) {
function (expectedArgument, i) {
if (!verifyMatcher(expectedArgument, args[i])) {
mockExpectation.fail(
this.method +
" received wrong arguments " +
format(args) +
", didn't match " +
String(expectedArguments)
`${this.method} received wrong arguments ${format(
args
)}, didn't match ${String(expectedArguments)}`
);
}
if (!deepEqual(args[i], expectedArgument)) {
mockExpectation.fail(
this.method +
" received wrong arguments " +
format(args) +
", expected " +
format(expectedArguments)
`${this.method} received wrong arguments ${format(
args
)}, expected ${format(expectedArguments)}`
);
}
},
@ -237,11 +236,14 @@ var mockExpectation = {
return false;
}
if (this.expectsExactArgCount && _args.length !== expectedArguments.length) {
if (
this.expectsExactArgCount &&
_args.length !== expectedArguments.length
) {
return false;
}
return every(expectedArguments, function(expectedArgument, i) {
return every(expectedArguments, function (expectedArgument, i) {
if (!verifyMatcher(expectedArgument, _args[i])) {
return false;
}
@ -270,7 +272,7 @@ var mockExpectation = {
return this;
},
toString: function() {
toString: function () {
var args = slice(this.expectedArguments || []);
if (!this.expectsExactArgCount) {
@ -279,16 +281,19 @@ var mockExpectation = {
var callStr = proxyCallToString.call({
proxy: this.method || "anonymous mock expectation",
args: args
args: args,
});
var message = callStr.replace(", [...", "[, ...") + " " + expectedCallCountInWords(this);
var message = `${callStr.replace(
", [...",
"[, ..."
)} ${expectedCallCountInWords(this)}`;
if (this.met()) {
return "Expectation met: " + message;
return `Expectation met: ${message}`;
}
return "Expected " + message + " (" + callCountInWords(this.callCount) + ")";
return `Expected ${message} (${callCountInWords(this.callCount)})`;
},
verify: function verify() {
@ -310,7 +315,7 @@ var mockExpectation = {
exception.name = "ExpectationError";
throw exception;
}
},
};
module.exports = mockExpectation;

70
node_modules/sinon/lib/sinon/mock.js generated vendored
View file

@ -36,7 +36,7 @@ function arrayEquals(arr1, arr2, compareLength) {
return false;
}
return every(arr1, function(element, i) {
return every(arr1, function (element, i) {
return deepEqual(arr2[i], element);
});
}
@ -68,7 +68,7 @@ extend(mock, {
this.expectations[method] = [];
var mockObject = this;
wrapMethod(this.object, method, function() {
wrapMethod(this.object, method, function () {
return mockObject.invokeMethod(method, this, arguments);
});
@ -86,7 +86,7 @@ extend(mock, {
restore: function restore() {
var object = this.object;
each(this.proxies, function(proxy) {
each(this.proxies, function (proxy) {
if (typeof object[proxy].restore === "function") {
object[proxy].restore();
}
@ -98,8 +98,8 @@ extend(mock, {
var messages = this.failures ? slice(this.failures) : [];
var met = [];
each(this.proxies, function(proxy) {
each(expectations[proxy], function(expectation) {
each(this.proxies, function (proxy) {
each(expectations[proxy], function (expectation) {
if (!expectation.met()) {
push(messages, String(expectation));
} else {
@ -128,19 +128,35 @@ extend(mock, {
invokeMethod: function invokeMethod(method, thisValue, args) {
/* if we cannot find any matching files we will explicitly call mockExpection#fail with error messages */
/* eslint consistent-return: "off" */
var expectations = this.expectations && this.expectations[method] ? this.expectations[method] : [];
var expectations =
this.expectations && this.expectations[method]
? this.expectations[method]
: [];
var currentArgs = args || [];
var available;
var expectationsWithMatchingArgs = filter(expectations, function(expectation) {
var expectedArgs = expectation.expectedArguments || [];
var expectationsWithMatchingArgs = filter(
expectations,
function (expectation) {
var expectedArgs = expectation.expectedArguments || [];
return arrayEquals(expectedArgs, currentArgs, expectation.expectsExactArgCount);
});
return arrayEquals(
expectedArgs,
currentArgs,
expectation.expectsExactArgCount
);
}
);
var expectationsToApply = filter(expectationsWithMatchingArgs, function(expectation) {
return !expectation.met() && expectation.allowsCall(thisValue, args);
});
var expectationsToApply = filter(
expectationsWithMatchingArgs,
function (expectation) {
return (
!expectation.met() &&
expectation.allowsCall(thisValue, args)
);
}
);
if (expectationsToApply.length > 0) {
return expectationsToApply[0].apply(thisValue, args);
@ -149,7 +165,7 @@ extend(mock, {
var messages = [];
var exhausted = 0;
forEach(expectationsWithMatchingArgs, function(expectation) {
forEach(expectationsWithMatchingArgs, function (expectation) {
if (expectation.allowsCall(thisValue, args)) {
available = available || expectation;
} else {
@ -161,17 +177,16 @@ extend(mock, {
return available.apply(thisValue, args);
}
forEach(expectations, function(expectation) {
push(messages, " " + String(expectation));
forEach(expectations, function (expectation) {
push(messages, ` ${String(expectation)}`);
});
unshift(
messages,
"Unexpected call: " +
proxyCallToString.call({
proxy: method,
args: args
})
`Unexpected call: ${proxyCallToString.call({
proxy: method,
args: args,
})}`
);
var err = new Error();
@ -185,16 +200,15 @@ extend(mock, {
}
push(
this.failures,
"Unexpected call: " +
proxyCallToString.call({
proxy: method,
args: args,
stack: err.stack
})
`Unexpected call: ${proxyCallToString.call({
proxy: method,
args: args,
stack: err.stack,
})}`
);
mockExpectation.fail(join(messages, "\n"));
}
},
});
module.exports = mock;

84
node_modules/sinon/lib/sinon/promise.js generated vendored Normal file
View file

@ -0,0 +1,84 @@
"use strict";
var fake = require("./fake");
var isRestorable = require("./util/core/is-restorable");
var STATUS_PENDING = "pending";
var STATUS_RESOLVED = "resolved";
var STATUS_REJECTED = "rejected";
/**
* Returns a fake for a given function or undefined. If no functino is given, a
* new fake is returned. If the given function is already a fake, it is
* returned as is. Otherwise the given function is wrapped in a new fake.
*
* @param {Function} [executor] The optional executor function.
* @returns {Function}
*/
function getFakeExecutor(executor) {
if (isRestorable(executor)) {
return executor;
}
if (executor) {
return fake(executor);
}
return fake();
}
/**
* Returns a new promise that exposes it's internal `status`, `resolvedValue`
* and `rejectedValue` and can be resolved or rejected from the outside by
* calling `resolve(value)` or `reject(reason)`.
*
* @param {Function} [executor] The optional executor function.
* @returns {Promise}
*/
function promise(executor) {
var fakeExecutor = getFakeExecutor(executor);
var sinonPromise = new Promise(fakeExecutor);
sinonPromise.status = STATUS_PENDING;
sinonPromise
.then(function (value) {
sinonPromise.status = STATUS_RESOLVED;
sinonPromise.resolvedValue = value;
})
.catch(function (reason) {
sinonPromise.status = STATUS_REJECTED;
sinonPromise.rejectedValue = reason;
});
/**
* Resolves or rejects the promise with the given status and value.
*
* @param {string} status
* @param {*} value
* @param {Function} callback
*/
function finalize(status, value, callback) {
if (sinonPromise.status !== STATUS_PENDING) {
throw new Error(`Promise already ${sinonPromise.status}`);
}
sinonPromise.status = status;
callback(value);
}
sinonPromise.resolve = function (value) {
finalize(STATUS_RESOLVED, value, fakeExecutor.firstCall.args[0]);
// Return the promise so that callers can await it:
return sinonPromise;
};
sinonPromise.reject = function (reason) {
finalize(STATUS_REJECTED, reason, fakeExecutor.firstCall.args[1]);
// Return a new promise that resolves when the sinon promise was
// rejected, so that callers can await it:
return new Promise(function (resolve) {
sinonPromise.catch(() => resolve());
});
};
return sinonPromise;
}
module.exports = promise;

View file

@ -27,7 +27,7 @@ exports.delegateToCalls = function delegateToCalls(
notCalled,
totalCallCount
) {
proxy[method] = function() {
proxy[method] = function () {
if (!this.called) {
if (notCalled) {
return notCalled.apply(this, arguments);
@ -45,7 +45,10 @@ exports.delegateToCalls = function delegateToCalls(
for (var i = 0, l = this.callCount; i < l; i += 1) {
currentCall = this.getCall(i);
var returnValue = currentCall[actual || method].apply(currentCall, arguments);
var returnValue = currentCall[actual || method].apply(
currentCall,
arguments
);
push(returnValues, returnValue);
if (returnValue) {
matches += 1;

View file

@ -17,7 +17,7 @@ var slice = arrayProto.slice;
function throwYieldError(proxy, text, args) {
var msg = functionName(proxy) + text;
if (args.length) {
msg += " Received [" + join(slice(args), ", ") + "]";
msg += ` Received [${join(slice(args), ", ")}]`;
}
throw new Error(msg);
}
@ -40,7 +40,7 @@ var callProto = {
return reduce(
calledWithArgs,
function(prev, arg, i) {
function (prev, arg, i) {
return prev && deepEqual(self.args[i], arg);
},
true
@ -57,7 +57,7 @@ var callProto = {
return reduce(
calledWithMatchArgs,
function(prev, expectation, i) {
function (prev, expectation, i) {
var actual = self.args[i];
return prev && match(expectation).test(actual);
@ -67,7 +67,10 @@ var callProto = {
},
calledWithExactly: function calledWithExactly() {
return arguments.length === this.args.length && this.calledWith.apply(this, arguments);
return (
arguments.length === this.args.length &&
this.calledWith.apply(this, arguments)
);
},
notCalledWith: function notCalledWith() {
@ -94,74 +97,86 @@ var callProto = {
return this.proxy.prototype && this.thisValue instanceof this.proxy;
},
calledBefore: function(other) {
calledBefore: function (other) {
return this.callId < other.callId;
},
calledAfter: function(other) {
calledAfter: function (other) {
return this.callId > other.callId;
},
calledImmediatelyBefore: function(other) {
calledImmediatelyBefore: function (other) {
return this.callId === other.callId - 1;
},
calledImmediatelyAfter: function(other) {
calledImmediatelyAfter: function (other) {
return this.callId === other.callId + 1;
},
callArg: function(pos) {
callArg: function (pos) {
this.ensureArgIsAFunction(pos);
return this.args[pos]();
},
callArgOn: function(pos, thisValue) {
callArgOn: function (pos, thisValue) {
this.ensureArgIsAFunction(pos);
return this.args[pos].apply(thisValue);
},
callArgWith: function(pos) {
return this.callArgOnWith.apply(this, concat([pos, null], slice(arguments, 1)));
callArgWith: function (pos) {
return this.callArgOnWith.apply(
this,
concat([pos, null], slice(arguments, 1))
);
},
callArgOnWith: function(pos, thisValue) {
callArgOnWith: function (pos, thisValue) {
this.ensureArgIsAFunction(pos);
var args = slice(arguments, 2);
return this.args[pos].apply(thisValue, args);
},
throwArg: function(pos) {
throwArg: function (pos) {
if (pos > this.args.length) {
throw new TypeError("Not enough arguments: " + pos + " required but only " + this.args.length + " present");
throw new TypeError(
`Not enough arguments: ${pos} required but only ${this.args.length} present`
);
}
throw this.args[pos];
},
yield: function() {
yield: function () {
return this.yieldOn.apply(this, concat([null], slice(arguments, 0)));
},
yieldOn: function(thisValue) {
yieldOn: function (thisValue) {
var args = slice(this.args);
var yieldFn = filter(args, function(arg) {
var yieldFn = filter(args, function (arg) {
return typeof arg === "function";
})[0];
if (!yieldFn) {
throwYieldError(this.proxy, " cannot yield since no callback was passed.", args);
throwYieldError(
this.proxy,
" cannot yield since no callback was passed.",
args
);
}
return yieldFn.apply(thisValue, slice(arguments, 1));
},
yieldTo: function(prop) {
return this.yieldToOn.apply(this, concat([prop, null], slice(arguments, 1)));
yieldTo: function (prop) {
return this.yieldToOn.apply(
this,
concat([prop, null], slice(arguments, 1))
);
},
yieldToOn: function(prop, thisValue) {
yieldToOn: function (prop, thisValue) {
var args = slice(this.args);
var yieldArg = filter(args, function(arg) {
var yieldArg = filter(args, function (arg) {
return arg && typeof arg[prop] === "function";
})[0];
var yieldFn = yieldArg && yieldArg[prop];
@ -169,7 +184,9 @@ var callProto = {
if (!yieldFn) {
throwYieldError(
this.proxy,
" cannot yield to '" + valueToString(prop) + "' since no callback was passed.",
` cannot yield to '${valueToString(
prop
)}' since no callback was passed.`,
args
);
}
@ -177,58 +194,70 @@ var callProto = {
return yieldFn.apply(thisValue, slice(arguments, 2));
},
toString: function() {
var callStr = this.proxy ? String(this.proxy) + "(" : "";
toString: function () {
var callStr = this.proxy ? `${String(this.proxy)}(` : "";
var formattedArgs;
if (!this.args) {
return ":(";
}
formattedArgs = map(this.args, function(arg) {
formattedArgs = map(this.args, function (arg) {
return sinonFormat(arg);
});
callStr = callStr + join(formattedArgs, ", ") + ")";
callStr = `${callStr + join(formattedArgs, ", ")})`;
if (typeof this.returnValue !== "undefined") {
callStr += " => " + sinonFormat(this.returnValue);
callStr += ` => ${sinonFormat(this.returnValue)}`;
}
if (this.exception) {
callStr += " !" + this.exception.name;
callStr += ` !${this.exception.name}`;
if (this.exception.message) {
callStr += "(" + this.exception.message + ")";
callStr += `(${this.exception.message})`;
}
}
if (this.stack) {
// Omit the error message and the two top stack frames in sinon itself:
callStr += (this.stack.split("\n")[3] || "unknown").replace(/^\s*(?:at\s+|@)?/, " at ");
callStr += (this.stack.split("\n")[3] || "unknown").replace(
/^\s*(?:at\s+|@)?/,
" at "
);
}
return callStr;
},
ensureArgIsAFunction: function(pos) {
ensureArgIsAFunction: function (pos) {
if (typeof this.args[pos] !== "function") {
throw new TypeError(
"Expected argument at position " + pos + " to be a Function, but was " + typeof this.args[pos]
`Expected argument at position ${pos} to be a Function, but was ${typeof this
.args[pos]}`
);
}
}
},
};
Object.defineProperty(callProto, "stack", {
enumerable: true,
configurable: true,
get: function() {
get: function () {
return (this.errorWithCallStack && this.errorWithCallStack.stack) || "";
}
},
});
callProto.invokeCallback = callProto.yield;
function createProxyCall(proxy, thisValue, args, returnValue, exception, id, errorWithCallStack) {
function createProxyCall(
proxy,
thisValue,
args,
returnValue,
exception,
id,
errorWithCallStack
) {
if (typeof id !== "number") {
throw new TypeError("Call id is not a number");
}
@ -241,7 +270,8 @@ function createProxyCall(proxy, thisValue, args, returnValue, exception, id, err
}
var proxyCall = Object.create(callProto);
var callback = lastArg && typeof lastArg === "function" ? lastArg : undefined;
var callback =
lastArg && typeof lastArg === "function" ? lastArg : undefined;
proxyCall.proxy = proxy;
proxyCall.thisValue = thisValue;

View file

@ -20,7 +20,7 @@ module.exports = function invoke(func, thisValue, args) {
push(this.thisValues, thisValue);
push(this.args, args);
push(this.callIds, currentCallId);
forEach(matchings, function(matching) {
forEach(matchings, function (matching) {
proxyCallUtil.incrementCallCount(matching);
push(matching.thisValues, thisValue);
push(matching.args, args);
@ -38,7 +38,10 @@ module.exports = function invoke(func, thisValue, args) {
if (thisCall.calledWithNew()) {
// Call through with `new`
returnValue = new (bind.apply(this.func || func, concat([thisValue], args)))();
returnValue = new (bind.apply(
this.func || func,
concat([thisValue], args)
))();
if (typeof returnValue !== "object") {
returnValue = thisValue;
@ -54,7 +57,7 @@ module.exports = function invoke(func, thisValue, args) {
push(this.exceptions, exception);
push(this.returnValues, returnValue);
forEach(matchings, function(matching) {
forEach(matchings, function (matching) {
push(matching.exceptions, exception);
push(matching.returnValues, returnValue);
});
@ -69,7 +72,7 @@ module.exports = function invoke(func, thisValue, args) {
/* empty */
}
push(this.errorsWithCallStack, err);
forEach(matchings, function(matching) {
forEach(matchings, function (matching) {
push(matching.errorsWithCallStack, err);
});

View file

@ -36,7 +36,7 @@ var proxyApi = {
* Hook for derived implementation to return fake instances matching the
* given arguments.
*/
matchingFakes: function(/*args, strict*/) {
matchingFakes: function (/*args, strict*/) {
return emptyFakes;
},
@ -61,7 +61,7 @@ var proxyApi = {
);
},
getCalls: function() {
getCalls: function () {
var calls = [];
var i;
@ -97,7 +97,10 @@ var proxyApi = {
return false;
}
return this.callIds[this.callCount - 1] === proxy.callIds[proxy.callCount - 1] - 1;
return (
this.callIds[this.callCount - 1] ===
proxy.callIds[proxy.callCount - 1] - 1
);
},
calledImmediatelyAfter: function calledImmediatelyAfter(proxy) {
@ -105,16 +108,19 @@ var proxyApi = {
return false;
}
return this.callIds[this.callCount - 1] === proxy.callIds[proxy.callCount - 1] + 1;
return (
this.callIds[this.callCount - 1] ===
proxy.callIds[proxy.callCount - 1] + 1
);
},
formatters: require("./spy-formatters"),
printf: function(format) {
printf: function (format) {
var spyInstance = this;
var args = slice(arguments, 1);
var formatter;
return (format || "").replace(/%(.)/g, function(match, specifyer) {
return (format || "").replace(/%(.)/g, function (match, specifyer) {
formatter = proxyApi.formatters[specifyer];
if (typeof formatter === "function") {
@ -123,11 +129,11 @@ var proxyApi = {
return sinonFormat(args[specifyer - 1]);
}
return "%" + specifyer;
return `%${specifyer}`;
});
},
resetHistory: function() {
resetHistory: function () {
if (this.invoking) {
var err = new Error(
"Cannot reset Sinon function while invoking it. " +
@ -157,32 +163,76 @@ var proxyApi = {
this.errorsWithCallStack = [];
if (this.fakes) {
forEach(this.fakes, function(fake) {
forEach(this.fakes, function (fake) {
fake.resetHistory();
});
}
return this;
}
},
};
var delegateToCalls = proxyCallUtil.delegateToCalls;
delegateToCalls(proxyApi, "calledOn", true);
delegateToCalls(proxyApi, "alwaysCalledOn", false, "calledOn");
delegateToCalls(proxyApi, "calledWith", true);
delegateToCalls(proxyApi, "calledOnceWith", true, "calledWith", false, undefined, 1);
delegateToCalls(
proxyApi,
"calledOnceWith",
true,
"calledWith",
false,
undefined,
1
);
delegateToCalls(proxyApi, "calledWithMatch", true);
delegateToCalls(proxyApi, "alwaysCalledWith", false, "calledWith");
delegateToCalls(proxyApi, "alwaysCalledWithMatch", false, "calledWithMatch");
delegateToCalls(proxyApi, "calledWithExactly", true);
delegateToCalls(proxyApi, "calledOnceWithExactly", true, "calledWithExactly", false, undefined, 1);
delegateToCalls(proxyApi, "alwaysCalledWithExactly", false, "calledWithExactly");
delegateToCalls(proxyApi, "neverCalledWith", false, "notCalledWith", false, function() {
return true;
});
delegateToCalls(proxyApi, "neverCalledWithMatch", false, "notCalledWithMatch", false, function() {
return true;
});
delegateToCalls(
proxyApi,
"calledOnceWithExactly",
true,
"calledWithExactly",
false,
undefined,
1
);
delegateToCalls(
proxyApi,
"calledOnceWithMatch",
true,
"calledWithMatch",
false,
undefined,
1
);
delegateToCalls(
proxyApi,
"alwaysCalledWithExactly",
false,
"calledWithExactly"
);
delegateToCalls(
proxyApi,
"neverCalledWith",
false,
"notCalledWith",
false,
function () {
return true;
}
);
delegateToCalls(
proxyApi,
"neverCalledWithMatch",
false,
"notCalledWithMatch",
false,
function () {
return true;
}
);
delegateToCalls(proxyApi, "threw", true);
delegateToCalls(proxyApi, "alwaysThrew", false, "threw");
delegateToCalls(proxyApi, "returned", true);
@ -308,7 +358,7 @@ function wrapFunction(func, originalFunc) {
thisValues: [],
exceptions: [],
callIds: [],
errorsWithCallStack: []
errorsWithCallStack: [],
});
return p;
}

View file

@ -1,6 +1,7 @@
"use strict";
var arrayProto = require("@sinonjs/commons").prototypes.array;
var logger = require("@sinonjs/commons").deprecated;
var collectOwnMethods = require("./collect-own-methods");
var getPropertyDescriptor = require("./util/core/get-property-descriptor");
var isPropertyConfigurable = require("./util/core/is-property-configurable");
@ -16,27 +17,47 @@ var fakeServer = require("nise").fakeServer;
var fakeXhr = require("nise").fakeXhr;
var usePromiseLibrary = require("./util/core/use-promise-library");
var DEFAULT_LEAK_THRESHOLD = 10000;
var filter = arrayProto.filter;
var forEach = arrayProto.filter;
var forEach = arrayProto.forEach;
var push = arrayProto.push;
var reverse = arrayProto.reverse;
function applyOnEach(fakes, method) {
var matchingFakes = filter(fakes, function(fake) {
var matchingFakes = filter(fakes, function (fake) {
return typeof fake[method] === "function";
});
forEach(matchingFakes, function(fake) {
forEach(matchingFakes, function (fake) {
fake[method]();
});
}
function Sandbox() {
var sandbox = this;
var collection = [];
var fakeRestorers = [];
var promiseLib;
var collection = [];
var loggedLeakWarning = false;
sandbox.leakThreshold = DEFAULT_LEAK_THRESHOLD;
function addToCollection(object) {
if (
push(collection, object) > sandbox.leakThreshold &&
!loggedLeakWarning
) {
// eslint-disable-next-line no-console
logger.printWarning(
"Potential memory leak detected; be sure to call restore() to clean up your sandbox. To suppress this warning, modify the leakThreshold property of your sandbox."
);
loggedLeakWarning = true;
}
}
sandbox.assert = sinonAssert.createAssertObject();
sandbox.serverPrototype = fakeServer;
// this is for testing only
@ -45,7 +66,7 @@ function Sandbox() {
};
// this is for testing only
sandbox.getRestorers = function() {
sandbox.getRestorers = function () {
return fakeRestorers;
};
@ -54,8 +75,8 @@ function Sandbox() {
var ownMethods = collectOwnMethods(stubbed);
forEach(ownMethods, function(method) {
push(collection, method);
forEach(ownMethods, function (method) {
addToCollection(method);
});
usePromiseLibrary(promiseLib, ownMethods);
@ -64,35 +85,35 @@ function Sandbox() {
};
sandbox.inject = function inject(obj) {
obj.spy = function() {
obj.spy = function () {
return sandbox.spy.apply(null, arguments);
};
obj.stub = function() {
obj.stub = function () {
return sandbox.stub.apply(null, arguments);
};
obj.mock = function() {
obj.mock = function () {
return sandbox.mock.apply(null, arguments);
};
obj.createStubInstance = function() {
obj.createStubInstance = function () {
return sandbox.createStubInstance.apply(sandbox, arguments);
};
obj.fake = function() {
obj.fake = function () {
return sandbox.fake.apply(null, arguments);
};
obj.replace = function() {
obj.replace = function () {
return sandbox.replace.apply(null, arguments);
};
obj.replaceSetter = function() {
obj.replaceSetter = function () {
return sandbox.replaceSetter.apply(null, arguments);
};
obj.replaceGetter = function() {
obj.replaceGetter = function () {
return sandbox.replaceGetter.apply(null, arguments);
};
@ -113,7 +134,7 @@ function Sandbox() {
sandbox.mock = function mock() {
var m = sinonMock.apply(null, arguments);
push(collection, m);
addToCollection(m);
usePromiseLibrary(promiseLib, m);
return m;
@ -136,7 +157,7 @@ function Sandbox() {
}
}
forEach(collection, function(fake) {
forEach(collection, function (fake) {
if (typeof fake === "function") {
privateResetHistory(fake);
return;
@ -157,14 +178,16 @@ function Sandbox() {
sandbox.restore = function restore() {
if (arguments.length) {
throw new Error("sandbox.restore() does not take any parameters. Perhaps you meant stub.restore()");
throw new Error(
"sandbox.restore() does not take any parameters. Perhaps you meant stub.restore()"
);
}
reverse(collection);
applyOnEach(collection, "restore");
collection = [];
forEach(fakeRestorers, function(restorer) {
forEach(fakeRestorers, function (restorer) {
restorer();
});
fakeRestorers = [];
@ -180,7 +203,7 @@ function Sandbox() {
return;
}
forEach(injectedKeys, function(injectedKey) {
forEach(injectedKeys, function (injectedKey) {
delete injectInto[injectedKey];
});
@ -203,9 +226,14 @@ function Sandbox() {
}
function verifyNotReplaced(object, property) {
forEach(fakeRestorers, function(fakeRestorer) {
if (fakeRestorer.object === object && fakeRestorer.property === property) {
throw new TypeError("Attempted to replace " + property + " which is already replaced");
forEach(fakeRestorers, function (fakeRestorer) {
if (
fakeRestorer.object === object &&
fakeRestorer.property === property
) {
throw new TypeError(
`Attempted to replace ${property} which is already replaced`
);
}
});
}
@ -214,7 +242,11 @@ function Sandbox() {
var descriptor = getPropertyDescriptor(object, property);
if (typeof descriptor === "undefined") {
throw new TypeError("Cannot replace non-existent property " + valueToString(property));
throw new TypeError(
`Cannot replace non-existent property ${valueToString(
property
)}`
);
}
if (typeof replacement === "undefined") {
@ -230,7 +262,11 @@ function Sandbox() {
}
if (typeof object[property] !== typeof replacement) {
throw new TypeError("Cannot replace " + typeof object[property] + " with " + typeof replacement);
throw new TypeError(
`Cannot replace ${typeof object[
property
]} with ${typeof replacement}`
);
}
verifyNotReplaced(object, property);
@ -243,15 +279,25 @@ function Sandbox() {
return replacement;
};
sandbox.replaceGetter = function replaceGetter(object, property, replacement) {
sandbox.replaceGetter = function replaceGetter(
object,
property,
replacement
) {
var descriptor = getPropertyDescriptor(object, property);
if (typeof descriptor === "undefined") {
throw new TypeError("Cannot replace non-existent property " + valueToString(property));
throw new TypeError(
`Cannot replace non-existent property ${valueToString(
property
)}`
);
}
if (typeof replacement !== "function") {
throw new TypeError("Expected replacement argument to be a function");
throw new TypeError(
"Expected replacement argument to be a function"
);
}
if (typeof descriptor.get !== "function") {
@ -265,21 +311,31 @@ function Sandbox() {
Object.defineProperty(object, property, {
get: replacement,
configurable: isPropertyConfigurable(object, property)
configurable: isPropertyConfigurable(object, property),
});
return replacement;
};
sandbox.replaceSetter = function replaceSetter(object, property, replacement) {
sandbox.replaceSetter = function replaceSetter(
object,
property,
replacement
) {
var descriptor = getPropertyDescriptor(object, property);
if (typeof descriptor === "undefined") {
throw new TypeError("Cannot replace non-existent property " + valueToString(property));
throw new TypeError(
`Cannot replace non-existent property ${valueToString(
property
)}`
);
}
if (typeof replacement !== "function") {
throw new TypeError("Expected replacement argument to be a function");
throw new TypeError(
"Expected replacement argument to be a function"
);
}
if (typeof descriptor.set !== "function") {
@ -294,7 +350,7 @@ function Sandbox() {
// eslint-disable-next-line accessor-pairs
Object.defineProperty(object, property, {
set: replacement,
configurable: isPropertyConfigurable(object, property)
configurable: isPropertyConfigurable(object, property),
});
return replacement;
@ -304,18 +360,19 @@ function Sandbox() {
var object = args[0];
var property = args[1];
var isSpyingOnEntireObject = typeof property === "undefined" && typeof object === "object";
var isSpyingOnEntireObject =
typeof property === "undefined" && typeof object === "object";
if (isSpyingOnEntireObject) {
var ownMethods = collectOwnMethods(spy);
forEach(ownMethods, function(method) {
push(collection, method);
forEach(ownMethods, function (method) {
addToCollection(method);
});
usePromiseLibrary(promiseLib, ownMethods);
} else {
push(collection, spy);
addToCollection(spy);
usePromiseLibrary(promiseLib, spy);
}
@ -336,18 +393,18 @@ function Sandbox() {
sandbox.fake = function fake(f) {
var s = sinonFake.apply(sinonFake, arguments);
push(collection, s);
addToCollection(s);
return s;
};
forEach(Object.keys(sinonFake), function(key) {
forEach(Object.keys(sinonFake), function (key) {
var fakeBehavior = sinonFake[key];
if (typeof fakeBehavior === "function") {
sandbox.fake[key] = function() {
sandbox.fake[key] = function () {
var s = fakeBehavior.apply(fakeBehavior, arguments);
push(collection, s);
addToCollection(s);
return s;
};
@ -358,7 +415,7 @@ function Sandbox() {
var clock = sinonClock.useFakeTimers.call(null, args);
sandbox.clock = clock;
push(collection, clock);
addToCollection(clock);
return clock;
};
@ -391,14 +448,14 @@ function Sandbox() {
}
sandbox.server = proto.create();
push(collection, sandbox.server);
addToCollection(sandbox.server);
return sandbox.server;
};
sandbox.useFakeXMLHttpRequest = function useFakeXMLHttpRequest() {
var xhr = fakeXhr.useFakeXMLHttpRequest();
push(collection, xhr);
addToCollection(xhr);
return xhr;
};
@ -410,7 +467,6 @@ function Sandbox() {
};
}
Sandbox.prototype.assert = sinonAssert;
Sandbox.prototype.match = match;
module.exports = Sandbox;

View file

@ -10,6 +10,7 @@ var jsDiff = require("diff");
var join = arrayProto.join;
var map = arrayProto.map;
var push = arrayProto.push;
var slice = arrayProto.slice;
function colorSinonMatchText(matcher, calledArg, calledArgMessage) {
var calledArgumentMessage = calledArgMessage;
@ -19,11 +20,11 @@ function colorSinonMatchText(matcher, calledArg, calledArgMessage) {
calledArgumentMessage = color.green(calledArgumentMessage);
}
}
return calledArgumentMessage + " " + matcher.message;
return `${calledArgumentMessage} ${matcher.message}`;
}
function colorDiffText(diff) {
var objects = map(diff, function(part) {
var objects = map(diff, function (part) {
var text = part.value;
if (part.added) {
text = color.green(text);
@ -38,33 +39,66 @@ function colorDiffText(diff) {
return join(objects, "");
}
function quoteStringValue(value) {
if (typeof value === "string") {
return JSON.stringify(value);
}
return value;
}
module.exports = {
c: function(spyInstance) {
c: function (spyInstance) {
return timesInWords(spyInstance.callCount);
},
n: function(spyInstance) {
// eslint-disable-next-line local-rules/no-prototype-methods
n: function (spyInstance) {
// eslint-disable-next-line @sinonjs/no-prototype-methods/no-prototype-methods
return spyInstance.toString();
},
D: function(spyInstance, args) {
D: function (spyInstance, args) {
var message = "";
for (var i = 0, l = spyInstance.callCount; i < l; ++i) {
// describe multiple calls
if (l > 1) {
message += "\nCall " + (i + 1) + ":";
message += `\nCall ${i + 1}:`;
}
var calledArgs = spyInstance.getCall(i).args;
for (var j = 0; j < calledArgs.length || j < args.length; ++j) {
var expectedArgs = slice(args);
for (
var j = 0;
j < calledArgs.length || j < expectedArgs.length;
++j
) {
if (calledArgs[j]) {
calledArgs[j] = quoteStringValue(calledArgs[j]);
}
if (expectedArgs[j]) {
expectedArgs[j] = quoteStringValue(expectedArgs[j]);
}
message += "\n";
var calledArgMessage = j < calledArgs.length ? sinonFormat(calledArgs[j]) : "";
if (match.isMatcher(args[j])) {
message += colorSinonMatchText(args[j], calledArgs[j], calledArgMessage);
var calledArgMessage =
j < calledArgs.length ? sinonFormat(calledArgs[j]) : "";
if (match.isMatcher(expectedArgs[j])) {
message += colorSinonMatchText(
expectedArgs[j],
calledArgs[j],
calledArgMessage
);
} else {
var expectedArgMessage = j < args.length ? sinonFormat(args[j]) : "";
var diff = jsDiff.diffJson(calledArgMessage, expectedArgMessage);
var expectedArgMessage =
j < expectedArgs.length
? sinonFormat(expectedArgs[j])
: "";
var diff = jsDiff.diffJson(
calledArgMessage,
expectedArgMessage
);
message += colorDiffText(diff);
}
}
@ -73,22 +107,22 @@ module.exports = {
return message;
},
C: function(spyInstance) {
C: function (spyInstance) {
var calls = [];
for (var i = 0, l = spyInstance.callCount; i < l; ++i) {
// eslint-disable-next-line local-rules/no-prototype-methods
var stringifiedCall = " " + spyInstance.getCall(i).toString();
// eslint-disable-next-line @sinonjs/no-prototype-methods/no-prototype-methods
var stringifiedCall = ` ${spyInstance.getCall(i).toString()}`;
if (/\n/.test(calls[i - 1])) {
stringifiedCall = "\n" + stringifiedCall;
stringifiedCall = `\n${stringifiedCall}`;
}
push(calls, stringifiedCall);
}
return calls.length > 0 ? "\n" + join(calls, "\n") : "";
return calls.length > 0 ? `\n${join(calls, "\n")}` : "";
},
t: function(spyInstance) {
t: function (spyInstance) {
var objects = [];
for (var i = 0, l = spyInstance.callCount; i < l; ++i) {
@ -98,12 +132,12 @@ module.exports = {
return join(objects, ", ");
},
"*": function(spyInstance, args) {
"*": function (spyInstance, args) {
return join(
map(args, function(arg) {
map(args, function (arg) {
return sinonFormat(arg);
}),
", "
);
}
},
};

79
node_modules/sinon/lib/sinon/spy.js generated vendored
View file

@ -23,7 +23,10 @@ var uuid = 0;
function matches(fake, args, strict) {
var margs = fake.matchingArguments;
if (margs.length <= args.length && deepEqual(slice(args, 0, margs.length), margs)) {
if (
margs.length <= args.length &&
deepEqual(slice(args, 0, margs.length), margs)
) {
return !strict || margs.length === args.length;
}
return false;
@ -31,7 +34,7 @@ function matches(fake, args, strict) {
// Public API
var spyApi = {
withArgs: function() {
withArgs: function () {
var args = slice(arguments);
var matching = pop(this.matchingFakes(args, true));
if (matching) {
@ -44,11 +47,11 @@ var spyApi = {
fake.parent = this;
push(this.fakes, fake);
fake.withArgs = function() {
fake.withArgs = function () {
return original.withArgs.apply(original, arguments);
};
forEach(original.args, function(arg, i) {
forEach(original.args, function (arg, i) {
if (!matches(fake, arg)) {
return;
}
@ -67,52 +70,72 @@ var spyApi = {
},
// Override proxy default implementation
matchingFakes: function(args, strict) {
return filter.call(this.fakes, function(fake) {
matchingFakes: function (args, strict) {
return filter.call(this.fakes, function (fake) {
return matches(fake, args, strict);
});
}
},
};
/* eslint-disable local-rules/no-prototype-methods */
/* eslint-disable @sinonjs/no-prototype-methods/no-prototype-methods */
var delegateToCalls = proxyCallUtil.delegateToCalls;
delegateToCalls(spyApi, "callArg", false, "callArgWith", true, function() {
throw new Error(this.toString() + " cannot call arg since it was not yet invoked.");
delegateToCalls(spyApi, "callArg", false, "callArgWith", true, function () {
throw new Error(
`${this.toString()} cannot call arg since it was not yet invoked.`
);
});
spyApi.callArgWith = spyApi.callArg;
delegateToCalls(spyApi, "callArgOn", false, "callArgOnWith", true, function() {
throw new Error(this.toString() + " cannot call arg since it was not yet invoked.");
delegateToCalls(spyApi, "callArgOn", false, "callArgOnWith", true, function () {
throw new Error(
`${this.toString()} cannot call arg since it was not yet invoked.`
);
});
spyApi.callArgOnWith = spyApi.callArgOn;
delegateToCalls(spyApi, "throwArg", false, "throwArg", false, function() {
throw new Error(this.toString() + " cannot throw arg since it was not yet invoked.");
delegateToCalls(spyApi, "throwArg", false, "throwArg", false, function () {
throw new Error(
`${this.toString()} cannot throw arg since it was not yet invoked.`
);
});
delegateToCalls(spyApi, "yield", false, "yield", true, function() {
throw new Error(this.toString() + " cannot yield since it was not yet invoked.");
delegateToCalls(spyApi, "yield", false, "yield", true, function () {
throw new Error(
`${this.toString()} cannot yield since it was not yet invoked.`
);
});
// "invokeCallback" is an alias for "yield" since "yield" is invalid in strict mode.
spyApi.invokeCallback = spyApi.yield;
delegateToCalls(spyApi, "yieldOn", false, "yieldOn", true, function() {
throw new Error(this.toString() + " cannot yield since it was not yet invoked.");
});
delegateToCalls(spyApi, "yieldTo", false, "yieldTo", true, function(property) {
delegateToCalls(spyApi, "yieldOn", false, "yieldOn", true, function () {
throw new Error(
this.toString() + " cannot yield to '" + valueToString(property) + "' since it was not yet invoked."
`${this.toString()} cannot yield since it was not yet invoked.`
);
});
delegateToCalls(spyApi, "yieldToOn", false, "yieldToOn", true, function(property) {
delegateToCalls(spyApi, "yieldTo", false, "yieldTo", true, function (property) {
throw new Error(
this.toString() + " cannot yield to '" + valueToString(property) + "' since it was not yet invoked."
`${this.toString()} cannot yield to '${valueToString(
property
)}' since it was not yet invoked.`
);
});
/* eslint-enable local-rules/no-prototype-methods */
delegateToCalls(
spyApi,
"yieldToOn",
false,
"yieldToOn",
true,
function (property) {
throw new Error(
`${this.toString()} cannot yield to '${valueToString(
property
)}' since it was not yet invoked.`
);
}
);
function createSpy(func) {
var name;
var funk = func;
if (typeof funk !== "function") {
funk = function() {
funk = function () {
return;
};
} else {
@ -127,7 +150,7 @@ function createSpy(func) {
displayName: name || "spy",
fakes: [],
instantiateFake: createSpy,
id: "spy#" + uuid++
id: `spy#${uuid++}`,
});
return proxy;
}
@ -148,7 +171,7 @@ function spy(object, property, types) {
}
if (!object && !property) {
return createSpy(function() {
return createSpy(function () {
return;
});
}
@ -160,7 +183,7 @@ function spy(object, property, types) {
descriptor = {};
methodDesc = getPropertyDescriptor(object, property);
forEach(types, function(type) {
forEach(types, function (type) {
descriptor[type] = createSpy(methodDesc[type]);
});

72
node_modules/sinon/lib/sinon/stub.js generated vendored
View file

@ -5,7 +5,8 @@ var behavior = require("./behavior");
var behaviors = require("./default-behaviors");
var createProxy = require("./proxy");
var functionName = require("@sinonjs/commons").functionName;
var hasOwnProperty = require("@sinonjs/commons").prototypes.object.hasOwnProperty;
var hasOwnProperty =
require("@sinonjs/commons").prototypes.object.hasOwnProperty;
var isNonExistentProperty = require("./util/core/is-non-existent-property");
var spy = require("./spy");
var extend = require("./util/core/extend");
@ -32,8 +33,10 @@ function createStub(originalFunc) {
var fnStub =
pop(
sort(matchings, function(a, b) {
return a.matchingArguments.length - b.matchingArguments.length;
sort(matchings, function (a, b) {
return (
a.matchingArguments.length - b.matchingArguments.length
);
})
) || proxy;
return getCurrentBehavior(fnStub).invoke(this, arguments);
@ -52,7 +55,7 @@ function createStub(originalFunc) {
displayName: name || "stub",
defaultBehavior: null,
behaviors: [],
id: "stub#" + uuid++
id: `stub#${uuid++}`,
});
return proxy;
@ -60,7 +63,9 @@ function createStub(originalFunc) {
function stub(object, property) {
if (arguments.length > 2) {
throw new TypeError("stub(obj, 'meth', fn) has been removed, see documentation");
throw new TypeError(
"stub(obj, 'meth', fn) has been removed, see documentation"
);
}
if (isEsModule(object)) {
@ -70,18 +75,22 @@ function stub(object, property) {
throwOnFalsyObject.apply(null, arguments);
if (isNonExistentProperty(object, property)) {
throw new TypeError("Cannot stub non-existent property " + valueToString(property));
throw new TypeError(
`Cannot stub non-existent property ${valueToString(property)}`
);
}
var actualDescriptor = getPropertyDescriptor(object, property);
var isObjectOrFunction = typeof object === "object" || typeof object === "function";
var isStubbingEntireObject = typeof property === "undefined" && isObjectOrFunction;
var isObjectOrFunction =
typeof object === "object" || typeof object === "function";
var isStubbingEntireObject =
typeof property === "undefined" && isObjectOrFunction;
var isCreatingNewStub = !object && typeof property === "undefined";
var isStubbingNonFuncProperty =
isObjectOrFunction &&
typeof property !== "undefined" &&
(typeof actualDescriptor === "undefined" || typeof actualDescriptor.value !== "function") &&
typeof descriptor === "undefined";
(typeof actualDescriptor === "undefined" ||
typeof actualDescriptor.value !== "function");
if (isStubbingEntireObject) {
return walkObject(stub, object);
@ -91,7 +100,10 @@ function stub(object, property) {
return createStub();
}
var func = typeof actualDescriptor.value === "function" ? actualDescriptor.value : null;
var func =
typeof actualDescriptor.value === "function"
? actualDescriptor.value
: null;
var s = createStub(func);
extend.nonEnum(s, {
@ -105,20 +117,20 @@ function stub(object, property) {
}
delete object[property];
}
},
});
return isStubbingNonFuncProperty ? s : wrapMethod(object, property, s);
}
stub.createStubInstance = function(constructor, overrides) {
stub.createStubInstance = function (constructor, overrides) {
if (typeof constructor !== "function") {
throw new TypeError("The constructor should be a function.");
}
var stubbedObject = stub(Object.create(constructor.prototype));
forEach(Object.keys(overrides || {}), function(propertyName) {
forEach(Object.keys(overrides || {}), function (propertyName) {
if (propertyName in stubbedObject) {
var value = overrides[propertyName];
if (value && value.createStubInstance) {
@ -127,7 +139,9 @@ stub.createStubInstance = function(constructor, overrides) {
stubbedObject[propertyName].returns(value);
}
} else {
throw new Error("Cannot stub " + propertyName + ". Property does not exist!");
throw new Error(
`Cannot stub ${propertyName}. Property does not exist!`
);
}
});
return stubbedObject;
@ -139,17 +153,23 @@ function getParentBehaviour(stubInstance) {
}
function getDefaultBehavior(stubInstance) {
return stubInstance.defaultBehavior || getParentBehaviour(stubInstance) || behavior.create(stubInstance);
return (
stubInstance.defaultBehavior ||
getParentBehaviour(stubInstance) ||
behavior.create(stubInstance)
);
}
function getCurrentBehavior(stubInstance) {
var currentBehavior = stubInstance.behaviors[stubInstance.callCount - 1];
return currentBehavior && currentBehavior.isPresent() ? currentBehavior : getDefaultBehavior(stubInstance);
return currentBehavior && currentBehavior.isPresent()
? currentBehavior
: getDefaultBehavior(stubInstance);
}
/*eslint-enable no-use-before-define*/
var proto = {
resetBehavior: function() {
resetBehavior: function () {
this.defaultBehavior = null;
this.behaviors = [];
@ -161,12 +181,12 @@ var proto = {
this.returnThis = false;
this.resolveThis = false;
forEach(this.fakes, function(fake) {
forEach(this.fakes, function (fake) {
fake.resetBehavior();
});
},
reset: function() {
reset: function () {
this.resetHistory();
this.resetBehavior();
},
@ -194,14 +214,16 @@ var proto = {
withArgs: function withArgs() {
var fake = spy.withArgs.apply(this, arguments);
if (this.defaultBehavior && this.defaultBehavior.promiseLibrary) {
fake.defaultBehavior = fake.defaultBehavior || behavior.create(fake);
fake.defaultBehavior.promiseLibrary = this.defaultBehavior.promiseLibrary;
fake.defaultBehavior =
fake.defaultBehavior || behavior.create(fake);
fake.defaultBehavior.promiseLibrary =
this.defaultBehavior.promiseLibrary;
}
return fake;
}
},
};
forEach(Object.keys(behavior), function(method) {
forEach(Object.keys(behavior), function (method) {
if (
hasOwnProperty(behavior, method) &&
!hasOwnProperty(proto, method) &&
@ -212,7 +234,7 @@ forEach(Object.keys(behavior), function(method) {
}
});
forEach(Object.keys(behaviors), function(method) {
forEach(Object.keys(behaviors), function (method) {
if (hasOwnProperty(behaviors, method) && !hasOwnProperty(proto, method)) {
behavior.addBehavior(stub, method, behaviors[method]);
}

View file

@ -4,7 +4,9 @@ var valueToString = require("@sinonjs/commons").valueToString;
function throwOnFalsyObject(object, property) {
if (property && !object) {
var type = object === null ? "null" : "undefined";
throw new Error("Trying to stub property '" + valueToString(property) + "' of " + type);
throw new Error(
`Trying to stub property '${valueToString(property)}' of ${type}`
);
}
}

View file

@ -13,8 +13,8 @@ module.exports = {
"replace",
"replaceSetter",
"replaceGetter",
"createStubInstance"
"createStubInstance",
],
useFakeTimers: true,
useFakeServer: true
useFakeServer: true,
};

View file

@ -6,10 +6,10 @@ var reduce = arrayProto.reduce;
module.exports = function exportAsyncBehaviors(behaviorMethods) {
return reduce(
Object.keys(behaviorMethods),
function(acc, method) {
function (acc, method) {
// need to avoid creating another async versions of the newly added async methods
if (method.match(/^(callsArg|yields)/) && !method.match(/Async/)) {
acc[method + "Async"] = function() {
acc[`${method}Async`] = function () {
var result = behaviorMethods[method].apply(this, arguments);
this.callbackAsync = true;
return result;

View file

@ -1,45 +1,45 @@
"use strict";
var arrayProto = require("@sinonjs/commons").prototypes.array;
var hasOwnProperty = require("@sinonjs/commons").prototypes.object.hasOwnProperty;
var hasOwnProperty =
require("@sinonjs/commons").prototypes.object.hasOwnProperty;
var join = arrayProto.join;
var push = arrayProto.push;
var slice = arrayProto.slice;
// Adapted from https://developer.mozilla.org/en/docs/ECMAScript_DontEnum_attribute#JScript_DontEnum_Bug
var hasDontEnumBug = (function() {
var hasDontEnumBug = (function () {
var obj = {
constructor: function() {
constructor: function () {
return "0";
},
toString: function() {
toString: function () {
return "1";
},
valueOf: function() {
valueOf: function () {
return "2";
},
toLocaleString: function() {
toLocaleString: function () {
return "3";
},
prototype: function() {
prototype: function () {
return "4";
},
isPrototypeOf: function() {
isPrototypeOf: function () {
return "5";
},
propertyIsEnumerable: function() {
propertyIsEnumerable: function () {
return "6";
},
hasOwnProperty: function() {
hasOwnProperty: function () {
return "7";
},
length: function() {
length: function () {
return "8";
},
unique: function() {
unique: function () {
return "9";
}
},
};
var result = [];
@ -65,7 +65,11 @@ function extendCommon(target, sources, doCopy) {
// Make sure we copy (own) toString method even when in JScript with DontEnum bug
// See https://developer.mozilla.org/en/docs/ECMAScript_DontEnum_attribute#JScript_DontEnum_Bug
if (hasDontEnumBug && hasOwnProperty(source, "toString") && source.toString !== target.toString) {
if (
hasDontEnumBug &&
hasOwnProperty(source, "toString") &&
source.toString !== target.toString
) {
target.toString = source.toString;
}
}
@ -73,39 +77,78 @@ function extendCommon(target, sources, doCopy) {
return target;
}
/** Public: Extend target in place with all (own) properties from sources in-order. Thus, last source will
* override properties in previous sources.
/** Public: Extend target in place with all (own) properties, except 'name' when [[writable]] is false,
* from sources in-order. Thus, last source will override properties in previous sources.
*
* @arg {Object} target - The Object to extend
* @arg {Object[]} sources - Objects to copy properties from.
* @param {object} target - The Object to extend
* @param {object[]} sources - Objects to copy properties from.
*
* @returns {Object} the extended target
* @returns {object} the extended target
*/
module.exports = function extend(target /*, sources */) {
var sources = slice(arguments, 1);
module.exports = function extend(target, ...sources) {
return extendCommon(
target,
sources,
function copyValue(dest, source, prop) {
var destOwnPropertyDescriptor = Object.getOwnPropertyDescriptor(
dest,
prop
);
var sourceOwnPropertyDescriptor = Object.getOwnPropertyDescriptor(
source,
prop
);
return extendCommon(target, sources, function copyValue(dest, source, prop) {
dest[prop] = source[prop];
});
if (prop === "name" && !destOwnPropertyDescriptor.writable) {
return;
}
const descriptors = {
configurable: sourceOwnPropertyDescriptor.configurable,
enumerable: sourceOwnPropertyDescriptor.enumerable,
};
/*
if the sorce has an Accessor property copy over the accessor functions (get and set)
data properties has writable attribute where as acessor property don't
REF: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#properties
*/
if (hasOwnProperty(sourceOwnPropertyDescriptor, "writable")) {
descriptors.writable = sourceOwnPropertyDescriptor.writable;
descriptors.value = sourceOwnPropertyDescriptor.value;
} else {
if (sourceOwnPropertyDescriptor.get) {
descriptors.get =
sourceOwnPropertyDescriptor.get.bind(dest);
}
if (sourceOwnPropertyDescriptor.set) {
descriptors.set =
sourceOwnPropertyDescriptor.set.bind(dest);
}
}
Object.defineProperty(dest, prop, descriptors);
}
);
};
/** Public: Extend target in place with all (own) properties from sources in-order. Thus, last source will
* override properties in previous sources. Define the properties as non enumerable.
*
* @arg {Object} target - The Object to extend
* @arg {Object[]} sources - Objects to copy properties from.
* @param {object} target - The Object to extend
* @param {object[]} sources - Objects to copy properties from.
*
* @returns {Object} the extended target
* @returns {object} the extended target
*/
module.exports.nonEnum = function extendNonEnum(target /*, sources */) {
var sources = slice(arguments, 1);
return extendCommon(target, sources, function copyProperty(dest, source, prop) {
Object.defineProperty(dest, prop, {
value: source[prop],
enumerable: false,
configurable: true,
writable: true
});
});
module.exports.nonEnum = function extendNonEnum(target, ...sources) {
return extendCommon(
target,
sources,
function copyProperty(dest, source, prop) {
Object.defineProperty(dest, prop, {
value: source[prop],
enumerable: false,
configurable: true,
writable: true,
});
}
);
};

View file

@ -1,12 +1,6 @@
"use strict";
var formatio = require("@sinonjs/formatio");
var formatter = formatio.configure({
quoteStrings: false,
limitChildrenCount: 250
});
var inspect = require("util").inspect;
var customFormatter;
function format() {
@ -14,10 +8,10 @@ function format() {
return customFormatter.apply(null, arguments);
}
return formatter.ascii.apply(formatter, arguments);
return inspect.apply(inspect, arguments);
}
format.setFormatter = function(aCustomFormatter) {
format.setFormatter = function (aCustomFormatter) {
if (typeof aCustomFormatter !== "function") {
throw new Error("format.setFormatter must be called with a function");
}

View file

@ -1,7 +1,8 @@
"use strict";
var defaultConfig = require("./default-config");
var hasOwnProperty = require("@sinonjs/commons").prototypes.object.hasOwnProperty;
var hasOwnProperty =
require("@sinonjs/commons").prototypes.object.hasOwnProperty;
module.exports = function getConfig(custom) {
var config = {};
@ -10,7 +11,9 @@ module.exports = function getConfig(custom) {
for (prop in defaultConfig) {
if (hasOwnProperty(defaultConfig, prop)) {
config[prop] = hasOwnProperty(kustom, prop) ? kustom[prop] : defaultConfig[prop];
config[prop] = hasOwnProperty(kustom, prop)
? kustom[prop]
: defaultConfig[prop];
}
}

View file

@ -3,9 +3,14 @@
module.exports = function getPropertyDescriptor(object, property) {
var proto = object;
var descriptor;
var isOwn = Boolean(object && Object.getOwnPropertyDescriptor(object, property));
var isOwn = Boolean(
object && Object.getOwnPropertyDescriptor(object, property)
);
while (proto && !(descriptor = Object.getOwnPropertyDescriptor(proto, property))) {
while (
proto &&
!(descriptor = Object.getOwnPropertyDescriptor(proto, property))
) {
proto = Object.getPrototypeOf(proto);
}

View file

@ -7,12 +7,15 @@
* using spies or stubs. Let the consumer know this to avoid bug reports
* on weird error messages.
*
* @param {Object} object The object to examine
* @param {object} object The object to examine
*
* @returns {Boolean} true when the object is a module
* @returns {boolean} true when the object is a module
*/
module.exports = function(object) {
module.exports = function (object) {
return (
object && typeof Symbol !== "undefined" && object[Symbol.toStringTag] === "Module" && Object.isSealed(object)
object &&
typeof Symbol !== "undefined" &&
object[Symbol.toStringTag] === "Module" &&
Object.isSealed(object)
);
};

View file

@ -2,11 +2,13 @@
/**
* @param {*} object
* @param {String} property
* @returns whether a prop exists in the prototype chain
* @param {string} property
* @returns {boolean} whether a prop exists in the prototype chain
*/
function isNonExistentProperty(object, property) {
return object && typeof property !== "undefined" && !(property in object);
return Boolean(
object && typeof property !== "undefined" && !(property in object)
);
}
module.exports = isNonExistentProperty;

View file

@ -1,7 +1,11 @@
"use strict";
function isRestorable(obj) {
return typeof obj === "function" && typeof obj.restore === "function" && obj.restore.sinon;
return (
typeof obj === "function" &&
typeof obj.restore === "function" &&
obj.restore.sinon
);
}
module.exports = isRestorable;

View file

@ -5,7 +5,7 @@ var walk = require("./walk");
module.exports = function restore(object) {
if (object !== null && typeof object === "object") {
walk(object, function(prop) {
walk(object, function (prop) {
if (isRestorable(object[prop])) {
object[prop].restore();
}

View file

@ -3,5 +3,5 @@
var array = [null, "once", "twice", "thrice"];
module.exports = function timesInWords(count) {
return array[count] || (count || 0) + " times";
return array[count] || `${count || 0} times`;
};

View file

@ -10,10 +10,12 @@ function walkObject(predicate, object, filter) {
var name = functionName(predicate);
if (!object) {
throw new Error("Trying to " + name + " object but received " + String(object));
throw new Error(
`Trying to ${name} object but received ${String(object)}`
);
}
walk(object, function(prop, propOwner) {
walk(object, function (prop, propOwner) {
// we don't want to stub things like toString(), valueOf(), etc. so we only stub if the object
// is not Object.prototype
if (
@ -34,7 +36,7 @@ function walkObject(predicate, object, filter) {
});
if (!called) {
throw new Error("Expected to " + name + " methods on object but found none");
throw new Error(`Expected to ${name} methods on object but found none`);
}
return object;

View file

@ -16,10 +16,14 @@ function walkInternal(obj, iterator, context, originalObj, seen) {
return;
}
forEach(Object.getOwnPropertyNames(obj), function(k) {
forEach(Object.getOwnPropertyNames(obj), function (k) {
if (seen[k] !== true) {
seen[k] = true;
var target = typeof Object.getOwnPropertyDescriptor(obj, k).get === "function" ? originalObj : obj;
var target =
typeof Object.getOwnPropertyDescriptor(obj, k).get ===
"function"
? originalObj
: obj;
iterator.call(context, k, target);
}
});

View file

@ -2,11 +2,16 @@
var getPropertyDescriptor = require("./get-property-descriptor");
var extend = require("./extend");
var hasOwnProperty = require("@sinonjs/commons").prototypes.object.hasOwnProperty;
var hasOwnProperty =
require("@sinonjs/commons").prototypes.object.hasOwnProperty;
var valueToString = require("@sinonjs/commons").valueToString;
var push = require("@sinonjs/commons").prototypes.array.push;
function isFunction(obj) {
return typeof obj === "function" || Boolean(obj && obj.constructor && obj.call && obj.apply);
return (
typeof obj === "function" ||
Boolean(obj && obj.constructor && obj.call && obj.apply)
);
}
function mirrorProperties(target, source) {
@ -17,6 +22,21 @@ function mirrorProperties(target, source) {
}
}
function getAccessor(object, property, method) {
var accessors = ["get", "set"];
var descriptor = getPropertyDescriptor(object, property);
for (var i = 0; i < accessors.length; i++) {
if (
descriptor[accessors[i]] &&
descriptor[accessors[i]].name === method.name
) {
return accessors[i];
}
}
return null;
}
// Cheap way to detect if we have ES5 support.
var hasES5Support = "keys" in Object;
@ -26,7 +46,9 @@ module.exports = function wrapMethod(object, property, method) {
}
if (typeof method !== "function" && typeof method !== "object") {
throw new TypeError("Method wrapper should be a function or a property descriptor");
throw new TypeError(
"Method wrapper should be a function or a property descriptor"
);
}
function checkWrappedMethod(wrappedMethod) {
@ -34,24 +56,42 @@ module.exports = function wrapMethod(object, property, method) {
if (!isFunction(wrappedMethod)) {
error = new TypeError(
"Attempted to wrap " + typeof wrappedMethod + " property " + valueToString(property) + " as function"
`Attempted to wrap ${typeof wrappedMethod} property ${valueToString(
property
)} as function`
);
} else if (wrappedMethod.restore && wrappedMethod.restore.sinon) {
error = new TypeError("Attempted to wrap " + valueToString(property) + " which is already wrapped");
error = new TypeError(
`Attempted to wrap ${valueToString(
property
)} which is already wrapped`
);
} else if (wrappedMethod.calledBefore) {
var verb = wrappedMethod.returns ? "stubbed" : "spied on";
error = new TypeError("Attempted to wrap " + valueToString(property) + " which is already " + verb);
error = new TypeError(
`Attempted to wrap ${valueToString(
property
)} which is already ${verb}`
);
}
if (error) {
if (wrappedMethod && wrappedMethod.stackTraceError) {
error.stack += "\n--------------\n" + wrappedMethod.stackTraceError.stack;
error.stack += `\n--------------\n${wrappedMethod.stackTraceError.stack}`;
}
throw error;
}
}
var error, wrappedMethod, i, wrappedMethodDesc;
var error,
wrappedMethods,
wrappedMethod,
i,
wrappedMethodDesc,
target,
accessor;
wrappedMethods = [];
function simplePropertyAssignment() {
wrappedMethod = object[property];
@ -61,23 +101,30 @@ module.exports = function wrapMethod(object, property, method) {
}
// Firefox has a problem when using hasOwn.call on objects from other frames.
/* eslint-disable-next-line local-rules/no-prototype-methods */
var owned = object.hasOwnProperty ? object.hasOwnProperty(property) : hasOwnProperty(object, property);
var owned = object.hasOwnProperty
? object.hasOwnProperty(property) // eslint-disable-line @sinonjs/no-prototype-methods/no-prototype-methods
: hasOwnProperty(object, property);
if (hasES5Support) {
var methodDesc = typeof method === "function" ? { value: method } : method;
var methodDesc =
typeof method === "function" ? { value: method } : method;
wrappedMethodDesc = getPropertyDescriptor(object, property);
if (!wrappedMethodDesc) {
error = new TypeError(
"Attempted to wrap " + typeof wrappedMethod + " property " + property + " as function"
`Attempted to wrap ${typeof wrappedMethod} property ${property} as function`
);
} else if (
wrappedMethodDesc.restore &&
wrappedMethodDesc.restore.sinon
) {
error = new TypeError(
`Attempted to wrap ${property} which is already wrapped`
);
} else if (wrappedMethodDesc.restore && wrappedMethodDesc.restore.sinon) {
error = new TypeError("Attempted to wrap " + property + " which is already wrapped");
}
if (error) {
if (wrappedMethodDesc && wrappedMethodDesc.stackTraceError) {
error.stack += "\n--------------\n" + wrappedMethodDesc.stackTraceError.stack;
error.stack += `\n--------------\n${wrappedMethodDesc.stackTraceError.stack}`;
}
throw error;
}
@ -86,6 +133,7 @@ module.exports = function wrapMethod(object, property, method) {
for (i = 0; i < types.length; i++) {
wrappedMethod = wrappedMethodDesc[types[i]];
checkWrappedMethod(wrappedMethod);
push(wrappedMethods, wrappedMethod);
}
mirrorProperties(methodDesc, wrappedMethodDesc);
@ -106,49 +154,82 @@ module.exports = function wrapMethod(object, property, method) {
simplePropertyAssignment();
}
extend.nonEnum(method, {
displayName: property,
extendObjectWithWrappedMethods();
wrappedMethod: wrappedMethod,
function extendObjectWithWrappedMethods() {
for (i = 0; i < wrappedMethods.length; i++) {
accessor = getAccessor(object, property, wrappedMethods[i]);
target = accessor ? method[accessor] : method;
extend.nonEnum(target, {
displayName: property,
wrappedMethod: wrappedMethods[i],
// Set up an Error object for a stack trace which can be used later to find what line of
// code the original method was created on.
stackTraceError: new Error("Stack Trace for original"),
// Set up an Error object for a stack trace which can be used later to find what line of
// code the original method was created on.
stackTraceError: new Error("Stack Trace for original"),
restore: function() {
// For prototype properties try to reset by delete first.
// If this fails (ex: localStorage on mobile safari) then force a reset
// via direct assignment.
restore: restore,
});
target.restore.sinon = true;
if (!hasES5Support) {
mirrorProperties(target, wrappedMethod);
}
}
}
function restore() {
accessor = getAccessor(object, property, this.wrappedMethod);
var descriptor;
// For prototype properties try to reset by delete first.
// If this fails (ex: localStorage on mobile safari) then force a reset
// via direct assignment.
if (accessor) {
if (!owned) {
// In some cases `delete` may throw an error
try {
delete object[property];
// In some cases `delete` may throw an error
delete object[property][accessor];
} catch (e) {} // eslint-disable-line no-empty
// For native code functions `delete` fails without throwing an error
// on Chrome < 43, PhantomJS, etc.
} else if (hasES5Support) {
descriptor = getPropertyDescriptor(object, property);
descriptor[accessor] = wrappedMethodDesc[accessor];
Object.defineProperty(object, property, descriptor);
}
if (hasES5Support) {
descriptor = getPropertyDescriptor(object, property);
if (descriptor && descriptor.value === target) {
object[property][accessor] = this.wrappedMethod;
}
} else {
// Use strict equality comparison to check failures then force a reset
// via direct assignment.
if (object[property][accessor] === target) {
object[property][accessor] = this.wrappedMethod;
}
}
} else {
if (!owned) {
try {
delete object[property];
} catch (e) {} // eslint-disable-line no-empty
} else if (hasES5Support) {
Object.defineProperty(object, property, wrappedMethodDesc);
}
if (hasES5Support) {
var descriptor = getPropertyDescriptor(object, property);
if (descriptor && descriptor.value === method) {
object[property] = wrappedMethod;
descriptor = getPropertyDescriptor(object, property);
if (descriptor && descriptor.value === target) {
object[property] = this.wrappedMethod;
}
} else {
// Use strict equality comparison to check failures then force a reset
// via direct assignment.
if (object[property] === method) {
object[property] = wrappedMethod;
if (object[property] === target) {
object[property] = this.wrappedMethod;
}
}
}
});
method.restore.sinon = true;
if (!hasES5Support) {
mirrorProperties(method, wrappedMethod);
}
return method;

View file

@ -22,24 +22,28 @@ function addIfDefined(obj, globalPropName) {
}
/**
* @param {number|Date|Object} dateOrConfig The unix epoch value to install with (default 0)
* @returns {Object} Returns a lolex clock instance
* @param {number|Date|object} dateOrConfig The unix epoch value to install with (default 0)
* @returns {object} Returns a lolex clock instance
*/
exports.useFakeTimers = function(dateOrConfig) {
exports.useFakeTimers = function (dateOrConfig) {
var hasArguments = typeof dateOrConfig !== "undefined";
var argumentIsDateLike =
(typeof dateOrConfig === "number" || dateOrConfig instanceof Date) && arguments.length === 1;
var argumentIsObject = dateOrConfig !== null && typeof dateOrConfig === "object" && arguments.length === 1;
(typeof dateOrConfig === "number" || dateOrConfig instanceof Date) &&
arguments.length === 1;
var argumentIsObject =
dateOrConfig !== null &&
typeof dateOrConfig === "object" &&
arguments.length === 1;
if (!hasArguments) {
return createClock({
now: 0
now: 0,
});
}
if (argumentIsDateLike) {
return createClock({
now: dateOrConfig
now: dateOrConfig,
});
}
@ -50,13 +54,15 @@ exports.useFakeTimers = function(dateOrConfig) {
return createClock(config, globalCtx);
}
throw new TypeError("useFakeTimers expected epoch or config object. See https://github.com/sinonjs/sinon");
throw new TypeError(
"useFakeTimers expected epoch or config object. See https://github.com/sinonjs/sinon"
);
};
exports.clock = {
create: function(now) {
create: function (now) {
return FakeTimers.createClock(now);
}
},
};
var timers = {
@ -64,7 +70,7 @@ var timers = {
clearTimeout: clearTimeout,
setInterval: setInterval,
clearInterval: clearInterval,
Date: Date
Date: Date,
};
addIfDefined(timers, "setImmediate");
addIfDefined(timers, "clearImmediate");

View file

@ -81,7 +81,7 @@ function supportsColor(haveStream, streamIsTTY) {
}
if ('CI' in env) {
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
return 1;
}
@ -92,10 +92,6 @@ function supportsColor(haveStream, streamIsTTY) {
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
}
if ('GITHUB_ACTIONS' in env) {
return 1;
}
if (env.COLORTERM === 'truecolor') {
return 3;
}

View file

@ -1,6 +1,6 @@
{
"name": "supports-color",
"version": "7.1.0",
"version": "7.2.0",
"description": "Detect whether a terminal supports color",
"license": "MIT",
"repository": "chalk/supports-color",

82
node_modules/sinon/package.json generated vendored
View file

@ -1,7 +1,21 @@
{
"name": "sinon",
"description": "JavaScript test spies, stubs and mocks.",
"version": "9.0.2",
"keywords": [
"sinon",
"test",
"testing",
"unit",
"stub",
"spy",
"fake",
"time",
"clock",
"mock",
"xhr",
"assert"
],
"version": "11.1.2",
"homepage": "https://sinonjs.org/",
"author": "Christian Johansen",
"repository": {
@ -27,19 +41,19 @@
"test-esm-bundle": "node test/es2015/check-esm-bundle-is-runnable.js",
"test-docker-image": "docker-compose up",
"test-runnable-examples": "docs/release-source/release/examples/run-test.sh",
"test": "run-s test-node test-headless test-webworker test-esm",
"test": "npm run test-node && npm run test-headless && npm run test-webworker && npm run test-esm",
"check-dependencies": "dependency-check package.json --no-dev --ignore-module esm",
"build": "node ./build.js",
"build-docs": "cd docs; bundle exec jekyll build",
"serve-docs": "cd docs; bundle exec jekyll serve --incremental --verbose",
"lint": "run-p lint-js lint-markdown",
"lint-js": "eslint '**/*.{js,mjs}'",
"lint-markdown": "scripts/lint-markdown.sh",
"lint": "eslint '**/*.{js,mjs}'",
"pretest-webworker": "npm run build",
"prebuild": "rimraf pkg && npm run check-dependencies",
"postbuild": "npm run test-esm-bundle",
"prebuild-docs": "./scripts/update-compatibility.js",
"prepublishOnly": "npm run build",
"prettier": "prettier lib/**/*.js test/**/*.js",
"prettier:check": "prettier --check '**/*.{js,css,md}'",
"prettier:write": "prettier --write '**/*.{js,css,md}'",
"preversion": "./scripts/preversion.sh",
"postversion": "./scripts/postversion.sh"
},
@ -52,47 +66,41 @@
]
},
"lint-staged": {
"*.js": "eslint",
"*.mjs": "eslint --ext mjs --parser-options=sourceType:module",
"docs/**/*.md": "markdownlint"
"*.{js,css,md}": "prettier --check",
"*.js": "eslint --quiet",
"*.mjs": "eslint --quiet --ext mjs --parser-options=sourceType:module"
},
"dependencies": {
"@sinonjs/commons": "^1.7.2",
"@sinonjs/fake-timers": "^6.0.1",
"@sinonjs/formatio": "^5.0.1",
"@sinonjs/samsam": "^5.0.3",
"diff": "^4.0.2",
"nise": "^4.0.1",
"supports-color": "^7.1.0"
"@sinonjs/commons": "^1.8.3",
"@sinonjs/fake-timers": "^7.1.2",
"@sinonjs/samsam": "^6.0.2",
"diff": "^5.0.0",
"nise": "^5.1.0",
"supports-color": "^7.2.0"
},
"devDependencies": {
"@babel/core": "^7.8.3",
"@sinonjs/referee": "^4.0.0",
"@babel/core": "^7.14.3",
"@sinonjs/eslint-config": "^4.0.2",
"@sinonjs/eslint-plugin-no-prototype-methods": "^0.1.1",
"@sinonjs/referee": "^8.0.2",
"babel-plugin-istanbul": "^6.0.0",
"babelify": "^10.0.0",
"browserify": "^16.5.0",
"browserify": "^16.5.2",
"debug": "^4.3.1",
"dependency-check": "^4.1.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.9.0",
"eslint-config-sinon": "^3.0.0",
"eslint-plugin-ie11": "^1.0.0",
"eslint-plugin-local-rules": "^0.1.0",
"eslint-plugin-mocha": "^6.1.0",
"eslint-plugin-prettier": "^3.1.0",
"esm": "^3.2.25",
"husky": "^4.2.1",
"lint-staged": "^10.0.7",
"markdownlint-cli": "^0.22.0",
"mocha": "^6.2.0",
"mochify": "^6.6.0",
"npm-run-all": "^4.1.5",
"nyc": "^15.0.0",
"prettier": "^1.18.2",
"husky": "^6.0.0",
"lint-staged": "^11.0.0",
"mocha": "^8.4.0",
"mochify": "^7.1.1",
"nyc": "^15.1.0",
"prettier": "^2.3.0",
"proxyquire": "^2.1.3",
"proxyquire-universal": "^2.1.0",
"proxyquire-universal": "^3.0.1",
"proxyquireify": "^3.2.1",
"puppeteer": "^2.1.0",
"rimraf": "^3.0.0"
"puppeteer": "^9.1.1",
"rimraf": "^3.0.2",
"shelljs": "^0.8.4"
},
"files": [
"lib",

4751
node_modules/sinon/pkg/sinon-esm.js generated vendored

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

4743
node_modules/sinon/pkg/sinon.js generated vendored

File diff suppressed because one or more lines are too long