Add sinon package for mocking
This commit is contained in:
parent
43c1bea680
commit
b0af5695e6
191 changed files with 85298 additions and 0 deletions
349
node_modules/sinon/AUTHORS
generated
vendored
Normal file
349
node_modules/sinon/AUTHORS
generated
vendored
Normal file
|
|
@ -0,0 +1,349 @@
|
|||
Morgan Roderick <morgan@roderick.dk>
|
||||
Christian Johansen <christian@cjohansen.no>
|
||||
Carl-Erik Kopseng <carlerik@gmail.com>
|
||||
Maximilian Antoni <mail@maxantoni.de>
|
||||
Phred <fearphage@gmail.com>
|
||||
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>
|
||||
Tim Fischbach <mail@timfischbach.de>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
Doug Orleans <dougorleans@gmail.com>
|
||||
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>
|
||||
GCHQDeveloper500 <32099399+GCHQDeveloper500@users.noreply.github.com>
|
||||
Carolyn Stransky <carolynstransky@gmail.com>
|
||||
zcicala <zcicala@fitbit.com>
|
||||
Garrick Cheung <garrick@garrickcheung.com>
|
||||
Konrad Holowinski <konrad.holowinski@gmail.com>
|
||||
Jay Sherby <jaysherby@gmail.com>
|
||||
Gavin Huang <gravof@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>
|
||||
Florent Jaby <florent.jaby@gmail.com>
|
||||
Islam Sharabash <islam.sharabash@gmail.com>
|
||||
Scott Andrews <scothis@gmail.com>
|
||||
geries <geries.handal@videoplaza.com>
|
||||
Márton Salomváry <salomvary@gmail.com>
|
||||
August Lilleaas <august.lilleaas@gmail.com>
|
||||
Tamas Szebeni <tamas_szebeni@epam.com>
|
||||
Adhya Pranata <adhyapranata@gmail.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>
|
||||
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>
|
||||
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>
|
||||
Evan Lloyd <evan.u.lloyd@gmail.com>
|
||||
Farid Neshat <FaridN_SOAD@yahoo.com>
|
||||
Josh Graham <josh@canva.com>
|
||||
Josh Greenberger <jdgreenb@usc.edu>
|
||||
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>
|
||||
Christoph Guttandin <chrisguttandin@media-codings.com>
|
||||
Victor Costan <costan@gmail.com>
|
||||
Gyandeep Singh <gyandeeps@gmail.com>
|
||||
Zach Bloomquist <github@chary.us>
|
||||
Marcus Hüsgen <marcus.huesgen@lusini.com>
|
||||
Henry Tung <henryptung@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>
|
||||
Michael Herman <hermanmu@gmail.com>
|
||||
David Mott <dpmott@sep.com>
|
||||
vitalets <vitalets@yandex-team.ru>
|
||||
Jakob Jónasson <jakob.jonasson@gmail.com>
|
||||
yoshimura-toshihide <toshihide0105yoshimura@gmail.com>
|
||||
James Barwell <jb@jamesbarwell.co.uk>
|
||||
Revath S Kumar <revathskumar@users.noreply.github.com>
|
||||
Rich Hodgkins <rhodgkins@gmail.com>
|
||||
Rodion Vynnychenko <roddiku@gmail.com>
|
||||
Rodrigo García <yo@rodrigogarcia.me>
|
||||
Roland Warmerdam <roland@segment.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>
|
||||
Scott Rudiger <scottrudiger@gmail.com>
|
||||
Sergio Cinos <scinos@atlassian.com>
|
||||
Shaine Hatch <shainehatch@overstock.com>
|
||||
Shawn Krisman <skrisman@nodelings>
|
||||
Shinnosuke Watanabe <snnskwtnb@gmail.com>
|
||||
Simone Fonda <fonda@netseven.it>
|
||||
Sinan Bolel <1915925+sbolel@users.noreply.github.com>
|
||||
Stefan Weil <sw@weilnetz.de>
|
||||
Stefan du Fresne <stefan@sdufresne.info>
|
||||
StefanSchoof <Stefan.Schoof@direkt-gruppe.de>
|
||||
Stephen Burrows <stephen.r.burrows@gmail.com>
|
||||
Steven Lu <stevenlu443@gmail.com>
|
||||
Sven Fuchs <svenfuchs@artweb-design.de>
|
||||
Søren Enemærke <soren.enemaerke@gmail.com>
|
||||
T1st3 <contact@tiste.org>
|
||||
TEHEK Firefox <tehek@tehek.net>
|
||||
Tek Nynja <github@teknynja.com>
|
||||
The Gitter Badger <badger@gitter.im>
|
||||
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>
|
||||
Valentin Agachi <github-com@agachi.name>
|
||||
Volkan Ozcelik <volkan.ozcelik@jivesoftware.com>
|
||||
Vynce Montgomery <vynce.montgomery@gmail.com>
|
||||
White, Ben <ben.white@jpmchase.com>
|
||||
Whymarrh Whitby <whymarrh.whitby@gmail.com>
|
||||
Will Butler <will@butlerhq.com>
|
||||
William Meleyal <w.meleyal@wollzelle.com>
|
||||
Yury Fedorov <10244414+orlangure@users.noreply.github.com>
|
||||
Zakir <zak.saifi7@gmail.com>
|
||||
Zhengang Li <huttli@users.noreply.github.com>
|
||||
andrew <andrew.derozario@online-pajak.com>
|
||||
charlierudolph <charles.w.rudolph@gmail.com>
|
||||
clint <clint@wealthfront.com>
|
||||
ehmicky <ehmicky@gmail.com>
|
||||
goligo <ich@malte.de>
|
||||
hannes <github@htmlcss.de>
|
||||
hashchange <heim@zeilenwechsel.de>
|
||||
ichthala <alice.mottola@gmail.com>
|
||||
jamestalmage <james.talmage@jrtechnical.com>
|
||||
jshayes <justin@yolk.ai>
|
||||
kbackowski <kbackowski@gmail.com>
|
||||
mareq <mareq@balint.eu>
|
||||
mbehboodian <morteza6909@gmail.com>
|
||||
ngryman <ngryman@gmail.com>
|
||||
niftylettuce <niftylettuce@gmail.com>
|
||||
simonzack <simonzack@gmail.com>
|
||||
stevesouth <stephen.south@caplin.com>
|
||||
stoically <stoically@protonmail.com>
|
||||
thefourtheye <thefourtheye@users.noreply.github.com>
|
||||
till <till@php.net>
|
||||
vsa <vsa@users.noreply.github.com>
|
||||
wwalser <waw325@gmail.com>
|
||||
Xiao Ma <x@medium.com>
|
||||
AJ Ortega <ajo@google.com>
|
||||
AdilKhn <AdilKhn@users.noreply.github.com>
|
||||
Aditya Vohra <avohra@yelp.com>
|
||||
Adrian Phinney <adrian.phinney@bellaliant.net>
|
||||
Adrian Schmidt <adrian.schmidt@lime.tech>
|
||||
Akira Matsuda <ronnie@dio.jp>
|
||||
Aleksey Bobyr <aleksey.bobyr@beetroot.se>
|
||||
Alex Ghiculescu <alex@tanda.co>
|
||||
Alex Kessaris <alex@artsy.ca>
|
||||
Alex Tran <alex@Alexs-MacBook-Pro-2.local>
|
||||
Alexander Aivars <alex@aivars.se>
|
||||
Alexey Kucherenko <alexei.kucherenko@gmail.com>
|
||||
Alexsey <agat00@gmail.com>
|
||||
Alfonso Boza <alfonso@cloud.com>
|
||||
Ali Shakiba <ali@shakiba.me>
|
||||
Andrew Fong <afong@slack-corp.com>
|
||||
Andrew Leschinsky <andrew@leschinsky.com>
|
||||
Andrew Shirley <andrew@als-bi.com>
|
||||
Antonio D'Ettole <antonio@brandwatch.com>
|
||||
Auclair Emmanuel <auclair.emmanuel.prestataire@sfr.com>
|
||||
Aziz Punjani <aziz.punjani@gmail.com>
|
||||
Ben Brostoff <ben.brostoff@gmail.com>
|
||||
Ben Lertlumprasertkul <Ben.Lertlumprasertkul@ig.com>
|
||||
Bing Ren <bingtimren@gmail.com>
|
||||
Blaine Bublitz <blaine@iceddev.com>
|
||||
Blake Embrey <hello@blakeembrey.com>
|
||||
Blake Israel <blake.israel@gatech.edu>
|
||||
Boshen Chen <boshenc@gmail.com>
|
||||
Brandon Au <brandon.au@drexel.edu>
|
||||
Brett Zamir <brettz9@yahoo.com>
|
||||
Brian Bleakley <brianbleakley@gmail.com>
|
||||
Brian M Hunt <brianmhunt@gmail.com>
|
||||
Burak Yiğit Kaya <ben@byk.im>
|
||||
C. T. Lin <chentsulin@gmail.com>
|
||||
Dan Bird <danielsbird@gmail.com>
|
||||
Dan Peddle <dazld@users.noreply.github.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>
|
||||
Eli White <github@eli-white.com>
|
||||
Eric Stobbart <Eric_Stobbart@comcast.com>
|
||||
Eric Wendelin <ewendelin@twitter.com>
|
||||
Ericat <erica.salvaneschi@gmail.com>
|
||||
Feiyang1 <plane1113@gmail.com>
|
||||
Felipe Carasso <felipe@carassonet.org>
|
||||
Franck Romano <fra@octo.com>
|
||||
GProst <gprostmail@gmail.com>
|
||||
Gabe Jackson <gj@mail.co.de>
|
||||
Gavin Boulton <gavin.boulton@digital.cabinet-office.gov.uk>
|
||||
Gerhard Stöbich <18708370+Flarna@users.noreply.github.com>
|
||||
Gilad Peleg <giladp007@gmail.com>
|
||||
Giorgos Giannoutsos <contact@nuc.gr>
|
||||
Gord Tanner <gord@tinyhippos.com>
|
||||
Gordon L. Hempton <ghempton@gmail.com>
|
||||
Gvozd <gvozdev.viktor@gmail.com>
|
||||
Harry Wolff <hswolff@gmail.com>
|
||||
HugoMuller <hmu@debian-hmu-dev>
|
||||
Ian Lewis <IanMLewis@gmail.com>
|
||||
Ian Thomas <ian@ian-thomas.net>
|
||||
Irving <Irvingb232@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>
|
||||
James M. Greene <james.m.greene@gmail.com>
|
||||
Jan Kopriva <jan.kopriva@gooddata.com>
|
||||
Jan Suchý <jan.sandokan@gmail.com>
|
||||
Jani Hartikainen <jani.hartikainen@gmail.com>
|
||||
Jason Anderson <diurnalist@gmail.com>
|
||||
Joakim Wimmerstedt <joakim.wimmerstedt@gmail.com>
|
||||
Jochen Preusche <iilei@users.noreply.github.com>
|
||||
Johann Hubert Sonntagbauer <johann.sonntagbauer@gmx.at>
|
||||
John Bernardo <jbernardo@linkedin.com>
|
||||
Jonathan Roitgrund <jroitgrund@gmail.com>
|
||||
Jordan Harband <ljharb@gmail.com>
|
||||
Jordan Hawker <hawker.jordan@gmail.com>
|
||||
Joseph Evans <evonsdesigns@gmail.com>
|
||||
Joseph Spens <joseph@workmarket.com>
|
||||
Josh Goldberg <josh@fullscreenmario.com>
|
||||
JoshuaCWebDeveloper <coosriverjoshua1@outlook.com>
|
||||
Juntao Zeng <31234156+juntaozeng@users.noreply.github.com>
|
||||
Kalisa Falzone <KalisaFalzone@users.noreply.github.com>
|
||||
Katrina Theodosopoulos <katrinaelaine6@gmail.com>
|
||||
Keith Rogers <git@keithrogers.eu>
|
||||
Kelly Selden <kellyselden@gmail.com>
|
||||
Kenneth Williams <scriptdaemon@gmail.com>
|
||||
Kev <lineus@gmail.com>
|
||||
Kevin Bosman <kevinbosman@users.noreply.github.com>
|
||||
Kevin Ennis <kennis84@gmail.com>
|
||||
Kevin Turner <kevin@decipherinc.com>
|
||||
Kim Joar Bekkelund <kjbekkelund@gmail.com>
|
||||
Kris Kowal <kris.kowal@cixar.com>
|
||||
Kristian <krisham87@hotmail.com>
|
||||
Kuba Orlik <kontakt@jakub-orlik.pl>
|
||||
Kurt Ruppel <me@kurtruppel.com>
|
||||
Lars Thorup <lars@zealake.com>
|
||||
LboAnn <extend1994@gmail.com>
|
||||
LostArchives <valentin.mullet@gmail.com>
|
||||
Lucas Vieira <vieiralucas@users.noreply.github.com>
|
||||
Luchs <Luchs@euirc.eu>
|
||||
Maarten Tromp <maarten@nouncy.com>
|
||||
Marco Ramirez <marco-ramirez@bankofamerica.com>
|
||||
Marcos Vanetta <marcos_vanetta@condenast.com>
|
||||
Mario Pareja <mpareja@360incentives.com>
|
||||
Mark Banner <standard8@mozilla.com>
|
||||
Mark Gibson <mgibson@adaptavist.com>
|
||||
Mark Stickley <markstickley@users.noreply.github.com>
|
||||
Martin Brochhaus <mbrochh@gmail.com>
|
||||
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>
|
||||
Michael David Kuckuk <mdk@kuckuk.com>
|
||||
Michael Jackson <mjijackson@gmail.com>
|
||||
Michael Paulukonis <xraysmalevich@gmail.com>
|
||||
Michał Perłakowski <michal@perlakowski.pl>
|
||||
Mike Eve <ungrim97@gmail.com>
|
||||
Mike Flanigan <mkflan@gmail.com>
|
||||
Mikolaj Banasik <d1sover@gmail.com>
|
||||
MouseZero <rm@mousezero.com>
|
||||
Mustafa Sak <mustafa.sak@1und1.de>
|
||||
Nelson Silva <nelson.silva@inevo.pt>
|
||||
Nicholas Stephan <nicholas.stephan@gmail.com>
|
||||
Nicu Micleușanu <micnic90@gmail.com>
|
||||
Nikita Litvin <deltaidea@derpy.ru>
|
||||
Niklas Andreasson <eaglus_@hotmail.com>
|
||||
Noam Paz <noam.paz@gmail.com>
|
||||
Olmo Maldonado <olmo.maldonado@gmail.com>
|
||||
Paul Barry <paul@Pauls-Air.fios-router.home>
|
||||
Pelle Wessman <pelle@kodfabrik.se>
|
||||
Petar Dochev <dotchev@gmail.com>
|
||||
Peter Grainger <peter@grainger.xyz>
|
||||
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>
|
||||
1577
node_modules/sinon/CHANGELOG.md
generated
vendored
Normal file
1577
node_modules/sinon/CHANGELOG.md
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
127
node_modules/sinon/CONTRIBUTING.md
generated
vendored
Normal file
127
node_modules/sinon/CONTRIBUTING.md
generated
vendored
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
# Contributing to Sinon.JS
|
||||
|
||||
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
|
||||
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.
|
||||
|
||||
## Contributor Code of Conduct
|
||||
|
||||
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
|
||||
|
||||
## Reporting an issue
|
||||
|
||||
To save everyone time and make it much more likely for your issue to be understood, worked on and resolved quickly, it would help if you're mindful of [How to Report Bugs Effectively](http://www.chiark.greenend.org.uk/~sgtatham/bugs.html) when pressing the "Submit new issue" button.
|
||||
|
||||
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
|
||||
|
||||
See [our issue template](https://github.com/sinonjs/sinon/blob/master/.github/) for all details.
|
||||
|
||||
## Contributing to the code base
|
||||
|
||||
Pick [an issue](https://github.com/sinonjs/sinon/issues) to fix, or pitch
|
||||
new features. To avoid wasting your time, please ask for feedback on feature
|
||||
suggestions with [an issue](https://github.com/sinonjs/sinon/issues/new).
|
||||
|
||||
Make sure you have read [GitHub's guide on forking](https://guides.github.com/activities/forking/). It explains the general contribution process and key concepts.
|
||||
|
||||
### Making a pull request
|
||||
|
||||
Please try to [write great commit messages](http://chris.beams.io/posts/git-commit/).
|
||||
|
||||
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
|
||||
|
||||
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/).
|
||||
|
||||
Also, before making your pull request, consider if your commits make sense on their own (and potentially should be multiple pull requests) or if they can be squashed down to one commit (with a great message). There are no hard and fast rules about this, but being mindful of your readers greatly help you author good commits.
|
||||
|
||||
### Use EditorConfig
|
||||
|
||||
To save everyone some time, please use [EditorConfig](http://editorconfig.org), so your editor helps make
|
||||
sure we all use the same encoding, indentation, line endings, etc.
|
||||
|
||||
### Installation
|
||||
|
||||
The Sinon.JS developer environment requires Node/NPM. Please make sure you have
|
||||
Node installed, and install Sinon's dependencies:
|
||||
|
||||
$ npm install
|
||||
|
||||
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)
|
||||
|
||||
### Linting and style
|
||||
|
||||
Sinon.JS uses [ESLint](http://eslint.org) to keep the codebase free of lint, and uses [Prettier](https://prettier.io) to keep consistent style.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
You can run the linter locally:
|
||||
|
||||
```
|
||||
$ npm run lint
|
||||
```
|
||||
|
||||
You can fix a lot lint and style violations automatically:
|
||||
|
||||
```
|
||||
$ npm run lint -- --fix
|
||||
```
|
||||
|
||||
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
|
||||
|
||||
Following command runs unit tests in PhantomJS, Node and WebWorker
|
||||
|
||||
$ npm test
|
||||
|
||||
##### Testing in development
|
||||
|
||||
Sinon.JS uses [Mocha](https://mochajs.org/), please read those docs if you're unfamiliar with it.
|
||||
|
||||
If you're doing more than a one line edit, you'll want to have finer control and less restarting of the Mocha
|
||||
|
||||
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
|
||||
|
||||
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.
|
||||
|
||||
### Compiling a built version
|
||||
|
||||
Build requires Node. Under the hood [Browserify](http://browserify.org/) is used.
|
||||
|
||||
To build run
|
||||
|
||||
$ node build.js
|
||||
|
||||
|
||||
27
node_modules/sinon/LICENSE
generated
vendored
Normal file
27
node_modules/sinon/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
(The BSD License)
|
||||
|
||||
Copyright (c) 2010-2017, Christian Johansen, christian@cjohansen.no
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of Christian Johansen nor the names of his contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
149
node_modules/sinon/README.md
generated
vendored
Normal file
149
node_modules/sinon/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
<h1 align=center>
|
||||
<a href="https://sinonjs.org" title="Sinon.JS">
|
||||
<img alt="Sinon.JS" src="https://sinonjs.org/assets/images/logo.png">
|
||||
</a>
|
||||
<br>
|
||||
Sinon.JS
|
||||
</h1>
|
||||
|
||||
<p align=center>
|
||||
Standalone and test framework agnostic JavaScript test spies, stubs and mocks (pronounced "sigh-non", named after <a href="https://en.wikipedia.org/wiki/Sinon">Sinon, the warrior</a>).
|
||||
</p>
|
||||
|
||||
<p align=center>
|
||||
<a href="https://www.npmjs.com/package/sinon"><img src="https://img.shields.io/npm/v/sinon.svg?style=flat" alt="npm version"></a>
|
||||
<a href="https://gitter.im/sinonjs/sinon?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge"><img src="https://badges.gitter.im/Join%20Chat.svg" alt="Join the chat at https://gitter.im/sinonjs/sinon"></a>
|
||||
<a href="http://travis-ci.org/sinonjs/sinon"><img src="https://secure.travis-ci.org/sinonjs/sinon.svg?branch=master" alt="Build status"></a>
|
||||
<a href="https://saucelabs.com/u/sinonjs"><img src="https://saucelabs.com/buildstatus/sinonjs" alt="Sauce Test Status"/></a>
|
||||
<a href="https://codecov.io/gh/sinonjs/sinon"><img src="https://codecov.io/gh/sinonjs/sinon/branch/master/graph/badge.svg" alt="Codecov status"></a>
|
||||
<a href="#backers"><img src="https://opencollective.com/sinon/backers/badge.svg" alt="OpenCollective"></a>
|
||||
<a href="#sponsors"><img src="https://opencollective.com/sinon/sponsors/badge.svg" alt="OpenCollective"></a>
|
||||
<a href="https://www.npmjs.com/package/sinon" target="_blank"><img src="https://img.shields.io/npm/dm/sinon.svg" alt="npm downloads per month"></a>
|
||||
<a href="https://cdnjs.com/libraries/sinon.js" target="_blank"><img src="https://img.shields.io/cdnjs/v/sinon.js.svg" alt="CDNJS version"></a>
|
||||
<a href="CODE_OF_CONDUCT.md"><img src="https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg" alt="Contributor Covenant" /></a>
|
||||
</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>
|
||||
</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)
|
||||
|
||||
## Installation
|
||||
|
||||
via [npm](https://github.com/npm/npm)
|
||||
|
||||
$ npm install sinon
|
||||
|
||||
or via sinon's browser builds available for download on the [homepage](https://sinonjs.org/releases/). There are also [npm based CDNs](https://sinonjs.org/releases#npm-cdns) one can use.
|
||||
|
||||
## Usage
|
||||
|
||||
See the [sinon project homepage](https://sinonjs.org/) for documentation on usage.
|
||||
|
||||
If you have questions that are not covered by the documentation, you can [check out the `sinon` tag on Stack Overflow](https://stackoverflow.com/questions/tagged/sinon) or drop by <a href="irc://irc.freenode.net:6667/sinon.js">#sinon.js on irc.freenode.net:6667</a>.
|
||||
|
||||
You can also search through the [Sinon.JS mailing list archives](http://groups.google.com/group/sinonjs).
|
||||
|
||||
## 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
|
||||
|
||||
## Contribute?
|
||||
|
||||
See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how you can contribute to Sinon.JS
|
||||
|
||||
## Backers
|
||||
|
||||
Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/sinon#backer)]
|
||||
|
||||
<a href="https://opencollective.com/sinon/backer/0/website" target="_blank"><img src="https://opencollective.com/sinon/backer/0/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/1/website" target="_blank"><img src="https://opencollective.com/sinon/backer/1/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/2/website" target="_blank"><img src="https://opencollective.com/sinon/backer/2/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/3/website" target="_blank"><img src="https://opencollective.com/sinon/backer/3/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/4/website" target="_blank"><img src="https://opencollective.com/sinon/backer/4/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/5/website" target="_blank"><img src="https://opencollective.com/sinon/backer/5/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/6/website" target="_blank"><img src="https://opencollective.com/sinon/backer/6/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/7/website" target="_blank"><img src="https://opencollective.com/sinon/backer/7/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/8/website" target="_blank"><img src="https://opencollective.com/sinon/backer/8/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/9/website" target="_blank"><img src="https://opencollective.com/sinon/backer/9/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/10/website" target="_blank"><img src="https://opencollective.com/sinon/backer/10/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/11/website" target="_blank"><img src="https://opencollective.com/sinon/backer/11/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/12/website" target="_blank"><img src="https://opencollective.com/sinon/backer/12/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/13/website" target="_blank"><img src="https://opencollective.com/sinon/backer/13/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/14/website" target="_blank"><img src="https://opencollective.com/sinon/backer/14/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/15/website" target="_blank"><img src="https://opencollective.com/sinon/backer/15/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/16/website" target="_blank"><img src="https://opencollective.com/sinon/backer/16/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/17/website" target="_blank"><img src="https://opencollective.com/sinon/backer/17/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/18/website" target="_blank"><img src="https://opencollective.com/sinon/backer/18/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/19/website" target="_blank"><img src="https://opencollective.com/sinon/backer/19/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/20/website" target="_blank"><img src="https://opencollective.com/sinon/backer/20/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/21/website" target="_blank"><img src="https://opencollective.com/sinon/backer/21/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/22/website" target="_blank"><img src="https://opencollective.com/sinon/backer/22/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/23/website" target="_blank"><img src="https://opencollective.com/sinon/backer/23/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/24/website" target="_blank"><img src="https://opencollective.com/sinon/backer/24/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/25/website" target="_blank"><img src="https://opencollective.com/sinon/backer/25/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/26/website" target="_blank"><img src="https://opencollective.com/sinon/backer/26/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/27/website" target="_blank"><img src="https://opencollective.com/sinon/backer/27/avatar.svg"></a>
|
||||
<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)]
|
||||
|
||||
<a href="https://opencollective.com/sinon/sponsor/0/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/0/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/1/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/1/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/2/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/2/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/3/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/3/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/4/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/4/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/5/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/5/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/6/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/6/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/7/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/7/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/8/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/8/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/9/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/9/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/10/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/10/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/11/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/11/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/12/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/12/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/13/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/13/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/14/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/14/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/15/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/15/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/16/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/16/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/17/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/17/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/18/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/18/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/19/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/19/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/20/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/20/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/21/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/21/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/22/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/22/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/23/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/23/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/24/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/24/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/25/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/25/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/26/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/26/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/27/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/27/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/28/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/28/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/29/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/29/avatar.svg"></a>
|
||||
|
||||
## Licence
|
||||
|
||||
Sinon.js was released under [BSD-3](LICENSE)
|
||||
3
node_modules/sinon/lib/sinon-esm.js
generated
vendored
Normal file
3
node_modules/sinon/lib/sinon-esm.js
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
"use strict";
|
||||
// eslint-disable-next-line no-undef
|
||||
sinon = require("./sinon");
|
||||
45
node_modules/sinon/lib/sinon.js
generated
vendored
Normal file
45
node_modules/sinon/lib/sinon.js
generated
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
"use strict";
|
||||
|
||||
var behavior = require("./sinon/behavior");
|
||||
var createSandbox = require("./sinon/create-sandbox");
|
||||
var extend = require("./sinon/util/core/extend");
|
||||
var fakeTimers = require("./sinon/util/fake-timers");
|
||||
var format = require("./sinon/util/core/format");
|
||||
var nise = require("nise");
|
||||
var Sandbox = require("./sinon/sandbox");
|
||||
var stub = require("./sinon/stub");
|
||||
|
||||
var apiMethods = {
|
||||
createSandbox: createSandbox,
|
||||
assert: require("./sinon/assert"),
|
||||
match: require("@sinonjs/samsam").createMatcher,
|
||||
restoreObject: require("./sinon/restore-object"),
|
||||
|
||||
expectation: require("./sinon/mock-expectation"),
|
||||
defaultConfig: require("./sinon/util/core/default-config"),
|
||||
|
||||
setFormatter: format.setFormatter,
|
||||
|
||||
// fake timers
|
||||
timers: fakeTimers.timers,
|
||||
|
||||
// fake XHR
|
||||
xhr: nise.fakeXhr.xhr,
|
||||
FakeXMLHttpRequest: nise.fakeXhr.FakeXMLHttpRequest,
|
||||
|
||||
// fake server
|
||||
fakeServer: nise.fakeServer,
|
||||
fakeServerWithClock: nise.fakeServerWithClock,
|
||||
createFakeServer: nise.fakeServer.create.bind(nise.fakeServer),
|
||||
createFakeServerWithClock: nise.fakeServerWithClock.create.bind(nise.fakeServerWithClock),
|
||||
|
||||
addBehavior: function(name, fn) {
|
||||
behavior.addBehavior(stub, name, fn);
|
||||
}
|
||||
};
|
||||
|
||||
var sandbox = new Sandbox();
|
||||
|
||||
var api = extend(sandbox, apiMethods);
|
||||
|
||||
module.exports = api;
|
||||
216
node_modules/sinon/lib/sinon/assert.js
generated
vendored
Normal file
216
node_modules/sinon/lib/sinon/assert.js
generated
vendored
Normal file
|
|
@ -0,0 +1,216 @@
|
|||
"use strict";
|
||||
|
||||
var arrayProto = require("@sinonjs/commons").prototypes.array;
|
||||
var calledInOrder = require("@sinonjs/commons").calledInOrder;
|
||||
var createMatcher = require("@sinonjs/samsam").createMatcher;
|
||||
var orderByFirstCall = require("@sinonjs/commons").orderByFirstCall;
|
||||
var timesInWords = require("./util/core/times-in-words");
|
||||
var format = require("./util/core/format");
|
||||
var stringSlice = require("@sinonjs/commons").prototypes.string.slice;
|
||||
var globalObject = require("@sinonjs/commons").global;
|
||||
|
||||
var arraySlice = arrayProto.slice;
|
||||
var concat = arrayProto.concat;
|
||||
var forEach = arrayProto.forEach;
|
||||
var join = arrayProto.join;
|
||||
var splice = arrayProto.splice;
|
||||
|
||||
var assert;
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
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("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");
|
||||
|
||||
module.exports = assert;
|
||||
250
node_modules/sinon/lib/sinon/behavior.js
generated
vendored
Normal file
250
node_modules/sinon/lib/sinon/behavior.js
generated
vendored
Normal file
|
|
@ -0,0 +1,250 @@
|
|||
"use strict";
|
||||
|
||||
var arrayProto = require("@sinonjs/commons").prototypes.array;
|
||||
var extend = require("./util/core/extend");
|
||||
var functionName = require("@sinonjs/commons").functionName;
|
||||
var nextTick = require("./util/core/next-tick");
|
||||
var valueToString = require("@sinonjs/commons").valueToString;
|
||||
var exportAsyncBehaviors = require("./util/core/export-async-behaviors");
|
||||
|
||||
var concat = arrayProto.concat;
|
||||
var join = arrayProto.join;
|
||||
var reverse = arrayProto.reverse;
|
||||
var slice = arrayProto.slice;
|
||||
|
||||
var useLeftMostCallback = -1;
|
||||
var useRightMostCallback = -2;
|
||||
|
||||
function getCallback(behavior, args) {
|
||||
var callArgAt = behavior.callArgAt;
|
||||
|
||||
if (callArgAt >= 0) {
|
||||
return args[callArgAt];
|
||||
}
|
||||
|
||||
var argumentList;
|
||||
|
||||
if (callArgAt === useLeftMostCallback) {
|
||||
argumentList = args;
|
||||
}
|
||||
|
||||
if (callArgAt === useRightMostCallback) {
|
||||
argumentList = reverse(slice(args));
|
||||
}
|
||||
|
||||
var callArgProp = behavior.callArgProp;
|
||||
|
||||
for (var i = 0, l = argumentList.length; i < l; ++i) {
|
||||
if (!callArgProp && typeof argumentList[i] === "function") {
|
||||
return argumentList[i];
|
||||
}
|
||||
|
||||
if (callArgProp && argumentList[i] && typeof argumentList[i][callArgProp] === "function") {
|
||||
return argumentList[i][callArgProp];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function getCallbackError(behavior, func, args) {
|
||||
if (behavior.callArgAt < 0) {
|
||||
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.";
|
||||
} else {
|
||||
msg = functionName(behavior.stub) + " expected to yield, but no callback was passed.";
|
||||
}
|
||||
|
||||
if (args.length > 0) {
|
||||
msg += " Received [" + join(args, ", ") + "]";
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
return "argument at index " + behavior.callArgAt + " is not a function: " + func;
|
||||
}
|
||||
|
||||
function ensureArgs(name, behavior, args) {
|
||||
// map function name to internal property
|
||||
// callsArg => callArgAt
|
||||
var property = name.replace(/sArg/, "ArgAt");
|
||||
var index = behavior[property];
|
||||
|
||||
if (index >= args.length) {
|
||||
throw new TypeError(
|
||||
name + " failed: " + (index + 1) + " arguments required but only " + args.length + " present"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function callCallback(behavior, args) {
|
||||
if (typeof behavior.callArgAt === "number") {
|
||||
ensureArgs("callsArg", behavior, args);
|
||||
var func = getCallback(behavior, args);
|
||||
|
||||
if (typeof func !== "function") {
|
||||
throw new TypeError(getCallbackError(behavior, func, args));
|
||||
}
|
||||
|
||||
if (behavior.callbackAsync) {
|
||||
nextTick(function() {
|
||||
func.apply(behavior.callbackContext, behavior.callbackArguments);
|
||||
});
|
||||
} else {
|
||||
return func.apply(behavior.callbackContext, behavior.callbackArguments);
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var proto = {
|
||||
create: function create(stub) {
|
||||
var behavior = extend({}, proto);
|
||||
delete behavior.create;
|
||||
delete behavior.addBehavior;
|
||||
delete behavior.createBehavior;
|
||||
behavior.stub = stub;
|
||||
|
||||
if (stub.defaultBehavior && stub.defaultBehavior.promiseLibrary) {
|
||||
behavior.promiseLibrary = stub.defaultBehavior.promiseLibrary;
|
||||
}
|
||||
|
||||
return behavior;
|
||||
},
|
||||
|
||||
isPresent: function isPresent() {
|
||||
return (
|
||||
typeof this.callArgAt === "number" ||
|
||||
this.exception ||
|
||||
this.exceptionCreator ||
|
||||
typeof this.returnArgAt === "number" ||
|
||||
this.returnThis ||
|
||||
typeof this.resolveArgAt === "number" ||
|
||||
this.resolveThis ||
|
||||
typeof this.throwArgAt === "number" ||
|
||||
this.fakeFn ||
|
||||
this.returnValueDefined
|
||||
);
|
||||
},
|
||||
|
||||
/*eslint complexity: ["error", 20]*/
|
||||
invoke: function invoke(context, args) {
|
||||
/*
|
||||
* callCallback (conditionally) calls ensureArgs
|
||||
*
|
||||
* Note: callCallback intentionally happens before
|
||||
* everything else and cannot be moved lower
|
||||
*/
|
||||
var returnValue = callCallback(this, args);
|
||||
|
||||
if (this.exception) {
|
||||
throw this.exception;
|
||||
} else if (this.exceptionCreator) {
|
||||
this.exception = this.exceptionCreator();
|
||||
this.exceptionCreator = undefined;
|
||||
throw this.exception;
|
||||
} else if (typeof this.returnArgAt === "number") {
|
||||
ensureArgs("returnsArg", this, args);
|
||||
return args[this.returnArgAt];
|
||||
} else if (this.returnThis) {
|
||||
return context;
|
||||
} else if (typeof this.throwArgAt === "number") {
|
||||
ensureArgs("throwsArg", this, args);
|
||||
throw args[this.throwArgAt];
|
||||
} else if (this.fakeFn) {
|
||||
return this.fakeFn.apply(context, args);
|
||||
} else if (typeof this.resolveArgAt === "number") {
|
||||
ensureArgs("resolvesArg", this, args);
|
||||
return (this.promiseLibrary || Promise).resolve(args[this.resolveArgAt]);
|
||||
} else if (this.resolveThis) {
|
||||
return (this.promiseLibrary || Promise).resolve(context);
|
||||
} else if (this.resolve) {
|
||||
return (this.promiseLibrary || Promise).resolve(this.returnValue);
|
||||
} else if (this.reject) {
|
||||
return (this.promiseLibrary || Promise).reject(this.returnValue);
|
||||
} else if (this.callsThrough) {
|
||||
var wrappedMethod = this.effectiveWrappedMethod();
|
||||
|
||||
return wrappedMethod.apply(context, args);
|
||||
} else if (this.callsThroughWithNew) {
|
||||
// Get the original method (assumed to be a constructor in this case)
|
||||
var WrappedClass = this.effectiveWrappedMethod();
|
||||
// Turn the arguments object into a normal array
|
||||
var argsArray = slice(args);
|
||||
// Call the constructor
|
||||
var F = WrappedClass.bind.apply(WrappedClass, concat([null], argsArray));
|
||||
return new F();
|
||||
} else if (typeof this.returnValue !== "undefined") {
|
||||
return this.returnValue;
|
||||
} else if (typeof this.callArgAt === "number") {
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
return this.returnValue;
|
||||
},
|
||||
|
||||
effectiveWrappedMethod: function effectiveWrappedMethod() {
|
||||
for (var stubb = this.stub; stubb; stubb = stubb.parent) {
|
||||
if (stubb.wrappedMethod) {
|
||||
return stubb.wrappedMethod;
|
||||
}
|
||||
}
|
||||
throw new Error("Unable to find wrapped method");
|
||||
},
|
||||
|
||||
onCall: function onCall(index) {
|
||||
return this.stub.onCall(index);
|
||||
},
|
||||
|
||||
onFirstCall: function onFirstCall() {
|
||||
return this.stub.onFirstCall();
|
||||
},
|
||||
|
||||
onSecondCall: function onSecondCall() {
|
||||
return this.stub.onSecondCall();
|
||||
},
|
||||
|
||||
onThirdCall: function onThirdCall() {
|
||||
return this.stub.onThirdCall();
|
||||
},
|
||||
|
||||
withArgs: function withArgs(/* arguments */) {
|
||||
throw new Error(
|
||||
'Defining a stub by invoking "stub.onCall(...).withArgs(...)" ' +
|
||||
'is not supported. Use "stub.withArgs(...).onCall(...)" ' +
|
||||
"to define sequential behavior for calls with certain arguments."
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
function createBehavior(behaviorMethod) {
|
||||
return function() {
|
||||
this.defaultBehavior = this.defaultBehavior || proto.create(this);
|
||||
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
|
||||
return this;
|
||||
};
|
||||
}
|
||||
|
||||
function addBehavior(stub, name, fn) {
|
||||
proto[name] = function() {
|
||||
fn.apply(this, concat([this], slice(arguments)));
|
||||
return this.stub || this;
|
||||
};
|
||||
|
||||
stub[name] = createBehavior(name);
|
||||
}
|
||||
|
||||
proto.addBehavior = addBehavior;
|
||||
proto.createBehavior = createBehavior;
|
||||
|
||||
var asyncBehaviors = exportAsyncBehaviors(proto);
|
||||
|
||||
module.exports = extend.nonEnum({}, proto, asyncBehaviors);
|
||||
9
node_modules/sinon/lib/sinon/blob.js
generated
vendored
Normal file
9
node_modules/sinon/lib/sinon/blob.js
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
"use strict";
|
||||
|
||||
exports.isSupported = (function() {
|
||||
try {
|
||||
return Boolean(new Blob());
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
23
node_modules/sinon/lib/sinon/collect-own-methods.js
generated
vendored
Normal file
23
node_modules/sinon/lib/sinon/collect-own-methods.js
generated
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
"use strict";
|
||||
|
||||
var walk = require("./util/core/walk");
|
||||
var getPropertyDescriptor = require("./util/core/get-property-descriptor");
|
||||
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)) {
|
||||
push(methods, object[prop]);
|
||||
}
|
||||
}
|
||||
|
||||
// This function returns an array of all the own methods on the passed object
|
||||
function collectOwnMethods(object) {
|
||||
var methods = [];
|
||||
|
||||
walk(object, collectMethod.bind(null, methods, object));
|
||||
|
||||
return methods;
|
||||
}
|
||||
|
||||
module.exports = collectOwnMethods;
|
||||
31
node_modules/sinon/lib/sinon/color.js
generated
vendored
Normal file
31
node_modules/sinon/lib/sinon/color.js
generated
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
"use strict";
|
||||
|
||||
var supportsColor = require("supports-color");
|
||||
|
||||
function colorize(str, color) {
|
||||
if (supportsColor.stdout === false) {
|
||||
return str;
|
||||
}
|
||||
|
||||
return "\x1b[" + color + "m" + str + "\x1b[0m";
|
||||
}
|
||||
|
||||
exports.red = function(str) {
|
||||
return colorize(str, 31);
|
||||
};
|
||||
|
||||
exports.green = function(str) {
|
||||
return colorize(str, 32);
|
||||
};
|
||||
|
||||
exports.cyan = function(str) {
|
||||
return colorize(str, 96);
|
||||
};
|
||||
|
||||
exports.white = function(str) {
|
||||
return colorize(str, 39);
|
||||
};
|
||||
|
||||
exports.bold = function(str) {
|
||||
return colorize(str, 1);
|
||||
};
|
||||
67
node_modules/sinon/lib/sinon/create-sandbox.js
generated
vendored
Normal file
67
node_modules/sinon/lib/sinon/create-sandbox.js
generated
vendored
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
"use strict";
|
||||
|
||||
var arrayProto = require("@sinonjs/commons").prototypes.array;
|
||||
var Sandbox = require("./sandbox");
|
||||
|
||||
var forEach = arrayProto.forEach;
|
||||
var push = arrayProto.push;
|
||||
|
||||
function prepareSandboxFromConfig(config) {
|
||||
var sandbox = new Sandbox();
|
||||
|
||||
if (config.useFakeServer) {
|
||||
if (typeof config.useFakeServer === "object") {
|
||||
sandbox.serverPrototype = config.useFakeServer;
|
||||
}
|
||||
|
||||
sandbox.useFakeServer();
|
||||
}
|
||||
|
||||
if (config.useFakeTimers) {
|
||||
if (typeof config.useFakeTimers === "object") {
|
||||
sandbox.useFakeTimers(config.useFakeTimers);
|
||||
} else {
|
||||
sandbox.useFakeTimers();
|
||||
}
|
||||
}
|
||||
|
||||
return sandbox;
|
||||
}
|
||||
|
||||
function exposeValue(sandbox, config, key, value) {
|
||||
if (!value) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (config.injectInto && !(key in config.injectInto)) {
|
||||
config.injectInto[key] = value;
|
||||
push(sandbox.injectedKeys, key);
|
||||
} else {
|
||||
push(sandbox.args, value);
|
||||
}
|
||||
}
|
||||
|
||||
function createSandbox(config) {
|
||||
if (!config) {
|
||||
return new Sandbox();
|
||||
}
|
||||
|
||||
var configuredSandbox = prepareSandboxFromConfig(config);
|
||||
configuredSandbox.args = configuredSandbox.args || [];
|
||||
configuredSandbox.injectedKeys = [];
|
||||
configuredSandbox.injectInto = config.injectInto;
|
||||
var exposed = configuredSandbox.inject({});
|
||||
|
||||
if (config.properties) {
|
||||
forEach(config.properties, function(prop) {
|
||||
var value = exposed[prop] || (prop === "sandbox" && configuredSandbox);
|
||||
exposeValue(configuredSandbox, config, prop, value);
|
||||
});
|
||||
} else {
|
||||
exposeValue(configuredSandbox, config, "sandbox");
|
||||
}
|
||||
|
||||
return configuredSandbox;
|
||||
}
|
||||
|
||||
module.exports = createSandbox;
|
||||
270
node_modules/sinon/lib/sinon/default-behaviors.js
generated
vendored
Normal file
270
node_modules/sinon/lib/sinon/default-behaviors.js
generated
vendored
Normal file
|
|
@ -0,0 +1,270 @@
|
|||
"use strict";
|
||||
|
||||
var arrayProto = require("@sinonjs/commons").prototypes.array;
|
||||
var isPropertyConfigurable = require("./util/core/is-property-configurable");
|
||||
var exportAsyncBehaviors = require("./util/core/export-async-behaviors");
|
||||
var extend = require("./util/core/extend");
|
||||
|
||||
var slice = arrayProto.slice;
|
||||
|
||||
var useLeftMostCallback = -1;
|
||||
var useRightMostCallback = -2;
|
||||
|
||||
function throwsException(fake, error, message) {
|
||||
if (typeof error === "function") {
|
||||
fake.exceptionCreator = error;
|
||||
} else if (typeof error === "string") {
|
||||
fake.exceptionCreator = function() {
|
||||
var newException = new Error(message || "");
|
||||
newException.name = error;
|
||||
return newException;
|
||||
};
|
||||
} else if (!error) {
|
||||
fake.exceptionCreator = function() {
|
||||
return new Error("Error");
|
||||
};
|
||||
} else {
|
||||
fake.exception = error;
|
||||
}
|
||||
}
|
||||
|
||||
var defaultBehaviors = {
|
||||
callsFake: function callsFake(fake, fn) {
|
||||
fake.fakeFn = fn;
|
||||
},
|
||||
|
||||
callsArg: function callsArg(fake, index) {
|
||||
if (typeof index !== "number") {
|
||||
throw new TypeError("argument index is not number");
|
||||
}
|
||||
|
||||
fake.callArgAt = index;
|
||||
fake.callbackArguments = [];
|
||||
fake.callbackContext = undefined;
|
||||
fake.callArgProp = undefined;
|
||||
fake.callbackAsync = false;
|
||||
},
|
||||
|
||||
callsArgOn: function callsArgOn(fake, index, context) {
|
||||
if (typeof index !== "number") {
|
||||
throw new TypeError("argument index is not number");
|
||||
}
|
||||
|
||||
fake.callArgAt = index;
|
||||
fake.callbackArguments = [];
|
||||
fake.callbackContext = context;
|
||||
fake.callArgProp = undefined;
|
||||
fake.callbackAsync = false;
|
||||
},
|
||||
|
||||
callsArgWith: function callsArgWith(fake, index) {
|
||||
if (typeof index !== "number") {
|
||||
throw new TypeError("argument index is not number");
|
||||
}
|
||||
|
||||
fake.callArgAt = index;
|
||||
fake.callbackArguments = slice(arguments, 2);
|
||||
fake.callbackContext = undefined;
|
||||
fake.callArgProp = undefined;
|
||||
fake.callbackAsync = false;
|
||||
},
|
||||
|
||||
callsArgOnWith: function callsArgWith(fake, index, context) {
|
||||
if (typeof index !== "number") {
|
||||
throw new TypeError("argument index is not number");
|
||||
}
|
||||
|
||||
fake.callArgAt = index;
|
||||
fake.callbackArguments = slice(arguments, 3);
|
||||
fake.callbackContext = context;
|
||||
fake.callArgProp = undefined;
|
||||
fake.callbackAsync = false;
|
||||
},
|
||||
|
||||
usingPromise: function usingPromise(fake, promiseLibrary) {
|
||||
fake.promiseLibrary = promiseLibrary;
|
||||
},
|
||||
|
||||
yields: function(fake) {
|
||||
fake.callArgAt = useLeftMostCallback;
|
||||
fake.callbackArguments = slice(arguments, 1);
|
||||
fake.callbackContext = undefined;
|
||||
fake.callArgProp = undefined;
|
||||
fake.callbackAsync = false;
|
||||
},
|
||||
|
||||
yieldsRight: function(fake) {
|
||||
fake.callArgAt = useRightMostCallback;
|
||||
fake.callbackArguments = slice(arguments, 1);
|
||||
fake.callbackContext = undefined;
|
||||
fake.callArgProp = undefined;
|
||||
fake.callbackAsync = false;
|
||||
},
|
||||
|
||||
yieldsOn: function(fake, context) {
|
||||
fake.callArgAt = useLeftMostCallback;
|
||||
fake.callbackArguments = slice(arguments, 2);
|
||||
fake.callbackContext = context;
|
||||
fake.callArgProp = undefined;
|
||||
fake.callbackAsync = false;
|
||||
},
|
||||
|
||||
yieldsTo: function(fake, prop) {
|
||||
fake.callArgAt = useLeftMostCallback;
|
||||
fake.callbackArguments = slice(arguments, 2);
|
||||
fake.callbackContext = undefined;
|
||||
fake.callArgProp = prop;
|
||||
fake.callbackAsync = false;
|
||||
},
|
||||
|
||||
yieldsToOn: function(fake, prop, context) {
|
||||
fake.callArgAt = useLeftMostCallback;
|
||||
fake.callbackArguments = slice(arguments, 3);
|
||||
fake.callbackContext = context;
|
||||
fake.callArgProp = prop;
|
||||
fake.callbackAsync = false;
|
||||
},
|
||||
|
||||
throws: throwsException,
|
||||
throwsException: throwsException,
|
||||
|
||||
returns: function returns(fake, value) {
|
||||
fake.returnValue = value;
|
||||
fake.resolve = false;
|
||||
fake.reject = false;
|
||||
fake.returnValueDefined = true;
|
||||
fake.exception = undefined;
|
||||
fake.exceptionCreator = undefined;
|
||||
fake.fakeFn = undefined;
|
||||
},
|
||||
|
||||
returnsArg: function returnsArg(fake, index) {
|
||||
if (typeof index !== "number") {
|
||||
throw new TypeError("argument index is not number");
|
||||
}
|
||||
|
||||
fake.returnArgAt = index;
|
||||
},
|
||||
|
||||
throwsArg: function throwsArg(fake, index) {
|
||||
if (typeof index !== "number") {
|
||||
throw new TypeError("argument index is not number");
|
||||
}
|
||||
|
||||
fake.throwArgAt = index;
|
||||
},
|
||||
|
||||
returnsThis: function returnsThis(fake) {
|
||||
fake.returnThis = true;
|
||||
},
|
||||
|
||||
resolves: function resolves(fake, value) {
|
||||
fake.returnValue = value;
|
||||
fake.resolve = true;
|
||||
fake.resolveThis = false;
|
||||
fake.reject = false;
|
||||
fake.returnValueDefined = true;
|
||||
fake.exception = undefined;
|
||||
fake.exceptionCreator = undefined;
|
||||
fake.fakeFn = undefined;
|
||||
},
|
||||
|
||||
resolvesArg: function resolvesArg(fake, index) {
|
||||
if (typeof index !== "number") {
|
||||
throw new TypeError("argument index is not number");
|
||||
}
|
||||
fake.resolveArgAt = index;
|
||||
fake.returnValue = undefined;
|
||||
fake.resolve = true;
|
||||
fake.resolveThis = false;
|
||||
fake.reject = false;
|
||||
fake.returnValueDefined = false;
|
||||
fake.exception = undefined;
|
||||
fake.exceptionCreator = undefined;
|
||||
fake.fakeFn = undefined;
|
||||
},
|
||||
|
||||
rejects: function rejects(fake, error, message) {
|
||||
var reason;
|
||||
if (typeof error === "string") {
|
||||
reason = new Error(message || "");
|
||||
reason.name = error;
|
||||
} else if (!error) {
|
||||
reason = new Error("Error");
|
||||
} else {
|
||||
reason = error;
|
||||
}
|
||||
fake.returnValue = reason;
|
||||
fake.resolve = false;
|
||||
fake.resolveThis = false;
|
||||
fake.reject = true;
|
||||
fake.returnValueDefined = true;
|
||||
fake.exception = undefined;
|
||||
fake.exceptionCreator = undefined;
|
||||
fake.fakeFn = undefined;
|
||||
|
||||
return fake;
|
||||
},
|
||||
|
||||
resolvesThis: function resolvesThis(fake) {
|
||||
fake.returnValue = undefined;
|
||||
fake.resolve = false;
|
||||
fake.resolveThis = true;
|
||||
fake.reject = false;
|
||||
fake.returnValueDefined = false;
|
||||
fake.exception = undefined;
|
||||
fake.exceptionCreator = undefined;
|
||||
fake.fakeFn = undefined;
|
||||
},
|
||||
|
||||
callThrough: function callThrough(fake) {
|
||||
fake.callsThrough = true;
|
||||
},
|
||||
|
||||
callThroughWithNew: function callThroughWithNew(fake) {
|
||||
fake.callsThroughWithNew = true;
|
||||
},
|
||||
|
||||
get: function get(fake, getterFunction) {
|
||||
var rootStub = fake.stub || fake;
|
||||
|
||||
Object.defineProperty(rootStub.rootObj, rootStub.propName, {
|
||||
get: getterFunction,
|
||||
configurable: isPropertyConfigurable(rootStub.rootObj, rootStub.propName)
|
||||
});
|
||||
|
||||
return fake;
|
||||
},
|
||||
|
||||
set: function set(fake, setterFunction) {
|
||||
var rootStub = fake.stub || fake;
|
||||
|
||||
Object.defineProperty(
|
||||
rootStub.rootObj,
|
||||
rootStub.propName,
|
||||
// eslint-disable-next-line accessor-pairs
|
||||
{
|
||||
set: setterFunction,
|
||||
configurable: isPropertyConfigurable(rootStub.rootObj, rootStub.propName)
|
||||
}
|
||||
);
|
||||
|
||||
return fake;
|
||||
},
|
||||
|
||||
value: function value(fake, newVal) {
|
||||
var rootStub = fake.stub || fake;
|
||||
|
||||
Object.defineProperty(rootStub.rootObj, rootStub.propName, {
|
||||
value: newVal,
|
||||
enumerable: true,
|
||||
configurable: rootStub.shadowsPropOnPrototype || isPropertyConfigurable(rootStub.rootObj, rootStub.propName)
|
||||
});
|
||||
|
||||
return fake;
|
||||
}
|
||||
};
|
||||
|
||||
var asyncBehaviors = exportAsyncBehaviors(defaultBehaviors);
|
||||
|
||||
module.exports = extend({}, defaultBehaviors, asyncBehaviors);
|
||||
106
node_modules/sinon/lib/sinon/fake.js
generated
vendored
Normal file
106
node_modules/sinon/lib/sinon/fake.js
generated
vendored
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
"use strict";
|
||||
|
||||
var arrayProto = require("@sinonjs/commons").prototypes.array;
|
||||
var createProxy = require("./proxy");
|
||||
var nextTick = require("./util/core/next-tick");
|
||||
|
||||
var slice = arrayProto.slice;
|
||||
|
||||
function getError(value) {
|
||||
return value instanceof Error ? value : new Error(value);
|
||||
}
|
||||
|
||||
var uuid = 0;
|
||||
function wrapFunc(f) {
|
||||
var proxy;
|
||||
var fakeInstance = function() {
|
||||
var firstArg, lastArg;
|
||||
|
||||
if (arguments.length > 0) {
|
||||
firstArg = arguments[0];
|
||||
lastArg = arguments[arguments.length - 1];
|
||||
}
|
||||
|
||||
var callback = lastArg && typeof lastArg === "function" ? lastArg : undefined;
|
||||
|
||||
proxy.firstArg = firstArg;
|
||||
proxy.lastArg = lastArg;
|
||||
proxy.callback = callback;
|
||||
|
||||
return f && f.apply(this, arguments);
|
||||
};
|
||||
proxy = createProxy(fakeInstance, f || fakeInstance);
|
||||
|
||||
proxy.displayName = "fake";
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
316
node_modules/sinon/lib/sinon/mock-expectation.js
generated
vendored
Normal file
316
node_modules/sinon/lib/sinon/mock-expectation.js
generated
vendored
Normal file
|
|
@ -0,0 +1,316 @@
|
|||
"use strict";
|
||||
|
||||
var arrayProto = require("@sinonjs/commons").prototypes.array;
|
||||
var proxyInvoke = require("./proxy-invoke");
|
||||
var proxyCallToString = require("./proxy-call").toString;
|
||||
var timesInWords = require("./util/core/times-in-words");
|
||||
var extend = require("./util/core/extend");
|
||||
var match = require("@sinonjs/samsam").createMatcher;
|
||||
var stub = require("./stub");
|
||||
var assert = require("./assert");
|
||||
var deepEqual = require("@sinonjs/samsam").deepEqual;
|
||||
var format = require("./util/core/format");
|
||||
var valueToString = require("@sinonjs/commons").valueToString;
|
||||
|
||||
var every = arrayProto.every;
|
||||
var forEach = arrayProto.forEach;
|
||||
var push = arrayProto.push;
|
||||
var slice = arrayProto.slice;
|
||||
|
||||
function callCountInWords(callCount) {
|
||||
if (callCount === 0) {
|
||||
return "never called";
|
||||
}
|
||||
|
||||
return "called " + timesInWords(callCount);
|
||||
}
|
||||
|
||||
function expectedCallCountInWords(expectation) {
|
||||
var min = expectation.minCalls;
|
||||
var max = expectation.maxCalls;
|
||||
|
||||
if (typeof min === "number" && typeof max === "number") {
|
||||
var str = timesInWords(min);
|
||||
|
||||
if (min !== max) {
|
||||
str = "at least " + str + " and at most " + timesInWords(max);
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
if (typeof min === "number") {
|
||||
return "at least " + timesInWords(min);
|
||||
}
|
||||
|
||||
return "at most " + timesInWords(max);
|
||||
}
|
||||
|
||||
function receivedMinCalls(expectation) {
|
||||
var hasMinLimit = typeof expectation.minCalls === "number";
|
||||
return !hasMinLimit || expectation.callCount >= expectation.minCalls;
|
||||
}
|
||||
|
||||
function receivedMaxCalls(expectation) {
|
||||
if (typeof expectation.maxCalls !== "number") {
|
||||
return false;
|
||||
}
|
||||
|
||||
return expectation.callCount === expectation.maxCalls;
|
||||
}
|
||||
|
||||
function verifyMatcher(possibleMatcher, arg) {
|
||||
var isMatcher = match.isMatcher(possibleMatcher);
|
||||
|
||||
return (isMatcher && possibleMatcher.test(arg)) || true;
|
||||
}
|
||||
|
||||
var mockExpectation = {
|
||||
minCalls: 1,
|
||||
maxCalls: 1,
|
||||
|
||||
create: function create(methodName) {
|
||||
var expectation = extend.nonEnum(stub(), mockExpectation);
|
||||
delete expectation.create;
|
||||
expectation.method = methodName;
|
||||
|
||||
return expectation;
|
||||
},
|
||||
|
||||
invoke: function invoke(func, thisValue, args) {
|
||||
this.verifyCallAllowed(thisValue, args);
|
||||
|
||||
return proxyInvoke.apply(this, arguments);
|
||||
},
|
||||
|
||||
atLeast: function atLeast(num) {
|
||||
if (typeof num !== "number") {
|
||||
throw new TypeError("'" + valueToString(num) + "' is not number");
|
||||
}
|
||||
|
||||
if (!this.limitsSet) {
|
||||
this.maxCalls = null;
|
||||
this.limitsSet = true;
|
||||
}
|
||||
|
||||
this.minCalls = num;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
atMost: function atMost(num) {
|
||||
if (typeof num !== "number") {
|
||||
throw new TypeError("'" + valueToString(num) + "' is not number");
|
||||
}
|
||||
|
||||
if (!this.limitsSet) {
|
||||
this.minCalls = null;
|
||||
this.limitsSet = true;
|
||||
}
|
||||
|
||||
this.maxCalls = num;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
never: function never() {
|
||||
return this.exactly(0);
|
||||
},
|
||||
|
||||
once: function once() {
|
||||
return this.exactly(1);
|
||||
},
|
||||
|
||||
twice: function twice() {
|
||||
return this.exactly(2);
|
||||
},
|
||||
|
||||
thrice: function thrice() {
|
||||
return this.exactly(3);
|
||||
},
|
||||
|
||||
exactly: function exactly(num) {
|
||||
if (typeof num !== "number") {
|
||||
throw new TypeError("'" + valueToString(num) + "' is not a number");
|
||||
}
|
||||
|
||||
this.atLeast(num);
|
||||
return this.atMost(num);
|
||||
},
|
||||
|
||||
met: function met() {
|
||||
return !this.failed && receivedMinCalls(this);
|
||||
},
|
||||
|
||||
verifyCallAllowed: function verifyCallAllowed(thisValue, args) {
|
||||
var expectedArguments = this.expectedArguments;
|
||||
|
||||
if (receivedMaxCalls(this)) {
|
||||
this.failed = true;
|
||||
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)
|
||||
);
|
||||
}
|
||||
|
||||
if (!("expectedArguments" in this)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!args) {
|
||||
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)
|
||||
);
|
||||
}
|
||||
|
||||
if (this.expectsExactArgCount && args.length !== expectedArguments.length) {
|
||||
mockExpectation.fail(
|
||||
this.method +
|
||||
" received too many arguments (" +
|
||||
format(args) +
|
||||
"), expected " +
|
||||
format(expectedArguments)
|
||||
);
|
||||
}
|
||||
|
||||
forEach(
|
||||
expectedArguments,
|
||||
function(expectedArgument, i) {
|
||||
if (!verifyMatcher(expectedArgument, args[i])) {
|
||||
mockExpectation.fail(
|
||||
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
|
||||
);
|
||||
},
|
||||
|
||||
allowsCall: function allowsCall(thisValue, args) {
|
||||
var expectedArguments = this.expectedArguments;
|
||||
|
||||
if (this.met() && receivedMaxCalls(this)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ("expectedThis" in this && this.expectedThis !== thisValue) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!("expectedArguments" in this)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-underscore-dangle
|
||||
var _args = args || [];
|
||||
|
||||
if (_args.length < expectedArguments.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.expectsExactArgCount && _args.length !== expectedArguments.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return every(expectedArguments, function(expectedArgument, i) {
|
||||
if (!verifyMatcher(expectedArgument, _args[i])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!deepEqual(_args[i], expectedArgument)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
},
|
||||
|
||||
withArgs: function withArgs() {
|
||||
this.expectedArguments = slice(arguments);
|
||||
return this;
|
||||
},
|
||||
|
||||
withExactArgs: function withExactArgs() {
|
||||
this.withArgs.apply(this, arguments);
|
||||
this.expectsExactArgCount = true;
|
||||
return this;
|
||||
},
|
||||
|
||||
on: function on(thisValue) {
|
||||
this.expectedThis = thisValue;
|
||||
return this;
|
||||
},
|
||||
|
||||
toString: function() {
|
||||
var args = slice(this.expectedArguments || []);
|
||||
|
||||
if (!this.expectsExactArgCount) {
|
||||
push(args, "[...]");
|
||||
}
|
||||
|
||||
var callStr = proxyCallToString.call({
|
||||
proxy: this.method || "anonymous mock expectation",
|
||||
args: args
|
||||
});
|
||||
|
||||
var message = callStr.replace(", [...", "[, ...") + " " + expectedCallCountInWords(this);
|
||||
|
||||
if (this.met()) {
|
||||
return "Expectation met: " + message;
|
||||
}
|
||||
|
||||
return "Expected " + message + " (" + callCountInWords(this.callCount) + ")";
|
||||
},
|
||||
|
||||
verify: function verify() {
|
||||
if (!this.met()) {
|
||||
mockExpectation.fail(String(this));
|
||||
} else {
|
||||
mockExpectation.pass(String(this));
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
pass: function pass(message) {
|
||||
assert.pass(message);
|
||||
},
|
||||
|
||||
fail: function fail(message) {
|
||||
var exception = new Error(message);
|
||||
exception.name = "ExpectationError";
|
||||
|
||||
throw exception;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = mockExpectation;
|
||||
200
node_modules/sinon/lib/sinon/mock.js
generated
vendored
Normal file
200
node_modules/sinon/lib/sinon/mock.js
generated
vendored
Normal file
|
|
@ -0,0 +1,200 @@
|
|||
"use strict";
|
||||
|
||||
var arrayProto = require("@sinonjs/commons").prototypes.array;
|
||||
var mockExpectation = require("./mock-expectation");
|
||||
var proxyCallToString = require("./proxy-call").toString;
|
||||
var extend = require("./util/core/extend");
|
||||
var deepEqual = require("@sinonjs/samsam").deepEqual;
|
||||
var wrapMethod = require("./util/core/wrap-method");
|
||||
var usePromiseLibrary = require("./util/core/use-promise-library");
|
||||
|
||||
var concat = arrayProto.concat;
|
||||
var filter = arrayProto.filter;
|
||||
var forEach = arrayProto.forEach;
|
||||
var every = arrayProto.every;
|
||||
var join = arrayProto.join;
|
||||
var push = arrayProto.push;
|
||||
var slice = arrayProto.slice;
|
||||
var unshift = arrayProto.unshift;
|
||||
|
||||
function mock(object) {
|
||||
if (!object || typeof object === "string") {
|
||||
return mockExpectation.create(object ? object : "Anonymous mock");
|
||||
}
|
||||
|
||||
return mock.create(object);
|
||||
}
|
||||
|
||||
function each(collection, callback) {
|
||||
var col = collection || [];
|
||||
|
||||
forEach(col, callback);
|
||||
}
|
||||
|
||||
function arrayEquals(arr1, arr2, compareLength) {
|
||||
if (compareLength && arr1.length !== arr2.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return every(arr1, function(element, i) {
|
||||
return deepEqual(arr2[i], element);
|
||||
});
|
||||
}
|
||||
|
||||
extend(mock, {
|
||||
create: function create(object) {
|
||||
if (!object) {
|
||||
throw new TypeError("object is null");
|
||||
}
|
||||
|
||||
var mockObject = extend.nonEnum({}, mock, { object: object });
|
||||
delete mockObject.create;
|
||||
|
||||
return mockObject;
|
||||
},
|
||||
|
||||
expects: function expects(method) {
|
||||
if (!method) {
|
||||
throw new TypeError("method is falsy");
|
||||
}
|
||||
|
||||
if (!this.expectations) {
|
||||
this.expectations = {};
|
||||
this.proxies = [];
|
||||
this.failures = [];
|
||||
}
|
||||
|
||||
if (!this.expectations[method]) {
|
||||
this.expectations[method] = [];
|
||||
var mockObject = this;
|
||||
|
||||
wrapMethod(this.object, method, function() {
|
||||
return mockObject.invokeMethod(method, this, arguments);
|
||||
});
|
||||
|
||||
push(this.proxies, method);
|
||||
}
|
||||
|
||||
var expectation = mockExpectation.create(method);
|
||||
expectation.wrappedMethod = this.object[method].wrappedMethod;
|
||||
push(this.expectations[method], expectation);
|
||||
usePromiseLibrary(this.promiseLibrary, expectation);
|
||||
|
||||
return expectation;
|
||||
},
|
||||
|
||||
restore: function restore() {
|
||||
var object = this.object;
|
||||
|
||||
each(this.proxies, function(proxy) {
|
||||
if (typeof object[proxy].restore === "function") {
|
||||
object[proxy].restore();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
verify: function verify() {
|
||||
var expectations = this.expectations || {};
|
||||
var messages = this.failures ? slice(this.failures) : [];
|
||||
var met = [];
|
||||
|
||||
each(this.proxies, function(proxy) {
|
||||
each(expectations[proxy], function(expectation) {
|
||||
if (!expectation.met()) {
|
||||
push(messages, String(expectation));
|
||||
} else {
|
||||
push(met, String(expectation));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
this.restore();
|
||||
|
||||
if (messages.length > 0) {
|
||||
mockExpectation.fail(join(concat(messages, met), "\n"));
|
||||
} else if (met.length > 0) {
|
||||
mockExpectation.pass(join(concat(messages, met), "\n"));
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
usingPromise: function usingPromise(promiseLibrary) {
|
||||
this.promiseLibrary = promiseLibrary;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
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 currentArgs = args || [];
|
||||
var available;
|
||||
|
||||
var expectationsWithMatchingArgs = filter(expectations, function(expectation) {
|
||||
var expectedArgs = expectation.expectedArguments || [];
|
||||
|
||||
return arrayEquals(expectedArgs, currentArgs, expectation.expectsExactArgCount);
|
||||
});
|
||||
|
||||
var expectationsToApply = filter(expectationsWithMatchingArgs, function(expectation) {
|
||||
return !expectation.met() && expectation.allowsCall(thisValue, args);
|
||||
});
|
||||
|
||||
if (expectationsToApply.length > 0) {
|
||||
return expectationsToApply[0].apply(thisValue, args);
|
||||
}
|
||||
|
||||
var messages = [];
|
||||
var exhausted = 0;
|
||||
|
||||
forEach(expectationsWithMatchingArgs, function(expectation) {
|
||||
if (expectation.allowsCall(thisValue, args)) {
|
||||
available = available || expectation;
|
||||
} else {
|
||||
exhausted += 1;
|
||||
}
|
||||
});
|
||||
|
||||
if (available && exhausted === 0) {
|
||||
return available.apply(thisValue, args);
|
||||
}
|
||||
|
||||
forEach(expectations, function(expectation) {
|
||||
push(messages, " " + String(expectation));
|
||||
});
|
||||
|
||||
unshift(
|
||||
messages,
|
||||
"Unexpected call: " +
|
||||
proxyCallToString.call({
|
||||
proxy: method,
|
||||
args: args
|
||||
})
|
||||
);
|
||||
|
||||
var err = new Error();
|
||||
if (!err.stack) {
|
||||
// PhantomJS does not serialize the stack trace until the error has been thrown
|
||||
try {
|
||||
throw err;
|
||||
} catch (e) {
|
||||
/* empty */
|
||||
}
|
||||
}
|
||||
push(
|
||||
this.failures,
|
||||
"Unexpected call: " +
|
||||
proxyCallToString.call({
|
||||
proxy: method,
|
||||
args: args,
|
||||
stack: err.stack
|
||||
})
|
||||
);
|
||||
|
||||
mockExpectation.fail(join(messages, "\n"));
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = mock;
|
||||
64
node_modules/sinon/lib/sinon/proxy-call-util.js
generated
vendored
Normal file
64
node_modules/sinon/lib/sinon/proxy-call-util.js
generated
vendored
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
"use strict";
|
||||
|
||||
var push = require("@sinonjs/commons").prototypes.array.push;
|
||||
|
||||
exports.incrementCallCount = function incrementCallCount(proxy) {
|
||||
proxy.called = true;
|
||||
proxy.callCount += 1;
|
||||
proxy.notCalled = false;
|
||||
proxy.calledOnce = proxy.callCount === 1;
|
||||
proxy.calledTwice = proxy.callCount === 2;
|
||||
proxy.calledThrice = proxy.callCount === 3;
|
||||
};
|
||||
|
||||
exports.createCallProperties = function createCallProperties(proxy) {
|
||||
proxy.firstCall = proxy.getCall(0);
|
||||
proxy.secondCall = proxy.getCall(1);
|
||||
proxy.thirdCall = proxy.getCall(2);
|
||||
proxy.lastCall = proxy.getCall(proxy.callCount - 1);
|
||||
};
|
||||
|
||||
exports.delegateToCalls = function delegateToCalls(
|
||||
proxy,
|
||||
method,
|
||||
matchAny,
|
||||
actual,
|
||||
returnsValues,
|
||||
notCalled,
|
||||
totalCallCount
|
||||
) {
|
||||
proxy[method] = function() {
|
||||
if (!this.called) {
|
||||
if (notCalled) {
|
||||
return notCalled.apply(this, arguments);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (totalCallCount !== undefined && this.callCount !== totalCallCount) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var currentCall;
|
||||
var matches = 0;
|
||||
var returnValues = [];
|
||||
|
||||
for (var i = 0, l = this.callCount; i < l; i += 1) {
|
||||
currentCall = this.getCall(i);
|
||||
var returnValue = currentCall[actual || method].apply(currentCall, arguments);
|
||||
push(returnValues, returnValue);
|
||||
if (returnValue) {
|
||||
matches += 1;
|
||||
|
||||
if (matchAny) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (returnsValues) {
|
||||
return returnValues;
|
||||
}
|
||||
return matches === this.callCount;
|
||||
};
|
||||
};
|
||||
261
node_modules/sinon/lib/sinon/proxy-call.js
generated
vendored
Normal file
261
node_modules/sinon/lib/sinon/proxy-call.js
generated
vendored
Normal file
|
|
@ -0,0 +1,261 @@
|
|||
"use strict";
|
||||
|
||||
var arrayProto = require("@sinonjs/commons").prototypes.array;
|
||||
var match = require("@sinonjs/samsam").createMatcher;
|
||||
var deepEqual = require("@sinonjs/samsam").deepEqual;
|
||||
var functionName = require("@sinonjs/commons").functionName;
|
||||
var sinonFormat = require("./util/core/format");
|
||||
var valueToString = require("@sinonjs/commons").valueToString;
|
||||
|
||||
var concat = arrayProto.concat;
|
||||
var filter = arrayProto.filter;
|
||||
var join = arrayProto.join;
|
||||
var map = arrayProto.map;
|
||||
var reduce = arrayProto.reduce;
|
||||
var slice = arrayProto.slice;
|
||||
|
||||
function throwYieldError(proxy, text, args) {
|
||||
var msg = functionName(proxy) + text;
|
||||
if (args.length) {
|
||||
msg += " Received [" + join(slice(args), ", ") + "]";
|
||||
}
|
||||
throw new Error(msg);
|
||||
}
|
||||
|
||||
var callProto = {
|
||||
calledOn: function calledOn(thisValue) {
|
||||
if (match.isMatcher(thisValue)) {
|
||||
return thisValue.test(this.thisValue);
|
||||
}
|
||||
return this.thisValue === thisValue;
|
||||
},
|
||||
|
||||
calledWith: function calledWith() {
|
||||
var self = this;
|
||||
var calledWithArgs = slice(arguments);
|
||||
|
||||
if (calledWithArgs.length > self.args.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return reduce(
|
||||
calledWithArgs,
|
||||
function(prev, arg, i) {
|
||||
return prev && deepEqual(self.args[i], arg);
|
||||
},
|
||||
true
|
||||
);
|
||||
},
|
||||
|
||||
calledWithMatch: function calledWithMatch() {
|
||||
var self = this;
|
||||
var calledWithMatchArgs = slice(arguments);
|
||||
|
||||
if (calledWithMatchArgs.length > self.args.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return reduce(
|
||||
calledWithMatchArgs,
|
||||
function(prev, expectation, i) {
|
||||
var actual = self.args[i];
|
||||
|
||||
return prev && match(expectation).test(actual);
|
||||
},
|
||||
true
|
||||
);
|
||||
},
|
||||
|
||||
calledWithExactly: function calledWithExactly() {
|
||||
return arguments.length === this.args.length && this.calledWith.apply(this, arguments);
|
||||
},
|
||||
|
||||
notCalledWith: function notCalledWith() {
|
||||
return !this.calledWith.apply(this, arguments);
|
||||
},
|
||||
|
||||
notCalledWithMatch: function notCalledWithMatch() {
|
||||
return !this.calledWithMatch.apply(this, arguments);
|
||||
},
|
||||
|
||||
returned: function returned(value) {
|
||||
return deepEqual(this.returnValue, value);
|
||||
},
|
||||
|
||||
threw: function threw(error) {
|
||||
if (typeof error === "undefined" || !this.exception) {
|
||||
return Boolean(this.exception);
|
||||
}
|
||||
|
||||
return this.exception === error || this.exception.name === error;
|
||||
},
|
||||
|
||||
calledWithNew: function calledWithNew() {
|
||||
return this.proxy.prototype && this.thisValue instanceof this.proxy;
|
||||
},
|
||||
|
||||
calledBefore: function(other) {
|
||||
return this.callId < other.callId;
|
||||
},
|
||||
|
||||
calledAfter: function(other) {
|
||||
return this.callId > other.callId;
|
||||
},
|
||||
|
||||
calledImmediatelyBefore: function(other) {
|
||||
return this.callId === other.callId - 1;
|
||||
},
|
||||
|
||||
calledImmediatelyAfter: function(other) {
|
||||
return this.callId === other.callId + 1;
|
||||
},
|
||||
|
||||
callArg: function(pos) {
|
||||
this.ensureArgIsAFunction(pos);
|
||||
return this.args[pos]();
|
||||
},
|
||||
|
||||
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)));
|
||||
},
|
||||
|
||||
callArgOnWith: function(pos, thisValue) {
|
||||
this.ensureArgIsAFunction(pos);
|
||||
var args = slice(arguments, 2);
|
||||
return this.args[pos].apply(thisValue, args);
|
||||
},
|
||||
|
||||
throwArg: function(pos) {
|
||||
if (pos > this.args.length) {
|
||||
throw new TypeError("Not enough arguments: " + pos + " required but only " + this.args.length + " present");
|
||||
}
|
||||
|
||||
throw this.args[pos];
|
||||
},
|
||||
|
||||
yield: function() {
|
||||
return this.yieldOn.apply(this, concat([null], slice(arguments, 0)));
|
||||
},
|
||||
|
||||
yieldOn: function(thisValue) {
|
||||
var args = slice(this.args);
|
||||
var yieldFn = filter(args, function(arg) {
|
||||
return typeof arg === "function";
|
||||
})[0];
|
||||
|
||||
if (!yieldFn) {
|
||||
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)));
|
||||
},
|
||||
|
||||
yieldToOn: function(prop, thisValue) {
|
||||
var args = slice(this.args);
|
||||
var yieldArg = filter(args, function(arg) {
|
||||
return arg && typeof arg[prop] === "function";
|
||||
})[0];
|
||||
var yieldFn = yieldArg && yieldArg[prop];
|
||||
|
||||
if (!yieldFn) {
|
||||
throwYieldError(
|
||||
this.proxy,
|
||||
" cannot yield to '" + valueToString(prop) + "' since no callback was passed.",
|
||||
args
|
||||
);
|
||||
}
|
||||
|
||||
return yieldFn.apply(thisValue, slice(arguments, 2));
|
||||
},
|
||||
|
||||
toString: function() {
|
||||
var callStr = this.proxy ? String(this.proxy) + "(" : "";
|
||||
var formattedArgs;
|
||||
|
||||
if (!this.args) {
|
||||
return ":(";
|
||||
}
|
||||
|
||||
formattedArgs = map(this.args, function(arg) {
|
||||
return sinonFormat(arg);
|
||||
});
|
||||
|
||||
callStr = callStr + join(formattedArgs, ", ") + ")";
|
||||
|
||||
if (typeof this.returnValue !== "undefined") {
|
||||
callStr += " => " + sinonFormat(this.returnValue);
|
||||
}
|
||||
|
||||
if (this.exception) {
|
||||
callStr += " !" + this.exception.name;
|
||||
|
||||
if (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 ");
|
||||
}
|
||||
|
||||
return callStr;
|
||||
},
|
||||
|
||||
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]
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
Object.defineProperty(callProto, "stack", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
get: function() {
|
||||
return (this.errorWithCallStack && this.errorWithCallStack.stack) || "";
|
||||
}
|
||||
});
|
||||
|
||||
callProto.invokeCallback = callProto.yield;
|
||||
|
||||
function createProxyCall(proxy, thisValue, args, returnValue, exception, id, errorWithCallStack) {
|
||||
if (typeof id !== "number") {
|
||||
throw new TypeError("Call id is not a number");
|
||||
}
|
||||
|
||||
var firstArg, lastArg;
|
||||
|
||||
if (args.length > 0) {
|
||||
firstArg = args[0];
|
||||
lastArg = args[args.length - 1];
|
||||
}
|
||||
|
||||
var proxyCall = Object.create(callProto);
|
||||
var callback = lastArg && typeof lastArg === "function" ? lastArg : undefined;
|
||||
|
||||
proxyCall.proxy = proxy;
|
||||
proxyCall.thisValue = thisValue;
|
||||
proxyCall.args = args;
|
||||
proxyCall.firstArg = firstArg;
|
||||
proxyCall.lastArg = lastArg;
|
||||
proxyCall.callback = callback;
|
||||
proxyCall.returnValue = returnValue;
|
||||
proxyCall.exception = exception;
|
||||
proxyCall.callId = id;
|
||||
proxyCall.errorWithCallStack = errorWithCallStack;
|
||||
|
||||
return proxyCall;
|
||||
}
|
||||
createProxyCall.toString = callProto.toString; // used by mocks
|
||||
|
||||
module.exports = createProxyCall;
|
||||
85
node_modules/sinon/lib/sinon/proxy-invoke.js
generated
vendored
Normal file
85
node_modules/sinon/lib/sinon/proxy-invoke.js
generated
vendored
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
"use strict";
|
||||
|
||||
var arrayProto = require("@sinonjs/commons").prototypes.array;
|
||||
var proxyCallUtil = require("./proxy-call-util");
|
||||
|
||||
var push = arrayProto.push;
|
||||
var forEach = arrayProto.forEach;
|
||||
var concat = arrayProto.concat;
|
||||
var ErrorConstructor = Error.prototype.constructor;
|
||||
var bind = Function.prototype.bind;
|
||||
|
||||
var callId = 0;
|
||||
|
||||
module.exports = function invoke(func, thisValue, args) {
|
||||
var matchings = this.matchingFakes(args);
|
||||
var currentCallId = callId++;
|
||||
var exception, returnValue;
|
||||
|
||||
proxyCallUtil.incrementCallCount(this);
|
||||
push(this.thisValues, thisValue);
|
||||
push(this.args, args);
|
||||
push(this.callIds, currentCallId);
|
||||
forEach(matchings, function(matching) {
|
||||
proxyCallUtil.incrementCallCount(matching);
|
||||
push(matching.thisValues, thisValue);
|
||||
push(matching.args, args);
|
||||
push(matching.callIds, currentCallId);
|
||||
});
|
||||
|
||||
// Make call properties available from within the spied function:
|
||||
proxyCallUtil.createCallProperties(this);
|
||||
forEach(matchings, proxyCallUtil.createCallProperties);
|
||||
|
||||
try {
|
||||
this.invoking = true;
|
||||
|
||||
var thisCall = this.getCall(this.callCount - 1);
|
||||
|
||||
if (thisCall.calledWithNew()) {
|
||||
// Call through with `new`
|
||||
returnValue = new (bind.apply(this.func || func, concat([thisValue], args)))();
|
||||
|
||||
if (typeof returnValue !== "object") {
|
||||
returnValue = thisValue;
|
||||
}
|
||||
} else {
|
||||
returnValue = (this.func || func).apply(thisValue, args);
|
||||
}
|
||||
} catch (e) {
|
||||
exception = e;
|
||||
} finally {
|
||||
delete this.invoking;
|
||||
}
|
||||
|
||||
push(this.exceptions, exception);
|
||||
push(this.returnValues, returnValue);
|
||||
forEach(matchings, function(matching) {
|
||||
push(matching.exceptions, exception);
|
||||
push(matching.returnValues, returnValue);
|
||||
});
|
||||
|
||||
var err = new ErrorConstructor();
|
||||
// 1. Please do not get stack at this point. It may be so very slow, and not actually used
|
||||
// 2. PhantomJS does not serialize the stack trace until the error has been thrown:
|
||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Stack
|
||||
try {
|
||||
throw err;
|
||||
} catch (e) {
|
||||
/* empty */
|
||||
}
|
||||
push(this.errorsWithCallStack, err);
|
||||
forEach(matchings, function(matching) {
|
||||
push(matching.errorsWithCallStack, err);
|
||||
});
|
||||
|
||||
// Make return value and exception available in the calls:
|
||||
proxyCallUtil.createCallProperties(this);
|
||||
forEach(matchings, proxyCallUtil.createCallProperties);
|
||||
|
||||
if (exception !== undefined) {
|
||||
throw exception;
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
};
|
||||
316
node_modules/sinon/lib/sinon/proxy.js
generated
vendored
Normal file
316
node_modules/sinon/lib/sinon/proxy.js
generated
vendored
Normal file
|
|
@ -0,0 +1,316 @@
|
|||
"use strict";
|
||||
|
||||
var arrayProto = require("@sinonjs/commons").prototypes.array;
|
||||
var extend = require("./util/core/extend");
|
||||
var functionToString = require("./util/core/function-to-string");
|
||||
var proxyCall = require("./proxy-call");
|
||||
var proxyCallUtil = require("./proxy-call-util");
|
||||
var proxyInvoke = require("./proxy-invoke");
|
||||
var sinonFormat = require("./util/core/format");
|
||||
|
||||
var push = arrayProto.push;
|
||||
var forEach = arrayProto.forEach;
|
||||
var slice = arrayProto.slice;
|
||||
|
||||
var emptyFakes = Object.freeze([]);
|
||||
|
||||
// Public API
|
||||
var proxyApi = {
|
||||
toString: functionToString,
|
||||
|
||||
named: function named(name) {
|
||||
this.displayName = name;
|
||||
var nameDescriptor = Object.getOwnPropertyDescriptor(this, "name");
|
||||
if (nameDescriptor && nameDescriptor.configurable) {
|
||||
// IE 11 functions don't have a name.
|
||||
// Safari 9 has names that are not configurable.
|
||||
nameDescriptor.value = name;
|
||||
Object.defineProperty(this, "name", nameDescriptor);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
invoke: proxyInvoke,
|
||||
|
||||
/*
|
||||
* Hook for derived implementation to return fake instances matching the
|
||||
* given arguments.
|
||||
*/
|
||||
matchingFakes: function(/*args, strict*/) {
|
||||
return emptyFakes;
|
||||
},
|
||||
|
||||
getCall: function getCall(index) {
|
||||
var i = index;
|
||||
if (i < 0) {
|
||||
// Negative indices means counting backwards from the last call
|
||||
i += this.callCount;
|
||||
}
|
||||
if (i < 0 || i >= this.callCount) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return proxyCall(
|
||||
this,
|
||||
this.thisValues[i],
|
||||
this.args[i],
|
||||
this.returnValues[i],
|
||||
this.exceptions[i],
|
||||
this.callIds[i],
|
||||
this.errorsWithCallStack[i]
|
||||
);
|
||||
},
|
||||
|
||||
getCalls: function() {
|
||||
var calls = [];
|
||||
var i;
|
||||
|
||||
for (i = 0; i < this.callCount; i++) {
|
||||
push(calls, this.getCall(i));
|
||||
}
|
||||
|
||||
return calls;
|
||||
},
|
||||
|
||||
calledBefore: function calledBefore(proxy) {
|
||||
if (!this.called) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!proxy.called) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return this.callIds[0] < proxy.callIds[proxy.callIds.length - 1];
|
||||
},
|
||||
|
||||
calledAfter: function calledAfter(proxy) {
|
||||
if (!this.called || !proxy.called) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.callIds[this.callCount - 1] > proxy.callIds[0];
|
||||
},
|
||||
|
||||
calledImmediatelyBefore: function calledImmediatelyBefore(proxy) {
|
||||
if (!this.called || !proxy.called) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.callIds[this.callCount - 1] === proxy.callIds[proxy.callCount - 1] - 1;
|
||||
},
|
||||
|
||||
calledImmediatelyAfter: function calledImmediatelyAfter(proxy) {
|
||||
if (!this.called || !proxy.called) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.callIds[this.callCount - 1] === proxy.callIds[proxy.callCount - 1] + 1;
|
||||
},
|
||||
|
||||
formatters: require("./spy-formatters"),
|
||||
printf: function(format) {
|
||||
var spyInstance = this;
|
||||
var args = slice(arguments, 1);
|
||||
var formatter;
|
||||
|
||||
return (format || "").replace(/%(.)/g, function(match, specifyer) {
|
||||
formatter = proxyApi.formatters[specifyer];
|
||||
|
||||
if (typeof formatter === "function") {
|
||||
return String(formatter(spyInstance, args));
|
||||
} else if (!isNaN(parseInt(specifyer, 10))) {
|
||||
return sinonFormat(args[specifyer - 1]);
|
||||
}
|
||||
|
||||
return "%" + specifyer;
|
||||
});
|
||||
},
|
||||
|
||||
resetHistory: function() {
|
||||
if (this.invoking) {
|
||||
var err = new Error(
|
||||
"Cannot reset Sinon function while invoking it. " +
|
||||
"Move the call to .resetHistory outside of the callback."
|
||||
);
|
||||
err.name = "InvalidResetException";
|
||||
throw err;
|
||||
}
|
||||
|
||||
this.called = false;
|
||||
this.notCalled = true;
|
||||
this.calledOnce = false;
|
||||
this.calledTwice = false;
|
||||
this.calledThrice = false;
|
||||
this.callCount = 0;
|
||||
this.firstCall = null;
|
||||
this.secondCall = null;
|
||||
this.thirdCall = null;
|
||||
this.lastCall = null;
|
||||
this.args = [];
|
||||
this.firstArg = null;
|
||||
this.lastArg = null;
|
||||
this.returnValues = [];
|
||||
this.thisValues = [];
|
||||
this.exceptions = [];
|
||||
this.callIds = [];
|
||||
this.errorsWithCallStack = [];
|
||||
|
||||
if (this.fakes) {
|
||||
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, "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, "threw", true);
|
||||
delegateToCalls(proxyApi, "alwaysThrew", false, "threw");
|
||||
delegateToCalls(proxyApi, "returned", true);
|
||||
delegateToCalls(proxyApi, "alwaysReturned", false, "returned");
|
||||
delegateToCalls(proxyApi, "calledWithNew", true);
|
||||
delegateToCalls(proxyApi, "alwaysCalledWithNew", false, "calledWithNew");
|
||||
|
||||
function createProxy(func, originalFunc) {
|
||||
var proxy = wrapFunction(func, originalFunc);
|
||||
|
||||
// Inherit function properties:
|
||||
extend(proxy, func);
|
||||
|
||||
proxy.prototype = func.prototype;
|
||||
|
||||
extend.nonEnum(proxy, proxyApi);
|
||||
|
||||
return proxy;
|
||||
}
|
||||
|
||||
function wrapFunction(func, originalFunc) {
|
||||
var arity = originalFunc.length;
|
||||
var p;
|
||||
// Do not change this to use an eval. Projects that depend on sinon block the use of eval.
|
||||
// ref: https://github.com/sinonjs/sinon/issues/710
|
||||
switch (arity) {
|
||||
/*eslint-disable no-unused-vars, max-len*/
|
||||
case 0:
|
||||
p = function proxy() {
|
||||
return p.invoke(func, this, slice(arguments));
|
||||
};
|
||||
break;
|
||||
case 1:
|
||||
p = function proxy(a) {
|
||||
return p.invoke(func, this, slice(arguments));
|
||||
};
|
||||
break;
|
||||
case 2:
|
||||
p = function proxy(a, b) {
|
||||
return p.invoke(func, this, slice(arguments));
|
||||
};
|
||||
break;
|
||||
case 3:
|
||||
p = function proxy(a, b, c) {
|
||||
return p.invoke(func, this, slice(arguments));
|
||||
};
|
||||
break;
|
||||
case 4:
|
||||
p = function proxy(a, b, c, d) {
|
||||
return p.invoke(func, this, slice(arguments));
|
||||
};
|
||||
break;
|
||||
case 5:
|
||||
p = function proxy(a, b, c, d, e) {
|
||||
return p.invoke(func, this, slice(arguments));
|
||||
};
|
||||
break;
|
||||
case 6:
|
||||
p = function proxy(a, b, c, d, e, f) {
|
||||
return p.invoke(func, this, slice(arguments));
|
||||
};
|
||||
break;
|
||||
case 7:
|
||||
p = function proxy(a, b, c, d, e, f, g) {
|
||||
return p.invoke(func, this, slice(arguments));
|
||||
};
|
||||
break;
|
||||
case 8:
|
||||
p = function proxy(a, b, c, d, e, f, g, h) {
|
||||
return p.invoke(func, this, slice(arguments));
|
||||
};
|
||||
break;
|
||||
case 9:
|
||||
p = function proxy(a, b, c, d, e, f, g, h, i) {
|
||||
return p.invoke(func, this, slice(arguments));
|
||||
};
|
||||
break;
|
||||
case 10:
|
||||
p = function proxy(a, b, c, d, e, f, g, h, i, j) {
|
||||
return p.invoke(func, this, slice(arguments));
|
||||
};
|
||||
break;
|
||||
case 11:
|
||||
p = function proxy(a, b, c, d, e, f, g, h, i, j, k) {
|
||||
return p.invoke(func, this, slice(arguments));
|
||||
};
|
||||
break;
|
||||
case 12:
|
||||
p = function proxy(a, b, c, d, e, f, g, h, i, j, k, l) {
|
||||
return p.invoke(func, this, slice(arguments));
|
||||
};
|
||||
break;
|
||||
default:
|
||||
p = function proxy() {
|
||||
return p.invoke(func, this, slice(arguments));
|
||||
};
|
||||
break;
|
||||
/*eslint-enable*/
|
||||
}
|
||||
var nameDescriptor = Object.getOwnPropertyDescriptor(originalFunc, "name");
|
||||
if (nameDescriptor && nameDescriptor.configurable) {
|
||||
// IE 11 functions don't have a name.
|
||||
// Safari 9 has names that are not configurable.
|
||||
Object.defineProperty(p, "name", nameDescriptor);
|
||||
}
|
||||
extend.nonEnum(p, {
|
||||
isSinonProxy: true,
|
||||
|
||||
called: false,
|
||||
notCalled: true,
|
||||
calledOnce: false,
|
||||
calledTwice: false,
|
||||
calledThrice: false,
|
||||
callCount: 0,
|
||||
firstCall: null,
|
||||
firstArg: null,
|
||||
secondCall: null,
|
||||
thirdCall: null,
|
||||
lastCall: null,
|
||||
lastArg: null,
|
||||
args: [],
|
||||
returnValues: [],
|
||||
thisValues: [],
|
||||
exceptions: [],
|
||||
callIds: [],
|
||||
errorsWithCallStack: []
|
||||
});
|
||||
return p;
|
||||
}
|
||||
|
||||
module.exports = createProxy;
|
||||
17
node_modules/sinon/lib/sinon/restore-object.js
generated
vendored
Normal file
17
node_modules/sinon/lib/sinon/restore-object.js
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
"use strict";
|
||||
|
||||
var walkObject = require("./util/core/walk-object");
|
||||
|
||||
function filter(object, property) {
|
||||
return object[property].restore && object[property].restore.sinon;
|
||||
}
|
||||
|
||||
function restore(object, property) {
|
||||
object[property].restore();
|
||||
}
|
||||
|
||||
function restoreObject(object) {
|
||||
return walkObject(restore, object, filter);
|
||||
}
|
||||
|
||||
module.exports = restoreObject;
|
||||
416
node_modules/sinon/lib/sinon/sandbox.js
generated
vendored
Normal file
416
node_modules/sinon/lib/sinon/sandbox.js
generated
vendored
Normal file
|
|
@ -0,0 +1,416 @@
|
|||
"use strict";
|
||||
|
||||
var arrayProto = require("@sinonjs/commons").prototypes.array;
|
||||
var collectOwnMethods = require("./collect-own-methods");
|
||||
var getPropertyDescriptor = require("./util/core/get-property-descriptor");
|
||||
var isPropertyConfigurable = require("./util/core/is-property-configurable");
|
||||
var match = require("@sinonjs/samsam").createMatcher;
|
||||
var sinonAssert = require("./assert");
|
||||
var sinonClock = require("./util/fake-timers");
|
||||
var sinonMock = require("./mock");
|
||||
var sinonSpy = require("./spy");
|
||||
var sinonStub = require("./stub");
|
||||
var sinonFake = require("./fake");
|
||||
var valueToString = require("@sinonjs/commons").valueToString;
|
||||
var fakeServer = require("nise").fakeServer;
|
||||
var fakeXhr = require("nise").fakeXhr;
|
||||
var usePromiseLibrary = require("./util/core/use-promise-library");
|
||||
|
||||
var filter = arrayProto.filter;
|
||||
var forEach = arrayProto.filter;
|
||||
var push = arrayProto.push;
|
||||
var reverse = arrayProto.reverse;
|
||||
|
||||
function applyOnEach(fakes, method) {
|
||||
var matchingFakes = filter(fakes, function(fake) {
|
||||
return typeof fake[method] === "function";
|
||||
});
|
||||
|
||||
forEach(matchingFakes, function(fake) {
|
||||
fake[method]();
|
||||
});
|
||||
}
|
||||
|
||||
function Sandbox() {
|
||||
var sandbox = this;
|
||||
var collection = [];
|
||||
var fakeRestorers = [];
|
||||
var promiseLib;
|
||||
|
||||
sandbox.serverPrototype = fakeServer;
|
||||
|
||||
// this is for testing only
|
||||
sandbox.getFakes = function getFakes() {
|
||||
return collection;
|
||||
};
|
||||
|
||||
// this is for testing only
|
||||
sandbox.getRestorers = function() {
|
||||
return fakeRestorers;
|
||||
};
|
||||
|
||||
sandbox.createStubInstance = function createStubInstance() {
|
||||
var stubbed = sinonStub.createStubInstance.apply(null, arguments);
|
||||
|
||||
var ownMethods = collectOwnMethods(stubbed);
|
||||
|
||||
forEach(ownMethods, function(method) {
|
||||
push(collection, method);
|
||||
});
|
||||
|
||||
usePromiseLibrary(promiseLib, ownMethods);
|
||||
|
||||
return stubbed;
|
||||
};
|
||||
|
||||
sandbox.inject = function inject(obj) {
|
||||
obj.spy = function() {
|
||||
return sandbox.spy.apply(null, arguments);
|
||||
};
|
||||
|
||||
obj.stub = function() {
|
||||
return sandbox.stub.apply(null, arguments);
|
||||
};
|
||||
|
||||
obj.mock = function() {
|
||||
return sandbox.mock.apply(null, arguments);
|
||||
};
|
||||
|
||||
obj.createStubInstance = function() {
|
||||
return sandbox.createStubInstance.apply(sandbox, arguments);
|
||||
};
|
||||
|
||||
obj.fake = function() {
|
||||
return sandbox.fake.apply(null, arguments);
|
||||
};
|
||||
|
||||
obj.replace = function() {
|
||||
return sandbox.replace.apply(null, arguments);
|
||||
};
|
||||
|
||||
obj.replaceSetter = function() {
|
||||
return sandbox.replaceSetter.apply(null, arguments);
|
||||
};
|
||||
|
||||
obj.replaceGetter = function() {
|
||||
return sandbox.replaceGetter.apply(null, arguments);
|
||||
};
|
||||
|
||||
if (sandbox.clock) {
|
||||
obj.clock = sandbox.clock;
|
||||
}
|
||||
|
||||
if (sandbox.server) {
|
||||
obj.server = sandbox.server;
|
||||
obj.requests = sandbox.server.requests;
|
||||
}
|
||||
|
||||
obj.match = match;
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
sandbox.mock = function mock() {
|
||||
var m = sinonMock.apply(null, arguments);
|
||||
|
||||
push(collection, m);
|
||||
usePromiseLibrary(promiseLib, m);
|
||||
|
||||
return m;
|
||||
};
|
||||
|
||||
sandbox.reset = function reset() {
|
||||
applyOnEach(collection, "reset");
|
||||
applyOnEach(collection, "resetHistory");
|
||||
};
|
||||
|
||||
sandbox.resetBehavior = function resetBehavior() {
|
||||
applyOnEach(collection, "resetBehavior");
|
||||
};
|
||||
|
||||
sandbox.resetHistory = function resetHistory() {
|
||||
function privateResetHistory(f) {
|
||||
var method = f.resetHistory || f.reset;
|
||||
if (method) {
|
||||
method.call(f);
|
||||
}
|
||||
}
|
||||
|
||||
forEach(collection, function(fake) {
|
||||
if (typeof fake === "function") {
|
||||
privateResetHistory(fake);
|
||||
return;
|
||||
}
|
||||
|
||||
var methods = [];
|
||||
if (fake.get) {
|
||||
push(methods, fake.get);
|
||||
}
|
||||
|
||||
if (fake.set) {
|
||||
push(methods, fake.set);
|
||||
}
|
||||
|
||||
forEach(methods, privateResetHistory);
|
||||
});
|
||||
};
|
||||
|
||||
sandbox.restore = function restore() {
|
||||
if (arguments.length) {
|
||||
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) {
|
||||
restorer();
|
||||
});
|
||||
fakeRestorers = [];
|
||||
|
||||
sandbox.restoreContext();
|
||||
};
|
||||
|
||||
sandbox.restoreContext = function restoreContext() {
|
||||
var injectedKeys = sandbox.injectedKeys;
|
||||
var injectInto = sandbox.injectInto;
|
||||
|
||||
if (!injectedKeys) {
|
||||
return;
|
||||
}
|
||||
|
||||
forEach(injectedKeys, function(injectedKey) {
|
||||
delete injectInto[injectedKey];
|
||||
});
|
||||
|
||||
injectedKeys = [];
|
||||
};
|
||||
|
||||
function getFakeRestorer(object, property) {
|
||||
var descriptor = getPropertyDescriptor(object, property);
|
||||
|
||||
function restorer() {
|
||||
if (descriptor.isOwn) {
|
||||
Object.defineProperty(object, property, descriptor);
|
||||
} else {
|
||||
delete object[property];
|
||||
}
|
||||
}
|
||||
restorer.object = object;
|
||||
restorer.property = property;
|
||||
return restorer;
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
sandbox.replace = function replace(object, property, replacement) {
|
||||
var descriptor = getPropertyDescriptor(object, property);
|
||||
|
||||
if (typeof descriptor === "undefined") {
|
||||
throw new TypeError("Cannot replace non-existent property " + valueToString(property));
|
||||
}
|
||||
|
||||
if (typeof replacement === "undefined") {
|
||||
throw new TypeError("Expected replacement argument to be defined");
|
||||
}
|
||||
|
||||
if (typeof descriptor.get === "function") {
|
||||
throw new Error("Use sandbox.replaceGetter for replacing getters");
|
||||
}
|
||||
|
||||
if (typeof descriptor.set === "function") {
|
||||
throw new Error("Use sandbox.replaceSetter for replacing setters");
|
||||
}
|
||||
|
||||
if (typeof object[property] !== typeof replacement) {
|
||||
throw new TypeError("Cannot replace " + typeof object[property] + " with " + typeof replacement);
|
||||
}
|
||||
|
||||
verifyNotReplaced(object, property);
|
||||
|
||||
// store a function for restoring the replaced property
|
||||
push(fakeRestorers, getFakeRestorer(object, property));
|
||||
|
||||
object[property] = replacement;
|
||||
|
||||
return 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));
|
||||
}
|
||||
|
||||
if (typeof replacement !== "function") {
|
||||
throw new TypeError("Expected replacement argument to be a function");
|
||||
}
|
||||
|
||||
if (typeof descriptor.get !== "function") {
|
||||
throw new Error("`object.property` is not a getter");
|
||||
}
|
||||
|
||||
verifyNotReplaced(object, property);
|
||||
|
||||
// store a function for restoring the replaced property
|
||||
push(fakeRestorers, getFakeRestorer(object, property));
|
||||
|
||||
Object.defineProperty(object, property, {
|
||||
get: replacement,
|
||||
configurable: isPropertyConfigurable(object, property)
|
||||
});
|
||||
|
||||
return 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));
|
||||
}
|
||||
|
||||
if (typeof replacement !== "function") {
|
||||
throw new TypeError("Expected replacement argument to be a function");
|
||||
}
|
||||
|
||||
if (typeof descriptor.set !== "function") {
|
||||
throw new Error("`object.property` is not a setter");
|
||||
}
|
||||
|
||||
verifyNotReplaced(object, property);
|
||||
|
||||
// store a function for restoring the replaced property
|
||||
push(fakeRestorers, getFakeRestorer(object, property));
|
||||
|
||||
// eslint-disable-next-line accessor-pairs
|
||||
Object.defineProperty(object, property, {
|
||||
set: replacement,
|
||||
configurable: isPropertyConfigurable(object, property)
|
||||
});
|
||||
|
||||
return replacement;
|
||||
};
|
||||
|
||||
function commonPostInitSetup(args, spy) {
|
||||
var object = args[0];
|
||||
var property = args[1];
|
||||
|
||||
var isSpyingOnEntireObject = typeof property === "undefined" && typeof object === "object";
|
||||
|
||||
if (isSpyingOnEntireObject) {
|
||||
var ownMethods = collectOwnMethods(spy);
|
||||
|
||||
forEach(ownMethods, function(method) {
|
||||
push(collection, method);
|
||||
});
|
||||
|
||||
usePromiseLibrary(promiseLib, ownMethods);
|
||||
} else {
|
||||
push(collection, spy);
|
||||
usePromiseLibrary(promiseLib, spy);
|
||||
}
|
||||
|
||||
return spy;
|
||||
}
|
||||
|
||||
sandbox.spy = function spy() {
|
||||
var createdSpy = sinonSpy.apply(sinonSpy, arguments);
|
||||
return commonPostInitSetup(arguments, createdSpy);
|
||||
};
|
||||
|
||||
sandbox.stub = function stub() {
|
||||
var createdStub = sinonStub.apply(sinonStub, arguments);
|
||||
return commonPostInitSetup(arguments, createdStub);
|
||||
};
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
sandbox.fake = function fake(f) {
|
||||
var s = sinonFake.apply(sinonFake, arguments);
|
||||
|
||||
push(collection, s);
|
||||
|
||||
return s;
|
||||
};
|
||||
|
||||
forEach(Object.keys(sinonFake), function(key) {
|
||||
var fakeBehavior = sinonFake[key];
|
||||
if (typeof fakeBehavior === "function") {
|
||||
sandbox.fake[key] = function() {
|
||||
var s = fakeBehavior.apply(fakeBehavior, arguments);
|
||||
|
||||
push(collection, s);
|
||||
|
||||
return s;
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
sandbox.useFakeTimers = function useFakeTimers(args) {
|
||||
var clock = sinonClock.useFakeTimers.call(null, args);
|
||||
|
||||
sandbox.clock = clock;
|
||||
push(collection, clock);
|
||||
|
||||
return clock;
|
||||
};
|
||||
|
||||
sandbox.verify = function verify() {
|
||||
applyOnEach(collection, "verify");
|
||||
};
|
||||
|
||||
sandbox.verifyAndRestore = function verifyAndRestore() {
|
||||
var exception;
|
||||
|
||||
try {
|
||||
sandbox.verify();
|
||||
} catch (e) {
|
||||
exception = e;
|
||||
}
|
||||
|
||||
sandbox.restore();
|
||||
|
||||
if (exception) {
|
||||
throw exception;
|
||||
}
|
||||
};
|
||||
|
||||
sandbox.useFakeServer = function useFakeServer() {
|
||||
var proto = sandbox.serverPrototype || fakeServer;
|
||||
|
||||
if (!proto || !proto.create) {
|
||||
return null;
|
||||
}
|
||||
|
||||
sandbox.server = proto.create();
|
||||
push(collection, sandbox.server);
|
||||
|
||||
return sandbox.server;
|
||||
};
|
||||
|
||||
sandbox.useFakeXMLHttpRequest = function useFakeXMLHttpRequest() {
|
||||
var xhr = fakeXhr.useFakeXMLHttpRequest();
|
||||
push(collection, xhr);
|
||||
return xhr;
|
||||
};
|
||||
|
||||
sandbox.usingPromise = function usingPromise(promiseLibrary) {
|
||||
promiseLib = promiseLibrary;
|
||||
collection.promiseLibrary = promiseLibrary;
|
||||
|
||||
return sandbox;
|
||||
};
|
||||
}
|
||||
|
||||
Sandbox.prototype.assert = sinonAssert;
|
||||
Sandbox.prototype.match = match;
|
||||
|
||||
module.exports = Sandbox;
|
||||
109
node_modules/sinon/lib/sinon/spy-formatters.js
generated
vendored
Normal file
109
node_modules/sinon/lib/sinon/spy-formatters.js
generated
vendored
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
"use strict";
|
||||
|
||||
var arrayProto = require("@sinonjs/commons").prototypes.array;
|
||||
var color = require("./color");
|
||||
var match = require("@sinonjs/samsam").createMatcher;
|
||||
var timesInWords = require("./util/core/times-in-words");
|
||||
var sinonFormat = require("./util/core/format");
|
||||
var jsDiff = require("diff");
|
||||
|
||||
var join = arrayProto.join;
|
||||
var map = arrayProto.map;
|
||||
var push = arrayProto.push;
|
||||
|
||||
function colorSinonMatchText(matcher, calledArg, calledArgMessage) {
|
||||
var calledArgumentMessage = calledArgMessage;
|
||||
if (!matcher.test(calledArg)) {
|
||||
matcher.message = color.red(matcher.message);
|
||||
if (calledArgumentMessage) {
|
||||
calledArgumentMessage = color.green(calledArgumentMessage);
|
||||
}
|
||||
}
|
||||
return calledArgumentMessage + " " + matcher.message;
|
||||
}
|
||||
|
||||
function colorDiffText(diff) {
|
||||
var objects = map(diff, function(part) {
|
||||
var text = part.value;
|
||||
if (part.added) {
|
||||
text = color.green(text);
|
||||
} else if (part.removed) {
|
||||
text = color.red(text);
|
||||
}
|
||||
if (diff.length === 2) {
|
||||
text += " "; // format simple diffs
|
||||
}
|
||||
return text;
|
||||
});
|
||||
return join(objects, "");
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
c: function(spyInstance) {
|
||||
return timesInWords(spyInstance.callCount);
|
||||
},
|
||||
|
||||
n: function(spyInstance) {
|
||||
// eslint-disable-next-line local-rules/no-prototype-methods
|
||||
return spyInstance.toString();
|
||||
},
|
||||
|
||||
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) + ":";
|
||||
}
|
||||
var calledArgs = spyInstance.getCall(i).args;
|
||||
for (var j = 0; j < calledArgs.length || j < args.length; ++j) {
|
||||
message += "\n";
|
||||
var calledArgMessage = j < calledArgs.length ? sinonFormat(calledArgs[j]) : "";
|
||||
if (match.isMatcher(args[j])) {
|
||||
message += colorSinonMatchText(args[j], calledArgs[j], calledArgMessage);
|
||||
} else {
|
||||
var expectedArgMessage = j < args.length ? sinonFormat(args[j]) : "";
|
||||
var diff = jsDiff.diffJson(calledArgMessage, expectedArgMessage);
|
||||
message += colorDiffText(diff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return message;
|
||||
},
|
||||
|
||||
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();
|
||||
if (/\n/.test(calls[i - 1])) {
|
||||
stringifiedCall = "\n" + stringifiedCall;
|
||||
}
|
||||
push(calls, stringifiedCall);
|
||||
}
|
||||
|
||||
return calls.length > 0 ? "\n" + join(calls, "\n") : "";
|
||||
},
|
||||
|
||||
t: function(spyInstance) {
|
||||
var objects = [];
|
||||
|
||||
for (var i = 0, l = spyInstance.callCount; i < l; ++i) {
|
||||
push(objects, sinonFormat(spyInstance.thisValues[i]));
|
||||
}
|
||||
|
||||
return join(objects, ", ");
|
||||
},
|
||||
|
||||
"*": function(spyInstance, args) {
|
||||
return join(
|
||||
map(args, function(arg) {
|
||||
return sinonFormat(arg);
|
||||
}),
|
||||
", "
|
||||
);
|
||||
}
|
||||
};
|
||||
171
node_modules/sinon/lib/sinon/spy.js
generated
vendored
Normal file
171
node_modules/sinon/lib/sinon/spy.js
generated
vendored
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
"use strict";
|
||||
|
||||
var arrayProto = require("@sinonjs/commons").prototypes.array;
|
||||
var createProxy = require("./proxy");
|
||||
var extend = require("./util/core/extend");
|
||||
var functionName = require("@sinonjs/commons").functionName;
|
||||
var getPropertyDescriptor = require("./util/core/get-property-descriptor");
|
||||
var deepEqual = require("@sinonjs/samsam").deepEqual;
|
||||
var isEsModule = require("./util/core/is-es-module");
|
||||
var proxyCallUtil = require("./proxy-call-util");
|
||||
var walkObject = require("./util/core/walk-object");
|
||||
var wrapMethod = require("./util/core/wrap-method");
|
||||
var valueToString = require("@sinonjs/commons").valueToString;
|
||||
|
||||
/* cache references to library methods so that they also can be stubbed without problems */
|
||||
var forEach = arrayProto.forEach;
|
||||
var pop = arrayProto.pop;
|
||||
var push = arrayProto.push;
|
||||
var slice = arrayProto.slice;
|
||||
var filter = Array.prototype.filter;
|
||||
|
||||
var uuid = 0;
|
||||
|
||||
function matches(fake, args, strict) {
|
||||
var margs = fake.matchingArguments;
|
||||
if (margs.length <= args.length && deepEqual(slice(args, 0, margs.length), margs)) {
|
||||
return !strict || margs.length === args.length;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Public API
|
||||
var spyApi = {
|
||||
withArgs: function() {
|
||||
var args = slice(arguments);
|
||||
var matching = pop(this.matchingFakes(args, true));
|
||||
if (matching) {
|
||||
return matching;
|
||||
}
|
||||
|
||||
var original = this;
|
||||
var fake = this.instantiateFake();
|
||||
fake.matchingArguments = args;
|
||||
fake.parent = this;
|
||||
push(this.fakes, fake);
|
||||
|
||||
fake.withArgs = function() {
|
||||
return original.withArgs.apply(original, arguments);
|
||||
};
|
||||
|
||||
forEach(original.args, function(arg, i) {
|
||||
if (!matches(fake, arg)) {
|
||||
return;
|
||||
}
|
||||
|
||||
proxyCallUtil.incrementCallCount(fake);
|
||||
push(fake.thisValues, original.thisValues[i]);
|
||||
push(fake.args, arg);
|
||||
push(fake.returnValues, original.returnValues[i]);
|
||||
push(fake.exceptions, original.exceptions[i]);
|
||||
push(fake.callIds, original.callIds[i]);
|
||||
});
|
||||
|
||||
proxyCallUtil.createCallProperties(fake);
|
||||
|
||||
return fake;
|
||||
},
|
||||
|
||||
// Override proxy default implementation
|
||||
matchingFakes: function(args, strict) {
|
||||
return filter.call(this.fakes, function(fake) {
|
||||
return matches(fake, args, strict);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/* eslint-disable local-rules/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.");
|
||||
});
|
||||
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.");
|
||||
});
|
||||
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, "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) {
|
||||
throw new Error(
|
||||
this.toString() + " cannot yield to '" + valueToString(property) + "' since it was not yet invoked."
|
||||
);
|
||||
});
|
||||
delegateToCalls(spyApi, "yieldToOn", false, "yieldToOn", true, function(property) {
|
||||
throw new Error(
|
||||
this.toString() + " cannot yield to '" + valueToString(property) + "' since it was not yet invoked."
|
||||
);
|
||||
});
|
||||
/* eslint-enable local-rules/no-prototype-methods */
|
||||
|
||||
function createSpy(func) {
|
||||
var name;
|
||||
var funk = func;
|
||||
|
||||
if (typeof funk !== "function") {
|
||||
funk = function() {
|
||||
return;
|
||||
};
|
||||
} else {
|
||||
name = functionName(funk);
|
||||
}
|
||||
|
||||
var proxy = createProxy(funk, funk);
|
||||
|
||||
// Inherit spy API:
|
||||
extend.nonEnum(proxy, spyApi);
|
||||
extend.nonEnum(proxy, {
|
||||
displayName: name || "spy",
|
||||
fakes: [],
|
||||
instantiateFake: createSpy,
|
||||
id: "spy#" + uuid++
|
||||
});
|
||||
return proxy;
|
||||
}
|
||||
|
||||
function spy(object, property, types) {
|
||||
var descriptor, methodDesc;
|
||||
|
||||
if (isEsModule(object)) {
|
||||
throw new TypeError("ES Modules cannot be spied");
|
||||
}
|
||||
|
||||
if (!property && typeof object === "function") {
|
||||
return createSpy(object);
|
||||
}
|
||||
|
||||
if (!property && typeof object === "object") {
|
||||
return walkObject(spy, object);
|
||||
}
|
||||
|
||||
if (!object && !property) {
|
||||
return createSpy(function() {
|
||||
return;
|
||||
});
|
||||
}
|
||||
|
||||
if (!types) {
|
||||
return wrapMethod(object, property, createSpy(object[property]));
|
||||
}
|
||||
|
||||
descriptor = {};
|
||||
methodDesc = getPropertyDescriptor(object, property);
|
||||
|
||||
forEach(types, function(type) {
|
||||
descriptor[type] = createSpy(methodDesc[type]);
|
||||
});
|
||||
|
||||
return wrapMethod(object, property, descriptor);
|
||||
}
|
||||
|
||||
extend(spy, spyApi);
|
||||
module.exports = spy;
|
||||
222
node_modules/sinon/lib/sinon/stub.js
generated
vendored
Normal file
222
node_modules/sinon/lib/sinon/stub.js
generated
vendored
Normal file
|
|
@ -0,0 +1,222 @@
|
|||
"use strict";
|
||||
|
||||
var arrayProto = require("@sinonjs/commons").prototypes.array;
|
||||
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 isNonExistentProperty = require("./util/core/is-non-existent-property");
|
||||
var spy = require("./spy");
|
||||
var extend = require("./util/core/extend");
|
||||
var getPropertyDescriptor = require("./util/core/get-property-descriptor");
|
||||
var isEsModule = require("./util/core/is-es-module");
|
||||
var wrapMethod = require("./util/core/wrap-method");
|
||||
var throwOnFalsyObject = require("./throw-on-falsy-object");
|
||||
var valueToString = require("@sinonjs/commons").valueToString;
|
||||
var walkObject = require("./util/core/walk-object");
|
||||
|
||||
var forEach = arrayProto.forEach;
|
||||
var pop = arrayProto.pop;
|
||||
var slice = arrayProto.slice;
|
||||
var sort = arrayProto.sort;
|
||||
|
||||
var uuid = 0;
|
||||
|
||||
function createStub(originalFunc) {
|
||||
var proxy;
|
||||
|
||||
function functionStub() {
|
||||
var args = slice(arguments);
|
||||
var matchings = proxy.matchingFakes(args);
|
||||
|
||||
var fnStub =
|
||||
pop(
|
||||
sort(matchings, function(a, b) {
|
||||
return a.matchingArguments.length - b.matchingArguments.length;
|
||||
})
|
||||
) || proxy;
|
||||
return getCurrentBehavior(fnStub).invoke(this, arguments);
|
||||
}
|
||||
|
||||
proxy = createProxy(functionStub, originalFunc || functionStub);
|
||||
// Inherit spy API:
|
||||
extend.nonEnum(proxy, spy);
|
||||
// Inherit stub API:
|
||||
extend.nonEnum(proxy, stub);
|
||||
|
||||
var name = originalFunc ? functionName(originalFunc) : null;
|
||||
extend.nonEnum(proxy, {
|
||||
fakes: [],
|
||||
instantiateFake: createStub,
|
||||
displayName: name || "stub",
|
||||
defaultBehavior: null,
|
||||
behaviors: [],
|
||||
id: "stub#" + uuid++
|
||||
});
|
||||
|
||||
return proxy;
|
||||
}
|
||||
|
||||
function stub(object, property) {
|
||||
if (arguments.length > 2) {
|
||||
throw new TypeError("stub(obj, 'meth', fn) has been removed, see documentation");
|
||||
}
|
||||
|
||||
if (isEsModule(object)) {
|
||||
throw new TypeError("ES Modules cannot be stubbed");
|
||||
}
|
||||
|
||||
throwOnFalsyObject.apply(null, arguments);
|
||||
|
||||
if (isNonExistentProperty(object, 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 isCreatingNewStub = !object && typeof property === "undefined";
|
||||
var isStubbingNonFuncProperty =
|
||||
isObjectOrFunction &&
|
||||
typeof property !== "undefined" &&
|
||||
(typeof actualDescriptor === "undefined" || typeof actualDescriptor.value !== "function") &&
|
||||
typeof descriptor === "undefined";
|
||||
|
||||
if (isStubbingEntireObject) {
|
||||
return walkObject(stub, object);
|
||||
}
|
||||
|
||||
if (isCreatingNewStub) {
|
||||
return createStub();
|
||||
}
|
||||
|
||||
var func = typeof actualDescriptor.value === "function" ? actualDescriptor.value : null;
|
||||
var s = createStub(func);
|
||||
|
||||
extend.nonEnum(s, {
|
||||
rootObj: object,
|
||||
propName: property,
|
||||
shadowsPropOnPrototype: !actualDescriptor.isOwn,
|
||||
restore: function restore() {
|
||||
if (actualDescriptor !== undefined && actualDescriptor.isOwn) {
|
||||
Object.defineProperty(object, property, actualDescriptor);
|
||||
return;
|
||||
}
|
||||
|
||||
delete object[property];
|
||||
}
|
||||
});
|
||||
|
||||
return isStubbingNonFuncProperty ? s : wrapMethod(object, property, s);
|
||||
}
|
||||
|
||||
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) {
|
||||
if (propertyName in stubbedObject) {
|
||||
var value = overrides[propertyName];
|
||||
if (value && value.createStubInstance) {
|
||||
stubbedObject[propertyName] = value;
|
||||
} else {
|
||||
stubbedObject[propertyName].returns(value);
|
||||
}
|
||||
} else {
|
||||
throw new Error("Cannot stub " + propertyName + ". Property does not exist!");
|
||||
}
|
||||
});
|
||||
return stubbedObject;
|
||||
};
|
||||
|
||||
/*eslint-disable no-use-before-define*/
|
||||
function getParentBehaviour(stubInstance) {
|
||||
return stubInstance.parent && getCurrentBehavior(stubInstance.parent);
|
||||
}
|
||||
|
||||
function getDefaultBehavior(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);
|
||||
}
|
||||
/*eslint-enable no-use-before-define*/
|
||||
|
||||
var proto = {
|
||||
resetBehavior: function() {
|
||||
this.defaultBehavior = null;
|
||||
this.behaviors = [];
|
||||
|
||||
delete this.returnValue;
|
||||
delete this.returnArgAt;
|
||||
delete this.throwArgAt;
|
||||
delete this.resolveArgAt;
|
||||
delete this.fakeFn;
|
||||
this.returnThis = false;
|
||||
this.resolveThis = false;
|
||||
|
||||
forEach(this.fakes, function(fake) {
|
||||
fake.resetBehavior();
|
||||
});
|
||||
},
|
||||
|
||||
reset: function() {
|
||||
this.resetHistory();
|
||||
this.resetBehavior();
|
||||
},
|
||||
|
||||
onCall: function onCall(index) {
|
||||
if (!this.behaviors[index]) {
|
||||
this.behaviors[index] = behavior.create(this);
|
||||
}
|
||||
|
||||
return this.behaviors[index];
|
||||
},
|
||||
|
||||
onFirstCall: function onFirstCall() {
|
||||
return this.onCall(0);
|
||||
},
|
||||
|
||||
onSecondCall: function onSecondCall() {
|
||||
return this.onCall(1);
|
||||
},
|
||||
|
||||
onThirdCall: function onThirdCall() {
|
||||
return this.onCall(2);
|
||||
},
|
||||
|
||||
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;
|
||||
}
|
||||
return fake;
|
||||
}
|
||||
};
|
||||
|
||||
forEach(Object.keys(behavior), function(method) {
|
||||
if (
|
||||
hasOwnProperty(behavior, method) &&
|
||||
!hasOwnProperty(proto, method) &&
|
||||
method !== "create" &&
|
||||
method !== "invoke"
|
||||
) {
|
||||
proto[method] = behavior.createBehavior(method);
|
||||
}
|
||||
});
|
||||
|
||||
forEach(Object.keys(behaviors), function(method) {
|
||||
if (hasOwnProperty(behaviors, method) && !hasOwnProperty(proto, method)) {
|
||||
behavior.addBehavior(stub, method, behaviors[method]);
|
||||
}
|
||||
});
|
||||
|
||||
extend(stub, proto);
|
||||
module.exports = stub;
|
||||
11
node_modules/sinon/lib/sinon/throw-on-falsy-object.js
generated
vendored
Normal file
11
node_modules/sinon/lib/sinon/throw-on-falsy-object.js
generated
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
"use strict";
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = throwOnFalsyObject;
|
||||
20
node_modules/sinon/lib/sinon/util/core/default-config.js
generated
vendored
Normal file
20
node_modules/sinon/lib/sinon/util/core/default-config.js
generated
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
injectInto: null,
|
||||
properties: [
|
||||
"spy",
|
||||
"stub",
|
||||
"mock",
|
||||
"clock",
|
||||
"server",
|
||||
"requests",
|
||||
"fake",
|
||||
"replace",
|
||||
"replaceSetter",
|
||||
"replaceGetter",
|
||||
"createStubInstance"
|
||||
],
|
||||
useFakeTimers: true,
|
||||
useFakeServer: true
|
||||
};
|
||||
22
node_modules/sinon/lib/sinon/util/core/export-async-behaviors.js
generated
vendored
Normal file
22
node_modules/sinon/lib/sinon/util/core/export-async-behaviors.js
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
"use strict";
|
||||
|
||||
var arrayProto = require("@sinonjs/commons").prototypes.array;
|
||||
var reduce = arrayProto.reduce;
|
||||
|
||||
module.exports = function exportAsyncBehaviors(behaviorMethods) {
|
||||
return reduce(
|
||||
Object.keys(behaviorMethods),
|
||||
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() {
|
||||
var result = behaviorMethods[method].apply(this, arguments);
|
||||
this.callbackAsync = true;
|
||||
return result;
|
||||
};
|
||||
}
|
||||
return acc;
|
||||
},
|
||||
{}
|
||||
);
|
||||
};
|
||||
111
node_modules/sinon/lib/sinon/util/core/extend.js
generated
vendored
Normal file
111
node_modules/sinon/lib/sinon/util/core/extend.js
generated
vendored
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
"use strict";
|
||||
|
||||
var arrayProto = require("@sinonjs/commons").prototypes.array;
|
||||
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 obj = {
|
||||
constructor: function() {
|
||||
return "0";
|
||||
},
|
||||
toString: function() {
|
||||
return "1";
|
||||
},
|
||||
valueOf: function() {
|
||||
return "2";
|
||||
},
|
||||
toLocaleString: function() {
|
||||
return "3";
|
||||
},
|
||||
prototype: function() {
|
||||
return "4";
|
||||
},
|
||||
isPrototypeOf: function() {
|
||||
return "5";
|
||||
},
|
||||
propertyIsEnumerable: function() {
|
||||
return "6";
|
||||
},
|
||||
hasOwnProperty: function() {
|
||||
return "7";
|
||||
},
|
||||
length: function() {
|
||||
return "8";
|
||||
},
|
||||
unique: function() {
|
||||
return "9";
|
||||
}
|
||||
};
|
||||
|
||||
var result = [];
|
||||
for (var prop in obj) {
|
||||
if (hasOwnProperty(obj, prop)) {
|
||||
push(result, obj[prop]());
|
||||
}
|
||||
}
|
||||
return join(result, "") !== "0123456789";
|
||||
})();
|
||||
|
||||
function extendCommon(target, sources, doCopy) {
|
||||
var source, i, prop;
|
||||
|
||||
for (i = 0; i < sources.length; i++) {
|
||||
source = sources[i];
|
||||
|
||||
for (prop in source) {
|
||||
if (hasOwnProperty(source, prop)) {
|
||||
doCopy(target, source, prop);
|
||||
}
|
||||
}
|
||||
|
||||
// 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) {
|
||||
target.toString = source.toString;
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
/** Public: Extend target in place with all (own) properties 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.
|
||||
*
|
||||
* @returns {Object} the extended target
|
||||
*/
|
||||
module.exports = function extend(target /*, sources */) {
|
||||
var sources = slice(arguments, 1);
|
||||
|
||||
return extendCommon(target, sources, function copyValue(dest, source, prop) {
|
||||
dest[prop] = source[prop];
|
||||
});
|
||||
};
|
||||
|
||||
/** 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.
|
||||
*
|
||||
* @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
|
||||
});
|
||||
});
|
||||
};
|
||||
28
node_modules/sinon/lib/sinon/util/core/format.js
generated
vendored
Normal file
28
node_modules/sinon/lib/sinon/util/core/format.js
generated
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
"use strict";
|
||||
|
||||
var formatio = require("@sinonjs/formatio");
|
||||
|
||||
var formatter = formatio.configure({
|
||||
quoteStrings: false,
|
||||
limitChildrenCount: 250
|
||||
});
|
||||
|
||||
var customFormatter;
|
||||
|
||||
function format() {
|
||||
if (customFormatter) {
|
||||
return customFormatter.apply(null, arguments);
|
||||
}
|
||||
|
||||
return formatter.ascii.apply(formatter, arguments);
|
||||
}
|
||||
|
||||
format.setFormatter = function(aCustomFormatter) {
|
||||
if (typeof aCustomFormatter !== "function") {
|
||||
throw new Error("format.setFormatter must be called with a function");
|
||||
}
|
||||
|
||||
customFormatter = aCustomFormatter;
|
||||
};
|
||||
|
||||
module.exports = format;
|
||||
25
node_modules/sinon/lib/sinon/util/core/function-to-string.js
generated
vendored
Normal file
25
node_modules/sinon/lib/sinon/util/core/function-to-string.js
generated
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = function toString() {
|
||||
var i, prop, thisValue;
|
||||
if (this.getCall && this.callCount) {
|
||||
i = this.callCount;
|
||||
|
||||
while (i--) {
|
||||
thisValue = this.getCall(i).thisValue;
|
||||
|
||||
// eslint-disable-next-line guard-for-in
|
||||
for (prop in thisValue) {
|
||||
try {
|
||||
if (thisValue[prop] === this) {
|
||||
return prop;
|
||||
}
|
||||
} catch (e) {
|
||||
// no-op - accessing props can throw an error, nothing to do here
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.displayName || "sinon fake";
|
||||
};
|
||||
18
node_modules/sinon/lib/sinon/util/core/get-config.js
generated
vendored
Normal file
18
node_modules/sinon/lib/sinon/util/core/get-config.js
generated
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
"use strict";
|
||||
|
||||
var defaultConfig = require("./default-config");
|
||||
var hasOwnProperty = require("@sinonjs/commons").prototypes.object.hasOwnProperty;
|
||||
|
||||
module.exports = function getConfig(custom) {
|
||||
var config = {};
|
||||
var prop;
|
||||
var kustom = custom || {};
|
||||
|
||||
for (prop in defaultConfig) {
|
||||
if (hasOwnProperty(defaultConfig, prop)) {
|
||||
config[prop] = hasOwnProperty(kustom, prop) ? kustom[prop] : defaultConfig[prop];
|
||||
}
|
||||
}
|
||||
|
||||
return config;
|
||||
};
|
||||
18
node_modules/sinon/lib/sinon/util/core/get-next-tick.js
generated
vendored
Normal file
18
node_modules/sinon/lib/sinon/util/core/get-next-tick.js
generated
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
"use strict";
|
||||
|
||||
/* istanbul ignore next : not testing that setTimeout works */
|
||||
function nextTick(callback) {
|
||||
setTimeout(callback, 0);
|
||||
}
|
||||
|
||||
module.exports = function getNextTick(process, setImmediate) {
|
||||
if (typeof process === "object" && typeof process.nextTick === "function") {
|
||||
return process.nextTick;
|
||||
}
|
||||
|
||||
if (typeof setImmediate === "function") {
|
||||
return setImmediate;
|
||||
}
|
||||
|
||||
return nextTick;
|
||||
};
|
||||
17
node_modules/sinon/lib/sinon/util/core/get-property-descriptor.js
generated
vendored
Normal file
17
node_modules/sinon/lib/sinon/util/core/get-property-descriptor.js
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = function getPropertyDescriptor(object, property) {
|
||||
var proto = object;
|
||||
var descriptor;
|
||||
var isOwn = Boolean(object && Object.getOwnPropertyDescriptor(object, property));
|
||||
|
||||
while (proto && !(descriptor = Object.getOwnPropertyDescriptor(proto, property))) {
|
||||
proto = Object.getPrototypeOf(proto);
|
||||
}
|
||||
|
||||
if (descriptor) {
|
||||
descriptor.isOwn = isOwn;
|
||||
}
|
||||
|
||||
return descriptor;
|
||||
};
|
||||
18
node_modules/sinon/lib/sinon/util/core/is-es-module.js
generated
vendored
Normal file
18
node_modules/sinon/lib/sinon/util/core/is-es-module.js
generated
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
"use strict";
|
||||
|
||||
/**
|
||||
* Verify if an object is a ECMAScript Module
|
||||
*
|
||||
* As the exports from a module is immutable we cannot alter the exports
|
||||
* using spies or stubs. Let the consumer know this to avoid bug reports
|
||||
* on weird error messages.
|
||||
*
|
||||
* @param {Object} object The object to examine
|
||||
*
|
||||
* @returns {Boolean} true when the object is a module
|
||||
*/
|
||||
module.exports = function(object) {
|
||||
return (
|
||||
object && typeof Symbol !== "undefined" && object[Symbol.toStringTag] === "Module" && Object.isSealed(object)
|
||||
);
|
||||
};
|
||||
12
node_modules/sinon/lib/sinon/util/core/is-non-existent-property.js
generated
vendored
Normal file
12
node_modules/sinon/lib/sinon/util/core/is-non-existent-property.js
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
"use strict";
|
||||
|
||||
/**
|
||||
* @param {*} object
|
||||
* @param {String} property
|
||||
* @returns whether a prop exists in the prototype chain
|
||||
*/
|
||||
function isNonExistentProperty(object, property) {
|
||||
return object && typeof property !== "undefined" && !(property in object);
|
||||
}
|
||||
|
||||
module.exports = isNonExistentProperty;
|
||||
11
node_modules/sinon/lib/sinon/util/core/is-property-configurable.js
generated
vendored
Normal file
11
node_modules/sinon/lib/sinon/util/core/is-property-configurable.js
generated
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
"use strict";
|
||||
|
||||
var getPropertyDescriptor = require("./get-property-descriptor");
|
||||
|
||||
function isPropertyConfigurable(obj, propName) {
|
||||
var propertyDescriptor = getPropertyDescriptor(obj, propName);
|
||||
|
||||
return propertyDescriptor ? propertyDescriptor.configurable : true;
|
||||
}
|
||||
|
||||
module.exports = isPropertyConfigurable;
|
||||
7
node_modules/sinon/lib/sinon/util/core/is-restorable.js
generated
vendored
Normal file
7
node_modules/sinon/lib/sinon/util/core/is-restorable.js
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
"use strict";
|
||||
|
||||
function isRestorable(obj) {
|
||||
return typeof obj === "function" && typeof obj.restore === "function" && obj.restore.sinon;
|
||||
}
|
||||
|
||||
module.exports = isRestorable;
|
||||
6
node_modules/sinon/lib/sinon/util/core/next-tick.js
generated
vendored
Normal file
6
node_modules/sinon/lib/sinon/util/core/next-tick.js
generated
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
"use strict";
|
||||
|
||||
var globalObject = require("@sinonjs/commons").global;
|
||||
var getNextTick = require("./get-next-tick");
|
||||
|
||||
module.exports = getNextTick(globalObject.process, globalObject.setImmediate);
|
||||
16
node_modules/sinon/lib/sinon/util/core/restore.js
generated
vendored
Normal file
16
node_modules/sinon/lib/sinon/util/core/restore.js
generated
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
"use strict";
|
||||
|
||||
var isRestorable = require("./is-restorable");
|
||||
var walk = require("./walk");
|
||||
|
||||
module.exports = function restore(object) {
|
||||
if (object !== null && typeof object === "object") {
|
||||
walk(object, function(prop) {
|
||||
if (isRestorable(object[prop])) {
|
||||
object[prop].restore();
|
||||
}
|
||||
});
|
||||
} else if (isRestorable(object)) {
|
||||
object.restore();
|
||||
}
|
||||
};
|
||||
7
node_modules/sinon/lib/sinon/util/core/times-in-words.js
generated
vendored
Normal file
7
node_modules/sinon/lib/sinon/util/core/times-in-words.js
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
"use strict";
|
||||
|
||||
var array = [null, "once", "twice", "thrice"];
|
||||
|
||||
module.exports = function timesInWords(count) {
|
||||
return array[count] || (count || 0) + " times";
|
||||
};
|
||||
21
node_modules/sinon/lib/sinon/util/core/use-promise-library.js
generated
vendored
Normal file
21
node_modules/sinon/lib/sinon/util/core/use-promise-library.js
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
"use strict";
|
||||
|
||||
var forEach = Array.prototype.forEach;
|
||||
|
||||
function usePromiseLibrary(library, fakes) {
|
||||
if (typeof library === "undefined") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Array.isArray(fakes)) {
|
||||
forEach.call(fakes, usePromiseLibrary.bind(null, library));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof fakes.usingPromise === "function") {
|
||||
fakes.usingPromise(library);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = usePromiseLibrary;
|
||||
43
node_modules/sinon/lib/sinon/util/core/walk-object.js
generated
vendored
Normal file
43
node_modules/sinon/lib/sinon/util/core/walk-object.js
generated
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
"use strict";
|
||||
|
||||
var functionName = require("@sinonjs/commons").functionName;
|
||||
|
||||
var getPropertyDescriptor = require("./get-property-descriptor");
|
||||
var walk = require("./walk");
|
||||
|
||||
function walkObject(predicate, object, filter) {
|
||||
var called = false;
|
||||
var name = functionName(predicate);
|
||||
|
||||
if (!object) {
|
||||
throw new Error("Trying to " + name + " object but received " + String(object));
|
||||
}
|
||||
|
||||
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 (
|
||||
propOwner !== Object.prototype &&
|
||||
prop !== "constructor" &&
|
||||
typeof getPropertyDescriptor(propOwner, prop).value === "function"
|
||||
) {
|
||||
if (filter) {
|
||||
if (filter(object, prop)) {
|
||||
called = true;
|
||||
predicate(object, prop);
|
||||
}
|
||||
} else {
|
||||
called = true;
|
||||
predicate(object, prop);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!called) {
|
||||
throw new Error("Expected to " + name + " methods on object but found none");
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
module.exports = walkObject;
|
||||
45
node_modules/sinon/lib/sinon/util/core/walk.js
generated
vendored
Normal file
45
node_modules/sinon/lib/sinon/util/core/walk.js
generated
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
"use strict";
|
||||
|
||||
var forEach = require("@sinonjs/commons").prototypes.array.forEach;
|
||||
|
||||
function walkInternal(obj, iterator, context, originalObj, seen) {
|
||||
var proto, prop;
|
||||
|
||||
if (typeof Object.getOwnPropertyNames !== "function") {
|
||||
// We explicitly want to enumerate through all of the prototype's properties
|
||||
// in this case, therefore we deliberately leave out an own property check.
|
||||
/* eslint-disable-next-line guard-for-in */
|
||||
for (prop in obj) {
|
||||
iterator.call(context, obj[prop], prop, obj);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
forEach(Object.getOwnPropertyNames(obj), function(k) {
|
||||
if (seen[k] !== true) {
|
||||
seen[k] = true;
|
||||
var target = typeof Object.getOwnPropertyDescriptor(obj, k).get === "function" ? originalObj : obj;
|
||||
iterator.call(context, k, target);
|
||||
}
|
||||
});
|
||||
|
||||
proto = Object.getPrototypeOf(obj);
|
||||
if (proto) {
|
||||
walkInternal(proto, iterator, context, originalObj, seen);
|
||||
}
|
||||
}
|
||||
|
||||
/* Walks the prototype chain of an object and iterates over every own property
|
||||
* name encountered. The iterator is called in the same fashion that Array.prototype.forEach
|
||||
* works, where it is passed the value, key, and own object as the 1st, 2nd, and 3rd positional
|
||||
* argument, respectively. In cases where Object.getOwnPropertyNames is not available, walk will
|
||||
* default to using a simple for..in loop.
|
||||
*
|
||||
* obj - The object to walk the prototype chain for.
|
||||
* iterator - The function to be called on each pass of the walk.
|
||||
* context - (Optional) When given, the iterator will be called with this object as the receiver.
|
||||
*/
|
||||
module.exports = function walk(obj, iterator, context) {
|
||||
return walkInternal(obj, iterator, context, obj, {});
|
||||
};
|
||||
155
node_modules/sinon/lib/sinon/util/core/wrap-method.js
generated
vendored
Normal file
155
node_modules/sinon/lib/sinon/util/core/wrap-method.js
generated
vendored
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
"use strict";
|
||||
|
||||
var getPropertyDescriptor = require("./get-property-descriptor");
|
||||
var extend = require("./extend");
|
||||
var hasOwnProperty = require("@sinonjs/commons").prototypes.object.hasOwnProperty;
|
||||
var valueToString = require("@sinonjs/commons").valueToString;
|
||||
|
||||
function isFunction(obj) {
|
||||
return typeof obj === "function" || Boolean(obj && obj.constructor && obj.call && obj.apply);
|
||||
}
|
||||
|
||||
function mirrorProperties(target, source) {
|
||||
for (var prop in source) {
|
||||
if (!hasOwnProperty(target, prop)) {
|
||||
target[prop] = source[prop];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Cheap way to detect if we have ES5 support.
|
||||
var hasES5Support = "keys" in Object;
|
||||
|
||||
module.exports = function wrapMethod(object, property, method) {
|
||||
if (!object) {
|
||||
throw new TypeError("Should wrap property of object");
|
||||
}
|
||||
|
||||
if (typeof method !== "function" && typeof method !== "object") {
|
||||
throw new TypeError("Method wrapper should be a function or a property descriptor");
|
||||
}
|
||||
|
||||
function checkWrappedMethod(wrappedMethod) {
|
||||
var error;
|
||||
|
||||
if (!isFunction(wrappedMethod)) {
|
||||
error = new TypeError(
|
||||
"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");
|
||||
} else if (wrappedMethod.calledBefore) {
|
||||
var verb = wrappedMethod.returns ? "stubbed" : "spied on";
|
||||
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;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
var error, wrappedMethod, i, wrappedMethodDesc;
|
||||
|
||||
function simplePropertyAssignment() {
|
||||
wrappedMethod = object[property];
|
||||
checkWrappedMethod(wrappedMethod);
|
||||
object[property] = method;
|
||||
method.displayName = property;
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
if (hasES5Support) {
|
||||
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"
|
||||
);
|
||||
} 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;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
|
||||
var types = Object.keys(methodDesc);
|
||||
for (i = 0; i < types.length; i++) {
|
||||
wrappedMethod = wrappedMethodDesc[types[i]];
|
||||
checkWrappedMethod(wrappedMethod);
|
||||
}
|
||||
|
||||
mirrorProperties(methodDesc, wrappedMethodDesc);
|
||||
for (i = 0; i < types.length; i++) {
|
||||
mirrorProperties(methodDesc[types[i]], wrappedMethodDesc[types[i]]);
|
||||
}
|
||||
Object.defineProperty(object, property, methodDesc);
|
||||
|
||||
// catch failing assignment
|
||||
// this is the converse of the check in `.restore` below
|
||||
if (typeof method === "function" && object[property] !== method) {
|
||||
// correct any wrongdoings caused by the defineProperty call above,
|
||||
// such as adding new items (if object was a Storage object)
|
||||
delete object[property];
|
||||
simplePropertyAssignment();
|
||||
}
|
||||
} else {
|
||||
simplePropertyAssignment();
|
||||
}
|
||||
|
||||
extend.nonEnum(method, {
|
||||
displayName: property,
|
||||
|
||||
wrappedMethod: wrappedMethod,
|
||||
|
||||
// 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.
|
||||
if (!owned) {
|
||||
// In some cases `delete` may throw an error
|
||||
try {
|
||||
delete object[property];
|
||||
} 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) {
|
||||
Object.defineProperty(object, property, wrappedMethodDesc);
|
||||
}
|
||||
|
||||
if (hasES5Support) {
|
||||
var descriptor = getPropertyDescriptor(object, property);
|
||||
if (descriptor && descriptor.value === method) {
|
||||
object[property] = wrappedMethod;
|
||||
}
|
||||
} else {
|
||||
// Use strict equality comparison to check failures then force a reset
|
||||
// via direct assignment.
|
||||
if (object[property] === method) {
|
||||
object[property] = wrappedMethod;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
method.restore.sinon = true;
|
||||
|
||||
if (!hasES5Support) {
|
||||
mirrorProperties(method, wrappedMethod);
|
||||
}
|
||||
|
||||
return method;
|
||||
};
|
||||
72
node_modules/sinon/lib/sinon/util/fake-timers.js
generated
vendored
Normal file
72
node_modules/sinon/lib/sinon/util/fake-timers.js
generated
vendored
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
"use strict";
|
||||
|
||||
var extend = require("./core/extend");
|
||||
var FakeTimers = require("@sinonjs/fake-timers");
|
||||
var globalObject = require("@sinonjs/commons").global;
|
||||
|
||||
function createClock(config, globalCtx) {
|
||||
var FakeTimersCtx = FakeTimers;
|
||||
if (globalCtx !== null && typeof globalCtx === "object") {
|
||||
FakeTimersCtx = FakeTimers.withGlobal(globalCtx);
|
||||
}
|
||||
var clock = FakeTimersCtx.install(config);
|
||||
clock.restore = clock.uninstall;
|
||||
return clock;
|
||||
}
|
||||
|
||||
function addIfDefined(obj, globalPropName) {
|
||||
var globalProp = globalObject[globalPropName];
|
||||
if (typeof globalProp !== "undefined") {
|
||||
obj[globalPropName] = globalProp;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @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) {
|
||||
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;
|
||||
|
||||
if (!hasArguments) {
|
||||
return createClock({
|
||||
now: 0
|
||||
});
|
||||
}
|
||||
|
||||
if (argumentIsDateLike) {
|
||||
return createClock({
|
||||
now: dateOrConfig
|
||||
});
|
||||
}
|
||||
|
||||
if (argumentIsObject) {
|
||||
var config = extend.nonEnum({}, dateOrConfig);
|
||||
var globalCtx = config.global;
|
||||
delete config.global;
|
||||
return createClock(config, globalCtx);
|
||||
}
|
||||
|
||||
throw new TypeError("useFakeTimers expected epoch or config object. See https://github.com/sinonjs/sinon");
|
||||
};
|
||||
|
||||
exports.clock = {
|
||||
create: function(now) {
|
||||
return FakeTimers.createClock(now);
|
||||
}
|
||||
};
|
||||
|
||||
var timers = {
|
||||
setTimeout: setTimeout,
|
||||
clearTimeout: clearTimeout,
|
||||
setInterval: setInterval,
|
||||
clearInterval: clearInterval,
|
||||
Date: Date
|
||||
};
|
||||
addIfDefined(timers, "setImmediate");
|
||||
addIfDefined(timers, "clearImmediate");
|
||||
|
||||
exports.timers = timers;
|
||||
39
node_modules/sinon/node_modules/has-flag/index.d.ts
generated
vendored
Normal file
39
node_modules/sinon/node_modules/has-flag/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/**
|
||||
Check if [`argv`](https://nodejs.org/docs/latest/api/process.html#process_process_argv) has a specific flag.
|
||||
|
||||
@param flag - CLI flag to look for. The `--` prefix is optional.
|
||||
@param argv - CLI arguments. Default: `process.argv`.
|
||||
@returns Whether the flag exists.
|
||||
|
||||
@example
|
||||
```
|
||||
// $ ts-node foo.ts -f --unicorn --foo=bar -- --rainbow
|
||||
|
||||
// foo.ts
|
||||
import hasFlag = require('has-flag');
|
||||
|
||||
hasFlag('unicorn');
|
||||
//=> true
|
||||
|
||||
hasFlag('--unicorn');
|
||||
//=> true
|
||||
|
||||
hasFlag('f');
|
||||
//=> true
|
||||
|
||||
hasFlag('-f');
|
||||
//=> true
|
||||
|
||||
hasFlag('foo=bar');
|
||||
//=> true
|
||||
|
||||
hasFlag('foo');
|
||||
//=> false
|
||||
|
||||
hasFlag('rainbow');
|
||||
//=> false
|
||||
```
|
||||
*/
|
||||
declare function hasFlag(flag: string, argv?: string[]): boolean;
|
||||
|
||||
export = hasFlag;
|
||||
8
node_modules/sinon/node_modules/has-flag/index.js
generated
vendored
Normal file
8
node_modules/sinon/node_modules/has-flag/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = (flag, argv = process.argv) => {
|
||||
const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
|
||||
const position = argv.indexOf(prefix + flag);
|
||||
const terminatorPosition = argv.indexOf('--');
|
||||
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
||||
};
|
||||
9
node_modules/sinon/node_modules/has-flag/license
generated
vendored
Normal file
9
node_modules/sinon/node_modules/has-flag/license
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
78
node_modules/sinon/node_modules/has-flag/package.json
generated
vendored
Normal file
78
node_modules/sinon/node_modules/has-flag/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
{
|
||||
"_from": "has-flag@^4.0.0",
|
||||
"_id": "has-flag@4.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
|
||||
"_location": "/sinon/has-flag",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "has-flag@^4.0.0",
|
||||
"name": "has-flag",
|
||||
"escapedName": "has-flag",
|
||||
"rawSpec": "^4.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^4.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/sinon/supports-color"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
||||
"_shasum": "944771fd9c81c81265c4d6941860da06bb59479b",
|
||||
"_spec": "has-flag@^4.0.0",
|
||||
"_where": "/Users/sam/code/codeql-action/node_modules/sinon/node_modules/supports-color",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/sindresorhus/has-flag/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Check if argv has a specific flag",
|
||||
"devDependencies": {
|
||||
"ava": "^1.4.1",
|
||||
"tsd": "^0.7.2",
|
||||
"xo": "^0.24.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"homepage": "https://github.com/sindresorhus/has-flag#readme",
|
||||
"keywords": [
|
||||
"has",
|
||||
"check",
|
||||
"detect",
|
||||
"contains",
|
||||
"find",
|
||||
"flag",
|
||||
"cli",
|
||||
"command-line",
|
||||
"argv",
|
||||
"process",
|
||||
"arg",
|
||||
"args",
|
||||
"argument",
|
||||
"arguments",
|
||||
"getopt",
|
||||
"minimist",
|
||||
"optimist"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "has-flag",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sindresorhus/has-flag.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"version": "4.0.0"
|
||||
}
|
||||
89
node_modules/sinon/node_modules/has-flag/readme.md
generated
vendored
Normal file
89
node_modules/sinon/node_modules/has-flag/readme.md
generated
vendored
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
# has-flag [](https://travis-ci.org/sindresorhus/has-flag)
|
||||
|
||||
> Check if [`argv`](https://nodejs.org/docs/latest/api/process.html#process_process_argv) has a specific flag
|
||||
|
||||
Correctly stops looking after an `--` argument terminator.
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-has-flag?utm_source=npm-has-flag&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install has-flag
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
// foo.js
|
||||
const hasFlag = require('has-flag');
|
||||
|
||||
hasFlag('unicorn');
|
||||
//=> true
|
||||
|
||||
hasFlag('--unicorn');
|
||||
//=> true
|
||||
|
||||
hasFlag('f');
|
||||
//=> true
|
||||
|
||||
hasFlag('-f');
|
||||
//=> true
|
||||
|
||||
hasFlag('foo=bar');
|
||||
//=> true
|
||||
|
||||
hasFlag('foo');
|
||||
//=> false
|
||||
|
||||
hasFlag('rainbow');
|
||||
//=> false
|
||||
```
|
||||
|
||||
```
|
||||
$ node foo.js -f --unicorn --foo=bar -- --rainbow
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### hasFlag(flag, [argv])
|
||||
|
||||
Returns a boolean for whether the flag exists.
|
||||
|
||||
#### flag
|
||||
|
||||
Type: `string`
|
||||
|
||||
CLI flag to look for. The `--` prefix is optional.
|
||||
|
||||
#### argv
|
||||
|
||||
Type: `string[]`<br>
|
||||
Default: `process.argv`
|
||||
|
||||
CLI arguments.
|
||||
|
||||
|
||||
## Security
|
||||
|
||||
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
5
node_modules/sinon/node_modules/supports-color/browser.js
generated
vendored
Normal file
5
node_modules/sinon/node_modules/supports-color/browser.js
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
'use strict';
|
||||
module.exports = {
|
||||
stdout: false,
|
||||
stderr: false
|
||||
};
|
||||
139
node_modules/sinon/node_modules/supports-color/index.js
generated
vendored
Normal file
139
node_modules/sinon/node_modules/supports-color/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
'use strict';
|
||||
const os = require('os');
|
||||
const tty = require('tty');
|
||||
const hasFlag = require('has-flag');
|
||||
|
||||
const {env} = process;
|
||||
|
||||
let forceColor;
|
||||
if (hasFlag('no-color') ||
|
||||
hasFlag('no-colors') ||
|
||||
hasFlag('color=false') ||
|
||||
hasFlag('color=never')) {
|
||||
forceColor = 0;
|
||||
} else if (hasFlag('color') ||
|
||||
hasFlag('colors') ||
|
||||
hasFlag('color=true') ||
|
||||
hasFlag('color=always')) {
|
||||
forceColor = 1;
|
||||
}
|
||||
|
||||
if ('FORCE_COLOR' in env) {
|
||||
if (env.FORCE_COLOR === 'true') {
|
||||
forceColor = 1;
|
||||
} else if (env.FORCE_COLOR === 'false') {
|
||||
forceColor = 0;
|
||||
} else {
|
||||
forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
|
||||
}
|
||||
}
|
||||
|
||||
function translateLevel(level) {
|
||||
if (level === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return {
|
||||
level,
|
||||
hasBasic: true,
|
||||
has256: level >= 2,
|
||||
has16m: level >= 3
|
||||
};
|
||||
}
|
||||
|
||||
function supportsColor(haveStream, streamIsTTY) {
|
||||
if (forceColor === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (hasFlag('color=16m') ||
|
||||
hasFlag('color=full') ||
|
||||
hasFlag('color=truecolor')) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (hasFlag('color=256')) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const min = forceColor || 0;
|
||||
|
||||
if (env.TERM === 'dumb') {
|
||||
return min;
|
||||
}
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
// Windows 10 build 10586 is the first Windows release that supports 256 colors.
|
||||
// Windows 10 build 14931 is the first release that supports 16m/TrueColor.
|
||||
const osRelease = os.release().split('.');
|
||||
if (
|
||||
Number(osRelease[0]) >= 10 &&
|
||||
Number(osRelease[2]) >= 10586
|
||||
) {
|
||||
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ('CI' in env) {
|
||||
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return min;
|
||||
}
|
||||
|
||||
if ('TEAMCITY_VERSION' in env) {
|
||||
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;
|
||||
}
|
||||
|
||||
if ('TERM_PROGRAM' in env) {
|
||||
const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
||||
|
||||
switch (env.TERM_PROGRAM) {
|
||||
case 'iTerm.app':
|
||||
return version >= 3 ? 3 : 2;
|
||||
case 'Apple_Terminal':
|
||||
return 2;
|
||||
// No default
|
||||
}
|
||||
}
|
||||
|
||||
if (/-256(color)?$/i.test(env.TERM)) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ('COLORTERM' in env) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return min;
|
||||
}
|
||||
|
||||
function getSupportLevel(stream) {
|
||||
const level = supportsColor(stream, stream && stream.isTTY);
|
||||
return translateLevel(level);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
supportsColor: getSupportLevel,
|
||||
stdout: translateLevel(supportsColor(true, tty.isatty(1))),
|
||||
stderr: translateLevel(supportsColor(true, tty.isatty(2)))
|
||||
};
|
||||
9
node_modules/sinon/node_modules/supports-color/license
generated
vendored
Normal file
9
node_modules/sinon/node_modules/supports-color/license
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
85
node_modules/sinon/node_modules/supports-color/package.json
generated
vendored
Normal file
85
node_modules/sinon/node_modules/supports-color/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
{
|
||||
"_from": "supports-color@^7.1.0",
|
||||
"_id": "supports-color@7.1.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==",
|
||||
"_location": "/sinon/supports-color",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "supports-color@^7.1.0",
|
||||
"name": "supports-color",
|
||||
"escapedName": "supports-color",
|
||||
"rawSpec": "^7.1.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^7.1.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/sinon"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz",
|
||||
"_shasum": "68e32591df73e25ad1c4b49108a2ec507962bfd1",
|
||||
"_spec": "supports-color@^7.1.0",
|
||||
"_where": "/Users/sam/code/codeql-action/node_modules/sinon",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"browser": "browser.js",
|
||||
"bugs": {
|
||||
"url": "https://github.com/chalk/supports-color/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"has-flag": "^4.0.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Detect whether a terminal supports color",
|
||||
"devDependencies": {
|
||||
"ava": "^1.4.1",
|
||||
"import-fresh": "^3.0.0",
|
||||
"xo": "^0.24.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"browser.js"
|
||||
],
|
||||
"homepage": "https://github.com/chalk/supports-color#readme",
|
||||
"keywords": [
|
||||
"color",
|
||||
"colour",
|
||||
"colors",
|
||||
"terminal",
|
||||
"console",
|
||||
"cli",
|
||||
"ansi",
|
||||
"styles",
|
||||
"tty",
|
||||
"rgb",
|
||||
"256",
|
||||
"shell",
|
||||
"xterm",
|
||||
"command-line",
|
||||
"support",
|
||||
"supports",
|
||||
"capability",
|
||||
"detect",
|
||||
"truecolor",
|
||||
"16m"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "supports-color",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/chalk/supports-color.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"version": "7.1.0"
|
||||
}
|
||||
76
node_modules/sinon/node_modules/supports-color/readme.md
generated
vendored
Normal file
76
node_modules/sinon/node_modules/supports-color/readme.md
generated
vendored
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
# supports-color [](https://travis-ci.org/chalk/supports-color)
|
||||
|
||||
> Detect whether a terminal supports color
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install supports-color
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const supportsColor = require('supports-color');
|
||||
|
||||
if (supportsColor.stdout) {
|
||||
console.log('Terminal stdout supports color');
|
||||
}
|
||||
|
||||
if (supportsColor.stdout.has256) {
|
||||
console.log('Terminal stdout supports 256 colors');
|
||||
}
|
||||
|
||||
if (supportsColor.stderr.has16m) {
|
||||
console.log('Terminal stderr supports 16 million colors (truecolor)');
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
Returns an `Object` with a `stdout` and `stderr` property for testing either streams. Each property is an `Object`, or `false` if color is not supported.
|
||||
|
||||
The `stdout`/`stderr` objects specifies a level of support for color through a `.level` property and a corresponding flag:
|
||||
|
||||
- `.level = 1` and `.hasBasic = true`: Basic color support (16 colors)
|
||||
- `.level = 2` and `.has256 = true`: 256 color support
|
||||
- `.level = 3` and `.has16m = true`: Truecolor support (16 million colors)
|
||||
|
||||
|
||||
## Info
|
||||
|
||||
It obeys the `--color` and `--no-color` CLI flags.
|
||||
|
||||
For situations where using `--color` is not possible, use the environment variable `FORCE_COLOR=1` (level 1), `FORCE_COLOR=2` (level 2), or `FORCE_COLOR=3` (level 3) to forcefully enable color, or `FORCE_COLOR=0` to forcefully disable. The use of `FORCE_COLOR` overrides all other color support checks.
|
||||
|
||||
Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [supports-color-cli](https://github.com/chalk/supports-color-cli) - CLI for this module
|
||||
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
|
||||
|
||||
|
||||
## Maintainers
|
||||
|
||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||
- [Josh Junon](https://github.com/qix-)
|
||||
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-supports-color?utm_source=npm-supports-color&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
||||
|
||||
---
|
||||
1550
node_modules/sinon/package.json
generated
vendored
Normal file
1550
node_modules/sinon/package.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
16510
node_modules/sinon/pkg/sinon-esm.js
generated
vendored
Normal file
16510
node_modules/sinon/pkg/sinon-esm.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
16428
node_modules/sinon/pkg/sinon-no-sourcemaps.js
generated
vendored
Normal file
16428
node_modules/sinon/pkg/sinon-no-sourcemaps.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
16430
node_modules/sinon/pkg/sinon.js
generated
vendored
Normal file
16430
node_modules/sinon/pkg/sinon.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue