Sha256: 3ad032e8208b31bd8d8a70b4c8d1c12b7a95d69345403e18338d190374c0ac3c

Contents?: true

Size: 1.78 KB

Versions: 141

Compression:

Stored size: 1.78 KB

Contents

var LinkedList = require('./linked-list');

describe('LinkedList', function () {
  it('push/pop', function () {
    var list = new LinkedList();
    list.push(10);
    list.push(20);
    expect(list.pop()).toBe(20);
    expect(list.pop()).toBe(10);
  });
  xit('push/shift', function () {
    var list = new LinkedList();
    list.push(10);
    list.push(20);
    expect(list.shift()).toBe(10);
    expect(list.shift()).toBe(20);
  });
  xit('unshift/shift', function () {
    var list = new LinkedList();
    list.unshift(10);
    list.unshift(20);
    expect(list.shift()).toBe(20);
    expect(list.shift()).toBe(10);
  });
  xit('unshift/pop', function () {
    var list = new LinkedList();
    list.unshift(10);
    list.unshift(20);
    expect(list.pop()).toBe(10);
    expect(list.pop()).toBe(20);
  });
  xit('example', function () {
    var list = new LinkedList();
    list.push(10);
    list.push(20);
    expect(list.pop()).toBe(20);
    list.push(30);
    expect(list.shift()).toBe(10);
    list.unshift(40);
    list.push(50);
    expect(list.shift()).toBe(40);
    expect(list.pop()).toBe(50);
    expect(list.shift()).toBe(30);
  });
  xit('can count its elements', function () {
    var list = new LinkedList();
    expect(list.count()).toBe(0);
    list.push(10);
    expect(list.count()).toBe(1);
    list.push(20);
    expect(list.count()).toBe(2);
  });
  xit('deletes the last element from the list', function () {
    var list = new LinkedList();
    list.push(10);
    list.push(20);
    list.push(30);
    list.delete(20);
    expect(list.count()).toBe(2);
    expect(list.pop()).toBe(30);
    expect(list.shift()).toBe(10);
  });
  xit('deletes the only element', function () {
    var list = new LinkedList();
    list.push(10);
    list.delete(10);

    expect(list.count()).toBe(0);
  });
});

Version data entries

141 entries across 141 versions & 1 rubygems

Version Path
trackler-2.2.1.139 tracks/javascript/exercises/linked-list/linked-list.spec.js
trackler-2.2.1.138 tracks/javascript/exercises/linked-list/linked-list.spec.js
trackler-2.2.1.137 tracks/javascript/exercises/linked-list/linked-list.spec.js
trackler-2.2.1.136 tracks/javascript/exercises/linked-list/linked-list.spec.js
trackler-2.2.1.135 tracks/javascript/exercises/linked-list/linked-list.spec.js
trackler-2.2.1.134 tracks/javascript/exercises/linked-list/linked-list.spec.js
trackler-2.2.1.133 tracks/javascript/exercises/linked-list/linked-list.spec.js
trackler-2.2.1.132 tracks/javascript/exercises/linked-list/linked-list.spec.js
trackler-2.2.1.131 tracks/javascript/exercises/linked-list/linked-list.spec.js
trackler-2.2.1.130 tracks/javascript/exercises/linked-list/linked-list.spec.js
trackler-2.2.1.129 tracks/javascript/exercises/linked-list/linked-list.spec.js
trackler-2.2.1.128 tracks/javascript/exercises/linked-list/linked-list.spec.js
trackler-2.2.1.127 tracks/javascript/exercises/linked-list/linked-list.spec.js
trackler-2.2.1.126 tracks/javascript/exercises/linked-list/linked-list.spec.js
trackler-2.2.1.125 tracks/javascript/exercises/linked-list/linked-list.spec.js
trackler-2.2.1.124 tracks/javascript/exercises/linked-list/linked-list.spec.js
trackler-2.2.1.123 tracks/javascript/exercises/linked-list/linked-list.spec.js
trackler-2.2.1.122 tracks/javascript/exercises/linked-list/linked-list.spec.js
trackler-2.2.1.121 tracks/javascript/exercises/linked-list/linked-list.spec.js
trackler-2.2.1.120 tracks/javascript/exercises/linked-list/linked-list.spec.js