Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
]
}
})
// +2 quantity
assert.ok(eventsSpy.calledWith(sinon.match({
name: 'Added Product',
category: 'Ecommerce',
product: {
id: '1'
},
quantity: 2
})))
// +1 new item
assert.ok(eventsSpy.calledWith(sinon.match({
name: 'Added Product',
category: 'Ecommerce',
product: {
id: '2'
},
quantity: 1
})))
// -3 items
assert.ok(eventsSpy.calledWith(sinon.match({
name: 'Removed Product',
category: 'Ecommerce',
product: {
id: '3'
},
quantity: 3
var dir = __dirname + "/../examples/";
var rep = require("../examples/reporter.js");
var config = {
"asi": true,
"overrides": {
"bar.js": {
"asi": false
}
}
};
this.sinon.stub(process, "cwd").returns(dir);
this.sinon.stub(rep, "reporter");
this.sinon.stub(shjs, "cat")
.withArgs(sinon.match(/foo\.js$/)).returns("a()")
.withArgs(sinon.match(/bar\.js$/)).returns("a()")
.withArgs(sinon.match(/config\.json$/))
.returns(JSON.stringify(config));
this.sinon.stub(shjs, "test")
.withArgs("-e", sinon.match(/foo\.js$/)).returns(true)
.withArgs("-e", sinon.match(/bar\.js$/)).returns(true)
.withArgs("-e", sinon.match(/config\.json$/)).returns(true);
cli.exit.withArgs(0).returns(true)
.withArgs(1).throws("ProcessExit");
// Test successful file
cli.interpret([
"node", "jshint", "foo.js", "--config", "config.json", "--reporter", "reporter.js"
]);
test.ok(rep.reporter.args[0][0].length === 0);
it('should emit valueRead', function() {
var eventSpy = sandbox.spy();
bindings.once('valueRead', eventSpy);
if (typeof setup == 'function')
setup(mock, sandbox);
var bufferMatcher = sinon.match.instanceOf(Buffer).and(sinon.match(function(val) {
return val.toString() === a.dataBuffer.toString();
}));
bindings.readValue(a.peripheralUuidString, a.serviceUuidString, a.characteristicUuidString, a.descriptorUuidString);
eventSpy.calledWith(a.peripheralUuidString, a.serviceUuidString, a.characteristicUuidString, a.descriptorUuidString, bufferMatcher).should.equal(true);
});
.then(() => {
listPosts();
expect(console.log.calledWith(sinon.match('Date'))).to.be.true;
expect(console.log.calledWith(sinon.match('Title'))).to.be.true;
expect(console.log.calledWith(sinon.match('Path'))).to.be.true;
expect(console.log.calledWith(sinon.match('Category'))).to.be.true;
expect(console.log.calledWith(sinon.match('Tags'))).to.be.true;
for (let i = 0; i < posts.length; i++) {
expect(console.log.calledWith(sinon.match(posts[i].source))).to.be.true;
expect(console.log.calledWith(sinon.match(posts[i].slug))).to.be.true;
expect(console.log.calledWith(sinon.match(posts[i].title))).to.be.true;
}
});
});
it('calls logDeprecation() with deprecation messages', async () => {
const config = Config.withDefaultSchema();
const logDeprecation = sinon.stub();
await extendConfigService(pluginSpec, config, {
foo: {
bar: {
baz: {
oldTest: '123'
}
}
}
}, logDeprecation);
sinon.assert.calledOnce(logDeprecation);
sinon.assert.calledWithExactly(logDeprecation, sinon.match('"oldTest" is deprecated'));
});
it('should listen for scroll event on scrollElement', function () {
const { sticky, unmount } = mountSticky({ scrollElement: "#scrollarea" });
expect(listen).have.been.calledWithMatch(
match(el => el === document.getElementById('scrollarea'), 'div#scrollarea'),
createMatch(['scroll']),
match(cb => cb === sticky.instance().checkPosition, 'this.checkPosition')
);
unmount();
});
});
var numCrawlsOfUrl = function (url, followRedirect) {
var numCalls = 0;
var n = 0;
var call;
while (requestSpy.getCall(n)) {
call = requestSpy.getCall(n);
if (call.calledWith(sinon.match({
url: url,
forever: true,
followRedirect: followRedirect
}))) {
numCalls++;
}
n++;
}
return numCalls;
};
beforeEach(() => {
samlAcsRoute = serverStub.route
.withArgs(sinon.match({ path: '/api/security/v1/saml' }))
.firstCall
.args[0];
request = requestFixture({ payload: { SAMLResponse: 'saml-response-xml' } });
});
function(err, resources) {
fs.readFile.should.have.been.calledWith(sinon.match(/foo\/js\/foo\/foo.js/));
fs.readFile.should.have.been.calledWith(sinon.match(/foo\/js\/bar.js/));
fs.readFile.should.have.been.calledWith(sinon.match(/foo\/js\/views\/baz.js/));
resources.should.eql([{amd: 'foo/js/views/baz.js'}, {amd: 'foo/js/bar.js'}, {amd: 'foo/js/foo/foo.js'}]);
done();
});
});
beforeEach(function(){
plexAPIStubs.query.withArgs('/').resolves(require('./samples/root.json'));
plexAPIStubs.query.withArgs(sinon.match(/\/library\/metadata\/[0-9]+$/))
.resolves(require('./samples/library_metadata_item.json'));
plexAPIStubs.query.withArgs('/library/sections/1/all')
.resolves(require('./samples/library_section_allshows.json'));
plexAPIStubs.query.withArgs('/library/metadata/1/allLeaves')
.resolves(require('./samples/library_metadata_showepisodes_withunwatched.json'));
plexAPIStubs.query.withArgs('/library/metadata/143/allLeaves')
.resolves(require('./samples/library_metadata_showepisodes_allwatched.json'));
plexAPIStubs.postQuery.withArgs(sinon.match(/\/playQueues/))
.resolves(require('./samples/playqueues.json'));
plexAPIStubs.perform.withArgs(sinon.match(/\/playMedia/))
.resolves(null, true);
plexAPIStubs.find.withArgs('/clients')
.resolves(require('./samples/clients.json'));
});