removed count() from docs/tests

This commit is contained in:
Geoff Doty 2018-05-06 18:28:53 -04:00
parent 372b0e5179
commit 37f7cf0fe1
2 changed files with 19 additions and 25 deletions

View File

@ -91,10 +91,6 @@ let removed = collection.remove({"type": "cat"});
Returns **[array][7]** records removed Returns **[array][7]** records removed
## count
Returns **[number][9]** count of records in collection
[1]: #constructor [1]: #constructor
[2]: #add [2]: #add
@ -110,5 +106,3 @@ Returns **[number][9]** count of records in collection
[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array [7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String [8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number

View File

@ -1,36 +1,36 @@
const test = require('tape'); const test = require("tape");
const Record = require('../src/record.js'); const Record = require("../src/record.js");
test('Record.js', function(t) { test("Record.js", function(t) {
let pets; let pets;
t.test('setup', function(t) { t.test("setup", function(t) {
pets = new Record(); pets = new Record();
t.ok(Record, 'Record should exist'); t.ok(Record, "Record should exist");
t.ok(pets, 'new collection should have been created'); t.ok(pets, "new collection should have been created");
t.end(); t.end();
}); });
t.test('should add 3 records one-by-one', function(t) { t.test("should add 3 records one-by-one", function(t) {
t.ok(pets.add, 'add method exists'); t.ok(pets.add, "add method exists");
let plato = pets.add({"name": "plato", "type": "dog"}); let plato = pets.add({"name": "plato", "type": "dog"});
let socrates = pets.add({"id": "1", "name": "socrates", "type": "dog"}); let socrates = pets.add({"id": "1", "name": "socrates", "type": "dog"});
let hypatia = pets.add({"name": "hypatia", "type": "cat"}); let hypatia = pets.add({"name": "hypatia", "type": "cat"});
t.equal(plato.name, 'plato', 'plato should have been added'); t.equal(plato.name, "plato", "plato should have been added");
t.equal(socrates.name, 'socrates', 'socrates should have been added'); t.equal(socrates.name, "socrates", "socrates should have been added");
t.equal(hypatia.name, 'hypatia', 'hypatia should have been added'); t.equal(hypatia.name, "hypatia", "hypatia should have been added");
t.ok(plato.id, 'platos record id should be auto-generated'); t.ok(plato.id, "platos record id should be auto-generated");
t.equal(socrates.id, "1",'socrates record id should not be auto-generated'); t.equal(socrates.id, "1","socrates record id should not be auto-generated");
t.end(); t.end();
}); });
t.test('should be 3 records', function(t) { t.test("should be 3 records", function(t) {
t.equal(pets.count(), 3); t.equal(pets.find().length, 3);
t.end(); t.end();
}); });
@ -38,17 +38,17 @@ test('Record.js', function(t) {
let dogs = pets.find({"type": "dog"}); let dogs = pets.find({"type": "dog"});
t.equal(dogs.length, 2, "should be 2 dogs in the house"); t.equal(dogs.length, 2, "should be 2 dogs in the house");
t.equal(pets.count(), 3, "but should still have 3 pets"); t.equal(pets.find().length, 3, "but should still have 3 pets");
t.end(); t.end();
}); });
t.test('should be able to remove a record', function() { t.test("should be able to remove a record", function() {
let hypatia = pets.remove({"name": "hypatia"}); let hypatia = pets.remove({"name": "hypatia"});
t.equal(hypatia[0].name, 'hypatia', 'hypatia should be removed'); t.equal(hypatia[0].name, "hypatia", "hypatia should be removed");
t.equal(pets.count(), 2, 'yes, hypatia has left the building'); t.equal(pets.find().length, 2, "yes, hypatia has left the building");
t.end(); t.end();
}); });