gristlabs_grist-core/test/common/CircularArray.js
Jarosław Sadziński a52d56f613 (core) Moving client and common tests to core
Summary:
- Moved /test/client and /test/common to core.
- Moved two files (CircularArray and RecentItems) from app/common to core/app/common.
- Moved resetOrg test to gen-server.
- `testrun.sh` is now invoking common and client test from core.
- Added missing packages to core's package.json (and revealed underscore as it is used in the main app).
- Removed Coord.js as it is not used anywhere.

Test Plan: Existing tests

Reviewers: paulfitz

Reviewed By: paulfitz

Subscribers: paulfitz

Differential Revision: https://phab.getgrist.com/D3590
2022-08-23 19:20:10 +02:00

39 lines
1.1 KiB
JavaScript

/* global describe, it */
var assert = require('assert');
var CircularArray = require('app/common/CircularArray');
describe("CircularArray", function() {
it("should lose old items", function() {
var c = new CircularArray(5);
assert.equal(c.maxLength, 5);
assert.equal(c.length, 0);
c.push("a");
assert.equal(c.get(0), "a");
c.push("b");
c.push("c");
assert.equal(c.length, 3);
assert.equal(c.get(2), "c");
assert.deepEqual(c.getArray(), ["a", "b", "c"]);
c.push("d");
c.push("e");
assert.equal(c.length, 5);
assert.equal(c.get(4), "e");
assert.deepEqual(c.getArray(), ["a", "b", "c", "d", "e"]);
c.push("f");
assert.equal(c.length, 5);
assert.equal(c.get(0), "b");
assert.equal(c.get(4), "f");
assert.deepEqual(c.getArray(), ["b", "c", "d", "e", "f"]);
c.push("g");
c.push("h");
c.push("i");
c.push("j");
assert.equal(c.length, 5);
assert.equal(c.get(0), "f");
assert.equal(c.get(4), "j");
assert.deepEqual(c.getArray(), ["f", "g", "h", "i", "j"]);
assert.equal(c.maxLength, 5);
});
});