How to use getCall method in storybook-root

Best JavaScript code snippet using storybook-root

self.js

Source:self.js Github

copy

Full Screen

...128 const Test = implement(AbstractLevelDOWN, { _open: spy })129 const test = new Test('foobar')130 test.open(expectedCb)131 t.equal(spy.callCount, 1, 'got _open() call')132 t.equal(spy.getCall(0).thisValue, test, '`this` on _open() was correct')133 t.equal(spy.getCall(0).args.length, 2, 'got two arguments')134 t.deepEqual(spy.getCall(0).args[0], expectedOptions, 'got default options argument')135 test.open({ options: 1 }, expectedCb)136 expectedOptions.options = 1137 t.equal(spy.callCount, 2, 'got _open() call')138 t.equal(spy.getCall(1).thisValue, test, '`this` on _open() was correct')139 t.equal(spy.getCall(1).args.length, 2, 'got two arguments')140 t.deepEqual(spy.getCall(1).args[0], expectedOptions, 'got expected options argument')141 t.end()142})143test('test close() extensibility', function (t) {144 const spy = sinon.spy()145 const expectedCb = function () {}146 const Test = implement(AbstractLevelDOWN, { _close: spy })147 const test = new Test('foobar')148 test.close(expectedCb)149 t.equal(spy.callCount, 1, 'got _close() call')150 t.equal(spy.getCall(0).thisValue, test, '`this` on _close() was correct')151 t.equal(spy.getCall(0).args.length, 1, 'got one arguments')152 t.end()153})154test('test get() extensibility', function (t) {155 const spy = sinon.spy()156 const expectedCb = function () {}157 const expectedOptions = { asBuffer: true }158 const expectedKey = 'a key'159 const Test = implement(AbstractLevelDOWN, { _get: spy })160 const test = new Test('foobar')161 test.get(expectedKey, expectedCb)162 t.equal(spy.callCount, 1, 'got _get() call')163 t.equal(spy.getCall(0).thisValue, test, '`this` on _get() was correct')164 t.equal(spy.getCall(0).args.length, 3, 'got three arguments')165 t.equal(spy.getCall(0).args[0], expectedKey, 'got expected key argument')166 t.deepEqual(spy.getCall(0).args[1], expectedOptions, 'got default options argument')167 t.equal(spy.getCall(0).args[2], expectedCb, 'got expected cb argument')168 test.get(expectedKey, { options: 1 }, expectedCb)169 expectedOptions.options = 1170 t.equal(spy.callCount, 2, 'got _get() call')171 t.equal(spy.getCall(1).thisValue, test, '`this` on _get() was correct')172 t.equal(spy.getCall(1).args.length, 3, 'got three arguments')173 t.equal(spy.getCall(1).args[0], expectedKey, 'got expected key argument')174 t.deepEqual(spy.getCall(1).args[1], expectedOptions, 'got expected options argument')175 t.equal(spy.getCall(1).args[2], expectedCb, 'got expected cb argument')176 t.end()177})178test('test del() extensibility', function (t) {179 const spy = sinon.spy()180 const expectedCb = function () {}181 const expectedOptions = { options: 1 }182 const expectedKey = 'a key'183 const Test = implement(AbstractLevelDOWN, { _del: spy })184 const test = new Test('foobar')185 test.del(expectedKey, expectedCb)186 t.equal(spy.callCount, 1, 'got _del() call')187 t.equal(spy.getCall(0).thisValue, test, '`this` on _del() was correct')188 t.equal(spy.getCall(0).args.length, 3, 'got three arguments')189 t.equal(spy.getCall(0).args[0], expectedKey, 'got expected key argument')190 t.deepEqual(spy.getCall(0).args[1], {}, 'got blank options argument')191 t.equal(spy.getCall(0).args[2], expectedCb, 'got expected cb argument')192 test.del(expectedKey, expectedOptions, expectedCb)193 t.equal(spy.callCount, 2, 'got _del() call')194 t.equal(spy.getCall(1).thisValue, test, '`this` on _del() was correct')195 t.equal(spy.getCall(1).args.length, 3, 'got three arguments')196 t.equal(spy.getCall(1).args[0], expectedKey, 'got expected key argument')197 t.deepEqual(spy.getCall(1).args[1], expectedOptions, 'got expected options argument')198 t.equal(spy.getCall(1).args[2], expectedCb, 'got expected cb argument')199 t.end()200})201test('test put() extensibility', function (t) {202 const spy = sinon.spy()203 const expectedCb = function () {}204 const expectedOptions = { options: 1 }205 const expectedKey = 'a key'206 const expectedValue = 'a value'207 const Test = implement(AbstractLevelDOWN, { _put: spy })208 const test = new Test('foobar')209 test.put(expectedKey, expectedValue, expectedCb)210 t.equal(spy.callCount, 1, 'got _put() call')211 t.equal(spy.getCall(0).thisValue, test, '`this` on _put() was correct')212 t.equal(spy.getCall(0).args.length, 4, 'got four arguments')213 t.equal(spy.getCall(0).args[0], expectedKey, 'got expected key argument')214 t.equal(spy.getCall(0).args[1], expectedValue, 'got expected value argument')215 t.deepEqual(spy.getCall(0).args[2], {}, 'got blank options argument')216 t.equal(spy.getCall(0).args[3], expectedCb, 'got expected cb argument')217 test.put(expectedKey, expectedValue, expectedOptions, expectedCb)218 t.equal(spy.callCount, 2, 'got _put() call')219 t.equal(spy.getCall(1).thisValue, test, '`this` on _put() was correct')220 t.equal(spy.getCall(1).args.length, 4, 'got four arguments')221 t.equal(spy.getCall(1).args[0], expectedKey, 'got expected key argument')222 t.equal(spy.getCall(1).args[1], expectedValue, 'got expected value argument')223 t.deepEqual(spy.getCall(1).args[2], expectedOptions, 'got blank options argument')224 t.equal(spy.getCall(1).args[3], expectedCb, 'got expected cb argument')225 t.end()226})227test('test batch([]) (array-form) extensibility', function (t) {228 const spy = sinon.spy()229 const expectedCb = function () {}230 const expectedOptions = { options: 1 }231 const expectedArray = [232 { type: 'put', key: '1', value: '1' },233 { type: 'del', key: '2' }234 ]235 const Test = implement(AbstractLevelDOWN, { _batch: spy })236 const test = new Test('foobar')237 test.batch(expectedArray, expectedCb)238 t.equal(spy.callCount, 1, 'got _batch() call')239 t.equal(spy.getCall(0).thisValue, test, '`this` on _batch() was correct')240 t.equal(spy.getCall(0).args.length, 3, 'got three arguments')241 t.deepEqual(spy.getCall(0).args[0], expectedArray, 'got expected array argument')242 t.deepEqual(spy.getCall(0).args[1], {}, 'got expected options argument')243 t.equal(spy.getCall(0).args[2], expectedCb, 'got expected callback argument')244 test.batch(expectedArray, expectedOptions, expectedCb)245 t.equal(spy.callCount, 2, 'got _batch() call')246 t.equal(spy.getCall(1).thisValue, test, '`this` on _batch() was correct')247 t.equal(spy.getCall(1).args.length, 3, 'got three arguments')248 t.deepEqual(spy.getCall(1).args[0], expectedArray, 'got expected array argument')249 t.deepEqual(spy.getCall(1).args[1], expectedOptions, 'got expected options argument')250 t.equal(spy.getCall(1).args[2], expectedCb, 'got expected callback argument')251 test.batch(expectedArray, null, expectedCb)252 t.equal(spy.callCount, 3, 'got _batch() call')253 t.equal(spy.getCall(2).thisValue, test, '`this` on _batch() was correct')254 t.equal(spy.getCall(2).args.length, 3, 'got three arguments')255 t.deepEqual(spy.getCall(2).args[0], expectedArray, 'got expected array argument')256 t.ok(spy.getCall(2).args[1], 'options should not be null')257 t.equal(spy.getCall(2).args[2], expectedCb, 'got expected callback argument')258 t.end()259})260test('test batch([]) (array-form) with empty array is asynchronous', function (t) {261 const spy = sinon.spy()262 const Test = implement(AbstractLevelDOWN, { _batch: spy })263 const test = new Test()264 let async = false265 test.batch([], function (err) {266 t.ifError(err, 'no error')267 t.ok(async, 'callback is asynchronous')268 // Assert that asynchronicity is provided by batch() rather than _batch()269 t.is(spy.callCount, 0, '_batch() call was bypassed')270 t.end()271 })272 async = true273})274test('test chained batch() extensibility', function (t) {275 const spy = sinon.spy()276 const expectedCb = function () {}277 const expectedOptions = { options: 1 }278 const Test = implement(AbstractLevelDOWN, { _batch: spy })279 const test = new Test('foobar')280 test.batch().put('foo', 'bar').del('bang').write(expectedCb)281 t.equal(spy.callCount, 1, 'got _batch() call')282 t.equal(spy.getCall(0).thisValue, test, '`this` on _batch() was correct')283 t.equal(spy.getCall(0).args.length, 3, 'got three arguments')284 t.equal(spy.getCall(0).args[0].length, 2, 'got expected array argument')285 t.deepEqual(spy.getCall(0).args[0][0], { type: 'put', key: 'foo', value: 'bar' }, 'got expected array argument[0]')286 t.deepEqual(spy.getCall(0).args[0][1], { type: 'del', key: 'bang' }, 'got expected array argument[1]')287 t.deepEqual(spy.getCall(0).args[1], {}, 'got expected options argument')288 t.equal(spy.getCall(0).args[2], expectedCb, 'got expected callback argument')289 test.batch().put('foo', 'bar', expectedOptions).del('bang', expectedOptions).write(expectedOptions, expectedCb)290 t.equal(spy.callCount, 2, 'got _batch() call')291 t.equal(spy.getCall(1).thisValue, test, '`this` on _batch() was correct')292 t.equal(spy.getCall(1).args.length, 3, 'got three arguments')293 t.equal(spy.getCall(1).args[0].length, 2, 'got expected array argument')294 t.deepEqual(spy.getCall(1).args[0][0], { type: 'put', key: 'foo', value: 'bar', options: 1 }, 'got expected array argument[0]')295 t.deepEqual(spy.getCall(1).args[0][1], { type: 'del', key: 'bang', options: 1 }, 'got expected array argument[1]')296 t.deepEqual(spy.getCall(1).args[1], expectedOptions, 'got expected options argument')297 t.equal(spy.getCall(1).args[2], expectedCb, 'got expected callback argument')298 t.end()299})300test('test chained batch() with no operations is asynchronous', function (t) {301 const Test = implement(AbstractLevelDOWN, {})302 const test = new Test()303 let async = false304 test.batch().write(function (err) {305 t.ifError(err, 'no error')306 t.ok(async, 'callback is asynchronous')307 t.end()308 })309 async = true310})311test('test chained batch() (custom _chainedBatch) extensibility', function (t) {312 const spy = sinon.spy()313 const Test = implement(AbstractLevelDOWN, { _chainedBatch: spy })314 const test = new Test('foobar')315 test.batch()316 t.equal(spy.callCount, 1, 'got _chainedBatch() call')317 t.equal(spy.getCall(0).thisValue, test, '`this` on _chainedBatch() was correct')318 test.batch()319 t.equal(spy.callCount, 2, 'got _chainedBatch() call')320 t.equal(spy.getCall(1).thisValue, test, '`this` on _chainedBatch() was correct')321 t.end()322})323test('test AbstractChainedBatch extensibility', function (t) {324 const Test = implement(AbstractChainedBatch)325 const db = {}326 const test = new Test(db)327 t.ok(test.db === db, 'instance has db reference')328 t.end()329})330test('test AbstractChainedBatch expects a db', function (t) {331 t.plan(1)332 const Test = implement(AbstractChainedBatch)333 try {334 Test()335 } catch (err) {336 t.is(err.message, 'First argument must be an abstract-leveldown compliant store')337 }338})339test('test AbstractChainedBatch#write() extensibility', function (t) {340 const spy = sinon.spy()341 const spycb = sinon.spy()342 const Test = implement(AbstractChainedBatch, { _write: spy })343 const test = new Test({ test: true })344 test.write(spycb)345 t.equal(spy.callCount, 1, 'got _write() call')346 t.equal(spy.getCall(0).thisValue, test, '`this` on _write() was correct')347 t.equal(spy.getCall(0).args.length, 2, 'got two arguments')348 t.same(spy.getCall(0).args[0], {}, 'got options')349 // awkward here cause of nextTick & an internal wrapped cb350 t.equal(typeof spy.getCall(0).args[1], 'function', 'got a callback function')351 t.equal(spycb.callCount, 0, 'spycb not called')352 spy.getCall(0).args[1]()353 t.equal(spycb.callCount, 1, 'spycb called, i.e. was our cb argument')354 t.end()355})356test('test AbstractChainedBatch#write() extensibility with null options', function (t) {357 const spy = sinon.spy()358 const Test = implement(AbstractChainedBatch, { _write: spy })359 const test = new Test({ test: true })360 test.write(null, function () {})361 t.equal(spy.callCount, 1, 'got _write() call')362 t.same(spy.getCall(0).args[0], {}, 'got options')363 t.end()364})365test('test AbstractChainedBatch#write() extensibility with options', function (t) {366 const spy = sinon.spy()367 const Test = implement(AbstractChainedBatch, { _write: spy })368 const test = new Test({ test: true })369 test.write({ test: true }, function () {})370 t.equal(spy.callCount, 1, 'got _write() call')371 t.same(spy.getCall(0).args[0], { test: true }, 'got options')372 t.end()373})374test('test AbstractChainedBatch#put() extensibility', function (t) {375 const spy = sinon.spy()376 const expectedKey = 'key'377 const expectedValue = 'value'378 const Test = implement(AbstractChainedBatch, { _put: spy })379 const test = new Test(testCommon.factory())380 const returnValue = test.put(expectedKey, expectedValue)381 t.equal(spy.callCount, 1, 'got _put call')382 t.equal(spy.getCall(0).thisValue, test, '`this` on _put() was correct')383 t.equal(spy.getCall(0).args.length, 3, 'got 3 arguments')384 t.equal(spy.getCall(0).args[0], expectedKey, 'got expected key argument')385 t.equal(spy.getCall(0).args[1], expectedValue, 'got expected value argument')386 t.same(spy.getCall(0).args[2], {}, 'got expected options argument')387 t.equal(returnValue, test, 'get expected return value')388 t.end()389})390test('test AbstractChainedBatch#del() extensibility', function (t) {391 const spy = sinon.spy()392 const expectedKey = 'key'393 const Test = implement(AbstractChainedBatch, { _del: spy })394 const test = new Test(testCommon.factory())395 const returnValue = test.del(expectedKey)396 t.equal(spy.callCount, 1, 'got _del call')397 t.equal(spy.getCall(0).thisValue, test, '`this` on _del() was correct')398 t.equal(spy.getCall(0).args.length, 2, 'got 2 arguments')399 t.equal(spy.getCall(0).args[0], expectedKey, 'got expected key argument')400 t.same(spy.getCall(0).args[1], {}, 'got expected options argument')401 t.equal(returnValue, test, 'get expected return value')402 t.end()403})404test('test AbstractChainedBatch#clear() extensibility', function (t) {405 const spy = sinon.spy()406 const Test = implement(AbstractChainedBatch, { _clear: spy })407 const test = new Test(testCommon.factory())408 const returnValue = test.clear()409 t.equal(spy.callCount, 1, 'got _clear call')410 t.equal(spy.getCall(0).thisValue, test, '`this` on _clear() was correct')411 t.equal(spy.getCall(0).args.length, 0, 'got zero arguments')412 t.equal(returnValue, test, 'get expected return value')413 t.end()414})415test('test iterator() extensibility', function (t) {416 const spy = sinon.spy()417 const expectedOptions = {418 options: 1,419 reverse: false,420 keys: true,421 values: true,422 limit: -1,423 keyAsBuffer: true,424 valueAsBuffer: true425 }426 const Test = implement(AbstractLevelDOWN, { _iterator: spy })427 const test = new Test('foobar')428 test.iterator({ options: 1 })429 t.equal(spy.callCount, 1, 'got _iterator() call')430 t.equal(spy.getCall(0).thisValue, test, '`this` on _iterator() was correct')431 t.equal(spy.getCall(0).args.length, 1, 'got one arguments')432 t.deepEqual(spy.getCall(0).args[0], expectedOptions, 'got expected options argument')433 t.end()434})435test('test AbstractIterator extensibility', function (t) {436 const Test = implement(AbstractIterator)437 const db = {}438 const test = new Test(db)439 t.ok(test.db === db, 'instance has db reference')440 t.end()441})442test('test AbstractIterator#next() extensibility', function (t) {443 const spy = sinon.spy()444 const spycb = sinon.spy()445 const Test = implement(AbstractIterator, { _next: spy })446 const test = new Test({})447 test.next(spycb)448 t.equal(spy.callCount, 1, 'got _next() call')449 t.equal(spy.getCall(0).thisValue, test, '`this` on _next() was correct')450 t.equal(spy.getCall(0).args.length, 1, 'got one arguments')451 // awkward here cause of nextTick & an internal wrapped cb452 t.equal(typeof spy.getCall(0).args[0], 'function', 'got a callback function')453 t.equal(spycb.callCount, 0, 'spycb not called')454 spy.getCall(0).args[0]()455 t.equal(spycb.callCount, 1, 'spycb called, i.e. was our cb argument')456 t.end()457})458test('test AbstractIterator#end() extensibility', function (t) {459 const spy = sinon.spy()460 const expectedCb = function () {}461 const Test = implement(AbstractIterator, { _end: spy })462 const test = new Test({})463 test.end(expectedCb)464 t.equal(spy.callCount, 1, 'got _end() call')465 t.equal(spy.getCall(0).thisValue, test, '`this` on _end() was correct')466 t.equal(spy.getCall(0).args.length, 1, 'got one arguments')467 t.equal(spy.getCall(0).args[0], expectedCb, 'got expected cb argument')468 t.end()469})470test('test clear() extensibility', function (t) {471 const spy = sinon.spy()472 const Test = implement(AbstractLevelDOWN, { _clear: spy })473 const db = new Test()474 const callback = function () {}475 call([callback], { reverse: false, limit: -1 })476 call([null, callback], { reverse: false, limit: -1 })477 call([undefined, callback], { reverse: false, limit: -1 })478 call([{ custom: 1 }, callback], { custom: 1, reverse: false, limit: -1 })479 call([{ reverse: true, limit: 0 }, callback], { reverse: true, limit: 0 })480 call([{ reverse: 1 }, callback], { reverse: true, limit: -1 })481 call([{ reverse: null }, callback], { reverse: false, limit: -1 })482 function call (args, expectedOptions) {483 db.clear.apply(db, args)484 t.is(spy.callCount, 1, 'got _clear() call')485 t.is(spy.getCall(0).thisValue, db, '`this` on _clear() was correct')486 t.is(spy.getCall(0).args.length, 2, 'got two arguments')487 t.same(spy.getCall(0).args[0], expectedOptions, 'got expected options argument')488 t.is(spy.getCall(0).args[1], callback, 'got expected callback argument')489 spy.resetHistory()490 }491 t.end()492})493test('test serialization extensibility (put)', function (t) {494 t.plan(5)495 const spy = sinon.spy()496 const Test = implement(AbstractLevelDOWN, {497 _put: spy,498 _serializeKey: function (key) {499 t.equal(key, 'no')500 return 'foo'501 },502 _serializeValue: function (value) {503 t.equal(value, 'nope')504 return 'bar'505 }506 })507 const test = new Test('foobar')508 test.put('no', 'nope', function () {})509 t.equal(spy.callCount, 1, 'got _put() call')510 t.equal(spy.getCall(0).args[0], 'foo', 'got expected key argument')511 t.equal(spy.getCall(0).args[1], 'bar', 'got expected value argument')512})513test('test serialization extensibility (del)', function (t) {514 t.plan(3)515 const spy = sinon.spy()516 const Test = implement(AbstractLevelDOWN, {517 _del: spy,518 _serializeKey: function (key) {519 t.equal(key, 'no')520 return 'foo'521 },522 _serializeValue: function (value) {523 t.fail('should not be called')524 }525 })526 const test = new Test('foobar')527 test.del('no', function () {})528 t.equal(spy.callCount, 1, 'got _del() call')529 t.equal(spy.getCall(0).args[0], 'foo', 'got expected key argument')530 t.end()531})532test('test serialization extensibility (batch array put)', function (t) {533 t.plan(5)534 const spy = sinon.spy()535 const Test = implement(AbstractLevelDOWN, {536 _batch: spy,537 _serializeKey: function (key) {538 t.equal(key, 'no')539 return 'foo'540 },541 _serializeValue: function (value) {542 t.equal(value, 'nope')543 return 'bar'544 }545 })546 const test = new Test('foobar')547 test.batch([{ type: 'put', key: 'no', value: 'nope' }], function () {})548 t.equal(spy.callCount, 1, 'got _batch() call')549 t.equal(spy.getCall(0).args[0][0].key, 'foo', 'got expected key')550 t.equal(spy.getCall(0).args[0][0].value, 'bar', 'got expected value')551})552test('test serialization extensibility (batch chain put)', function (t) {553 t.plan(5)554 const spy = sinon.spy()555 const Test = implement(AbstractLevelDOWN, {556 _batch: spy,557 _serializeKey: function (key) {558 t.equal(key, 'no')559 return 'foo'560 },561 _serializeValue: function (value) {562 t.equal(value, 'nope')563 return 'bar'564 }565 })566 const test = new Test('foobar')567 test.batch().put('no', 'nope').write(function () {})568 t.equal(spy.callCount, 1, 'got _batch() call')569 t.equal(spy.getCall(0).args[0][0].key, 'foo', 'got expected key')570 t.equal(spy.getCall(0).args[0][0].value, 'bar', 'got expected value')571})572test('test serialization extensibility (batch array del)', function (t) {573 t.plan(3)574 const spy = sinon.spy()575 const Test = implement(AbstractLevelDOWN, {576 _batch: spy,577 _serializeKey: function (key) {578 t.equal(key, 'no')579 return 'foo'580 },581 _serializeValue: function (value) {582 t.fail('should not be called')583 }584 })585 const test = new Test('foobar')586 test.batch([{ type: 'del', key: 'no' }], function () {})587 t.equal(spy.callCount, 1, 'got _batch() call')588 t.equal(spy.getCall(0).args[0][0].key, 'foo', 'got expected key')589})590test('test serialization extensibility (batch chain del)', function (t) {591 t.plan(3)592 const spy = sinon.spy()593 const Test = implement(AbstractLevelDOWN, {594 _batch: spy,595 _serializeKey: function (key) {596 t.equal(key, 'no')597 return 'foo'598 },599 _serializeValue: function (value) {600 t.fail('should not be called')601 }602 })603 const test = new Test('foobar')604 test.batch().del('no').write(function () {})605 t.equal(spy.callCount, 1, 'got _batch() call')606 t.equal(spy.getCall(0).args[0][0].key, 'foo', 'got expected key')607})608test('test serialization extensibility (batch array is not mutated)', function (t) {609 t.plan(7)610 const spy = sinon.spy()611 const Test = implement(AbstractLevelDOWN, {612 _batch: spy,613 _serializeKey: function (key) {614 t.equal(key, 'no')615 return 'foo'616 },617 _serializeValue: function (value) {618 t.equal(value, 'nope')619 return 'bar'620 }621 })622 const test = new Test('foobar')623 const op = { type: 'put', key: 'no', value: 'nope' }624 test.batch([op], function () {})625 t.equal(spy.callCount, 1, 'got _batch() call')626 t.equal(spy.getCall(0).args[0][0].key, 'foo', 'got expected key')627 t.equal(spy.getCall(0).args[0][0].value, 'bar', 'got expected value')628 t.equal(op.key, 'no', 'did not mutate input key')629 t.equal(op.value, 'nope', 'did not mutate input value')630})631test('test serialization extensibility (iterator range options)', function (t) {632 t.plan(2)633 function Test () {634 AbstractLevelDOWN.call(this)635 }636 inherits(Test, AbstractLevelDOWN)637 Test.prototype._serializeKey = function (key) {638 t.is(key, 'input')639 return 'output'640 }641 Test.prototype._iterator = function (options) {642 return new Iterator(this, options)643 }644 function Iterator (db, options) {645 AbstractIterator.call(this, db)646 t.is(options.gt, 'output')647 }648 inherits(Iterator, AbstractIterator)649 const test = new Test()650 test.iterator({ gt: 'input' })651})652test('test serialization extensibility (iterator seek)', function (t) {653 t.plan(3)654 const spy = sinon.spy()655 const TestIterator = implement(AbstractIterator, { _seek: spy })656 const Test = implement(AbstractLevelDOWN, {657 _iterator: function () {658 return new TestIterator(this)659 },660 _serializeKey: function (key) {661 t.equal(key, 'target')662 return 'serialized'663 }664 })665 const test = new Test('foobar')666 const it = test.iterator()667 it.seek('target')668 t.equal(spy.callCount, 1, 'got _seek() call')669 t.equal(spy.getCall(0).args[0], 'serialized', 'got expected target argument')670})671test('test serialization extensibility (clear range options)', function (t) {672 t.plan(rangeOptions.length * 2)673 rangeOptions.forEach(function (key) {674 const Test = implement(AbstractLevelDOWN, {675 _serializeKey: function (key) {676 t.is(key, 'input')677 return 'output'678 },679 _clear: function (options, callback) {680 t.is(options[key], 'output')681 }682 })683 const db = new Test()...

Full Screen

Full Screen

progress.test.js

Source:progress.test.js Github

copy

Full Screen

...26 progress.init(1000);27 progress.progress(1000);28 progress.complete();29 expect(logger.log.callCount).toBe(22);30 expect(logger.log.getCall(0).args[0]).toMatch(/transfer/i);31 expect(logger.log.getCall(1).args[0]).toBe('.');32 expect(logger.log.getCall(2).args[0]).toBe('.');33 expect(logger.log.getCall(3).args[0]).toBe('.');34 expect(logger.log.getCall(4).args[0]).toBe('.');35 expect(logger.log.getCall(5).args[0]).toBe('.');36 expect(logger.log.getCall(6).args[0]).toBe('.');37 expect(logger.log.getCall(7).args[0]).toBe('.');38 expect(logger.log.getCall(8).args[0]).toBe('.');39 expect(logger.log.getCall(9).args[0]).toBe('.');40 expect(logger.log.getCall(10).args[0]).toBe('.');41 expect(logger.log.getCall(11).args[0]).toBe('.');42 expect(logger.log.getCall(12).args[0]).toBe('.');43 expect(logger.log.getCall(13).args[0]).toBe('.');44 expect(logger.log.getCall(14).args[0]).toBe('.');45 expect(logger.log.getCall(15).args[0]).toBe('.');46 expect(logger.log.getCall(16).args[0]).toBe('.');47 expect(logger.log.getCall(17).args[0]).toBe('.');48 expect(logger.log.getCall(18).args[0]).toBe('.');49 expect(logger.log.getCall(19).args[0]).toBe('.');50 expect(logger.log.getCall(20).args[0]).toBe('.');51 expect(logger.log.getCall(21).args[0]).toMatch(/complete/i);52 });53 it('should show dot for each 5% of completion', function () {54 progress.init(1000);55 expect(logger.log.callCount).toBe(1);56 progress.progress(50); //5%57 expect(logger.log.callCount).toBe(2);58 progress.progress(100); //15%59 expect(logger.log.callCount).toBe(4);60 progress.progress(200); //25%61 expect(logger.log.callCount).toBe(8);62 progress.progress(590); //94%63 expect(logger.log.callCount).toBe(20);64 progress.progress(60); //100%65 expect(logger.log.callCount).toBe(21);66 //Any progress over 100% should be ignored.67 progress.progress(9999);68 expect(logger.log.callCount).toBe(21);69 progress.complete();70 expect(logger.log.callCount).toBe(22);71 expect(logger.log.getCall(0).args[0]).toMatch(/transfer/i);72 expect(logger.log.getCall(21).args[0]).toMatch(/complete/i);73 });74 });75 });76 });...

Full Screen

Full Screen

progress.js

Source:progress.js Github

copy

Full Screen

...22 progress.init(1000);23 progress.progress(1000);24 progress.complete();25 expect(logger.log.callCount).to.be(22);26 expect(logger.log.getCall(0).args[0]).to.match(/transfer/i);27 expect(logger.log.getCall(1).args[0]).to.be('.');28 expect(logger.log.getCall(2).args[0]).to.be('.');29 expect(logger.log.getCall(3).args[0]).to.be('.');30 expect(logger.log.getCall(4).args[0]).to.be('.');31 expect(logger.log.getCall(5).args[0]).to.be('.');32 expect(logger.log.getCall(6).args[0]).to.be('.');33 expect(logger.log.getCall(7).args[0]).to.be('.');34 expect(logger.log.getCall(8).args[0]).to.be('.');35 expect(logger.log.getCall(9).args[0]).to.be('.');36 expect(logger.log.getCall(10).args[0]).to.be('.');37 expect(logger.log.getCall(11).args[0]).to.be('.');38 expect(logger.log.getCall(12).args[0]).to.be('.');39 expect(logger.log.getCall(13).args[0]).to.be('.');40 expect(logger.log.getCall(14).args[0]).to.be('.');41 expect(logger.log.getCall(15).args[0]).to.be('.');42 expect(logger.log.getCall(16).args[0]).to.be('.');43 expect(logger.log.getCall(17).args[0]).to.be('.');44 expect(logger.log.getCall(18).args[0]).to.be('.');45 expect(logger.log.getCall(19).args[0]).to.be('.');46 expect(logger.log.getCall(20).args[0]).to.be('.');47 expect(logger.log.getCall(21).args[0]).to.match(/complete/i);48 });49 it('should show dot for each 5% of completion', function () {50 progress.init(1000);51 expect(logger.log.callCount).to.be(1);52 progress.progress(50); //5%53 expect(logger.log.callCount).to.be(2);54 progress.progress(100); //15%55 expect(logger.log.callCount).to.be(4);56 progress.progress(200); //25%57 expect(logger.log.callCount).to.be(8);58 progress.progress(590); //94%59 expect(logger.log.callCount).to.be(20);60 progress.progress(60); //100%61 expect(logger.log.callCount).to.be(21);62 //Any progress over 100% should be ignored.63 progress.progress(9999);64 expect(logger.log.callCount).to.be(21);65 progress.complete();66 expect(logger.log.callCount).to.be(22);67 expect(logger.log.getCall(0).args[0]).to.match(/transfer/i);68 expect(logger.log.getCall(21).args[0]).to.match(/complete/i);69 });70 });71 });72 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import React from "react";2import { storiesOf } from "@storybook/react";3import { action } from "@storybook/addon-actions";4import Button from "./Button";5storiesOf("Button", module)6 .add("with text", () => <Button onClick={action("clicked")}>Hello Button</Button>)7 .add("with some emoji", () => (8 <Button onClick={action("clicked")}>πŸ˜€ 😎 πŸ‘ πŸ’―</Button>9 ));10import React from "react";11import { storiesOf } from "@storybook/react";12import { action } from "@storybook/addon-actions";13import Button from "./Button";14storiesOf("Button", module)15 .add("with text", () => <Button onClick={action("clicked")}>Hello Button</Button>)16 .add("with some emoji", () => (17 <Button onClick={action("clicked")}>πŸ˜€ 😎 πŸ‘ πŸ’―</Button>18 ));19import React from "react";20import { storiesOf } from "@storybook/react";21import { action } from "@storybook/addon-actions";22import Button from "./Button";23storiesOf("Button", module)24 .add("with text", () => <Button onClick={action("clicked")}>Hello Button</Button>)25 .add("with some emoji", () => (26 <Button onClick={action("clicked")}>πŸ˜€ 😎 πŸ‘ πŸ’―</Button>27 ));28import React from "react";29import { storiesOf } from "@storybook/react";30import { action } from "@storybook/addon-actions";31import Button from "./Button";32storiesOf("Button", module)33 .add("with text", () => <Button onClick={action("clicked")}>Hello Button</Button>)34 .add("with some emoji", () => (35 <Button onClick={action("clicked")}>πŸ˜€ 😎 πŸ‘ πŸ’―</Button>36 ));37import React from "react";38import { storiesOf } from "@storybook/react";39import { action } from "@storybook/addon-actions";40import Button from "./Button";41storiesOf("Button", module)42 .add("with text", () => <Button onClick={action("clicked")}>Hello Button</Button

Full Screen

Using AI Code Generation

copy

Full Screen

1import { getCall } from 'storybook-root';2import { getCall } from 'storybook-root';3import { getCall } from 'storybook-root';4import { getCall } from 'storybook-root';5import { getCall } from 'storybook-root';6import { getCall } from 'storybook-root';7import { getCall } from 'storybook-root';8import { getCall } from 'storybook-root';9import { getCall } from 'storybook-root';10import { getCall } from 'storybook-root';11import { getCall } from 'storybook-root';12import { getCall } from 'storybook-root';13import { getCall } from 'storybook-root';14import { getCall } from 'storybook-root';15import { getCall } from 'storybook-root';16import { getCall } from 'storybook-root';17import { getCall } from 'storybook-root';18import { getCall } from 'storybook-root';19import { getCall } from 'storybook-root';20import { getCall } from 'storybook-root';

Full Screen

Using AI Code Generation

copy

Full Screen

1import { getCall } from 'storybook-root';2const getCall = require('storybook-root').getCall;3const { getCall } = require('storybook-root');4const getCall = require('storybook-root/getCall');5const { getCall } = require('storybook-root/getCall');6const getCall = require('storybook-root/src/getCall');7const { getCall } = require('storybook-root/src/getCall');8const getCall = require('storybook-root/dist/getCall');9const { getCall } = require('storybook-root/dist/getCall');10const getCall = require('storybook-root/lib/getCall');11const { getCall } = require('storybook-root/lib/getCall');12import getCall from 'storybook-root/getCall';13import { getCall } from 'storybook-root/getCall';14import getCall from 'storybook-root/src/getCall';15import { getCall } from 'storybook-root/src/getCall';16import getCall from 'storybook-root/dist/getCall';17import { getCall } from 'storybook-root/dist/getCall';18import getCall from 'storybook-root/lib/getCall';19import { getCall } from 'storybook-root/lib/getCall';20import getCall from 'storybook-root';21import { getCall } from 'storybook-root';

Full Screen

Using AI Code Generation

copy

Full Screen

1import { getCall } from 'storybook-root';2getCall('test').then((res) => {3 console.log(res);4});5import { getCall } from 'storybook-root';6getCall('test').then((res) => {7 console.log(res);8});9import { getCall } from 'storybook-root';10getCall('test').then((res) => {11 console.log(res);12});13import { getCall } from 'storybook-root';14getCall('test').then((res) => {15 console.log(res);16});17import { getCall } from 'storybook-root';18getCall('test').then((res) => {19 console.log(res);20});21import { getCall } from 'storybook-root';22getCall('test').then((res) => {23 console.log(res);24});25import { getCall } from 'storybook-root';26getCall('test').then((res) => {27 console.log(res);28});29import { getCall } from 'storybook-root';30getCall('test').then((res) => {31 console.log(res);32});33import { getCall } from 'storybook-root';34getCall('test').then((res) => {35 console.log(res);36});37import { getCall } from 'storybook-root';38getCall('test').then((res) => {39 console.log(res);40});41import { getCall } from 'storybook-root';42getCall('test').then((res) => {43 console.log(res);44});45import { getCall

Full Screen

Using AI Code Generation

copy

Full Screen

1import { getCall } from 'storybook-root';2const myFunction = () => {3 getCall('myFunction', 'myFunction.js');4};5export default myFunction;6import { getCall } from 'storybook-root';7const myFunction = () => {8 getCall('myFunction', 'myFunction.js');9};10export default myFunction;11import { addons, makeDecorator } from '@storybook/addons';12import { STORY_RENDERED } from '@storybook/core-events';13const getCall = (functionName, fileName) => {14 const channel = addons.getChannel();15 channel.emit('storybook-root/getCall', {16 });17};18const withRoot = makeDecorator({19 wrapper: (getStory, context) => {20 const channel = addons.getChannel();21 channel.on('storybook-root/getCall', data => {22 console.log('getCall event called');23 console.log(data);24 });25 channel.emit(STORY_RENDERED, context.id);26 return getStory(context);27 },28});29export { getCall, withRoot };30import { addDecorator } from '@storybook/react';31import { withRoot } from 'storybook-root';32addDecorator(withRoot);33import { configure } from '@storybook/react';34import { addDecorator } from '@storybook/react';35import { withRoot } from 'storybook-root';36addDecorator(withRoot);37module.exports = ({ config }) => {38 config.resolve.alias['storybook-root'] = path.resolve(__dirname, '../storybook-root');39 return config;40};

Full Screen

Using AI Code Generation

copy

Full Screen

1import { getCall } from 'storybook-root';2const call = getCall('my-storybook');3call('my-action', { message: 'hello' });4import { getCall } from 'storybook-root';5export default (storyName, actionName, params) => {6 const call = getCall('my-storybook');7 return call('my-action', { message: 'hello' });8};9import { getCall } from 'storybook-root';10export default (storyName, actionName, params) => {11 const call = getCall('my-storybook');12 return call('my-action', { message: 'hello' });13};14import { getCall } from 'storybook-root';15export default (storyName, actionName, params) => {16 const call = getCall('my-storybook');17 return call('my-action', { message: 'hello' });18};19import { getCall } from 'storybook-root';20export default (storyName, actionName, params) => {21 const call = getCall('my-storybook');22 return call('my-action', { message: 'hello' });23};24import { getCall } from 'storybook-root';25export default (storyName, actionName, params) => {26 const call = getCall('my-storybook');27 return call('my-action', { message: 'hello' });28};29import { getCall } from 'storybook-root';30export default (storyName, actionName, params) => {31 const call = getCall('my-storybook');32 return call('my-action', { message: 'hello' });33};34import { getCall } from 'storybook-root';35export default (storyName, actionName, params) => {36 const call = getCall('my-storybook');37 return call('my-action

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run storybook-root automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful