Sha256: 4669f1f98c804388d0211bc135529c37c11db4fe1705c8fc161f97f4e7e5de35

Contents?: true

Size: 1.89 KB

Versions: 117

Compression:

Stored size: 1.89 KB

Contents

import RotationalCipher from './rotational-cipher';

describe('Rotational cipher', () => {
  test('rotate a by 0, same output as input', () => {
    const expected = 'a';
    const actual = RotationalCipher.rotate('a', 0);

    expect(actual).toEqual(expected);
  });

  xtest('rotate a by 1', () => {
    const expected = 'b';
    const actual = RotationalCipher.rotate('a', 1);

    expect(actual).toEqual(expected);
  });

  xtest('rotate a by 26, same output as input', () => {
    const expected = 'a';
    const actual = RotationalCipher.rotate('a', 26);

    expect(actual).toEqual(expected);
  });

  xtest('rotate m by 13', () => {
    const expected = 'z';
    const actual = RotationalCipher.rotate('m', 13);

    expect(actual).toEqual(expected);
  });

  xtest('rotate n by 13 with wrap around alphabet', () => {
    const expected = 'a';
    const actual = RotationalCipher.rotate('n', 13);

    expect(actual).toEqual(expected);
  });

  xtest('rotate capital letters', () => {
    const expected = 'TRL';
    const actual = RotationalCipher.rotate('OMG', 5);

    expect(actual).toEqual(expected);
  });

  xtest('rotate spaces', () => {
    const expected = 'T R L';
    const actual = RotationalCipher.rotate('O M G', 5);

    expect(actual).toEqual(expected);
  });

  xtest('rotate numbers', () => {
    const expected = 'Xiwxmrk 1 2 3 xiwxmrk';
    const actual = RotationalCipher.rotate('Testing 1 2 3 testing', 4);

    expect(actual).toEqual(expected);
  });

  xtest('rotate punctuation', () => {
    const expected = 'Gzo\'n zvo, Bmviyhv!';
    const actual = RotationalCipher.rotate('Let\'s eat, Grandma!', 21);

    expect(actual).toEqual(expected);
  });

  xtest('rotate all letters', () => {
    const expected = 'Gur dhvpx oebja sbk whzcf bire gur ynml qbt.';
    const actual = RotationalCipher.rotate('The quick brown fox jumps over the lazy dog.', 13);

    expect(actual).toEqual(expected);
  });
});

Version data entries

117 entries across 117 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/ecmascript/exercises/rotational-cipher/rotational-cipher.spec.js
trackler-2.2.1.179 tracks/ecmascript/exercises/rotational-cipher/rotational-cipher.spec.js
trackler-2.2.1.178 tracks/ecmascript/exercises/rotational-cipher/rotational-cipher.spec.js
trackler-2.2.1.177 tracks/ecmascript/exercises/rotational-cipher/rotational-cipher.spec.js
trackler-2.2.1.176 tracks/ecmascript/exercises/rotational-cipher/rotational-cipher.spec.js
trackler-2.2.1.175 tracks/ecmascript/exercises/rotational-cipher/rotational-cipher.spec.js
trackler-2.2.1.174 tracks/ecmascript/exercises/rotational-cipher/rotational-cipher.spec.js
trackler-2.2.1.173 tracks/ecmascript/exercises/rotational-cipher/rotational-cipher.spec.js
trackler-2.2.1.172 tracks/ecmascript/exercises/rotational-cipher/rotational-cipher.spec.js
trackler-2.2.1.171 tracks/ecmascript/exercises/rotational-cipher/rotational-cipher.spec.js
trackler-2.2.1.170 tracks/ecmascript/exercises/rotational-cipher/rotational-cipher.spec.js
trackler-2.2.1.169 tracks/ecmascript/exercises/rotational-cipher/rotational-cipher.spec.js
trackler-2.2.1.167 tracks/ecmascript/exercises/rotational-cipher/rotational-cipher.spec.js
trackler-2.2.1.166 tracks/ecmascript/exercises/rotational-cipher/rotational-cipher.spec.js
trackler-2.2.1.165 tracks/ecmascript/exercises/rotational-cipher/rotational-cipher.spec.js
trackler-2.2.1.164 tracks/ecmascript/exercises/rotational-cipher/rotational-cipher.spec.js
trackler-2.2.1.163 tracks/ecmascript/exercises/rotational-cipher/rotational-cipher.spec.js
trackler-2.2.1.162 tracks/ecmascript/exercises/rotational-cipher/rotational-cipher.spec.js
trackler-2.2.1.161 tracks/ecmascript/exercises/rotational-cipher/rotational-cipher.spec.js
trackler-2.2.1.160 tracks/ecmascript/exercises/rotational-cipher/rotational-cipher.spec.js