Exemplo n.º 1
0
     it("returns prev value", function () {
         $collection = new Collection([1, 2, 3]);
         $collection->rewind();
         expect($collection->next())->toBe(2);
         expect($collection->next())->toBe(3);
         expect($collection->next())->toBe(null);
         $collection->end();
         expect($collection->prev())->toBe(2);
         expect($collection->prev())->toBe(1);
         expect($collection->prev())->toBe(null);
     });
 });
 describe("->first()/->rewind()/->end()", function () {
     it("returns respectively the first and the last item of the collection", function () {
         $collection = new Collection([1, 2, 3, 4, 5]);
         expect($collection->end())->toBe(5);
         expect($collection->rewind())->toBe(1);
         expect($collection->end())->toBe(5);
         expect($collection->first())->toBe(1);
     });
 });
 describe("->valid()", function () {
     it("returns true only when the collection is valid", function () {
         $collection = new Collection();
         expect($collection->valid())->toBe(false);
         $collection = new Collection([1, 5]);
         expect($collection->valid())->toBe(true);
     });
 });
 describe("->count()", function () {
     it("returns 0 on empty", function () {