FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Adding testcases for permutations by AditiJain2826 · Pull Request #199 · mgechev/javascript-algorithms · GitHub

Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
22 changes: 22 additions & 0 deletions test/combinatorics/permutations.spec.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
var mod = require('../../src/combinatorics/permutations');
var permutations = mod.permutations;

describe('permutations', function () {
'use strict';

it('should return array of length 2 for 2 value permutation.', function () {
const result = permutations(['hello', 'world']);
expect(result.length).toBe(2);
expect(result).toEqual([['hello', 'world'], ['world', 'hello']]);
});

it('should return array of length 6 for 3 value permutations.', function () {
const result = permutations(['apple', 'orange', 'pear']);
expect(result.length).toBe(6);
expect(result).toEqual([['apple', 'orange', 'pear'], ['apple', 'pear', 'orange'], ['orange', 'apple', 'pear'], ['orange', 'pear', 'apple'], ['pear', 'orange', 'apple'], ['pear', 'apple', 'orange']]);
});

it('should return array of length 24 for 4 value permutations.', function () {
expect(permutations(['apple', 'mango', 'orange', 'pear']).length).toBe(24);
});
});

Back | FazBrowse Home | New Git URL