Skip to content
This repository was archived by the owner on Aug 1, 2021. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion exercises/pangram/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ var notAlpha = /[^a-z]+/gi,
unique;

var Pangram = function(candidate) {
var msg = candidate || '';
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

had to add a missing null check

unique = {};
cleaned = (candidate.replace(notAlpha, '')).toLowerCase();
cleaned = (msg.replace(notAlpha, '')).toLowerCase();
cleaned.split('').forEach(function (el) {
unique[el] = true;
});
Expand Down
55 changes: 33 additions & 22 deletions exercises/pangram/pangram.spec.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,61 @@
var Pangram = require('./pangram');

describe('Pangram()', function() {
describe('Tests the Pangram checker.', function() {

it('empty sentence', function() {
it('can handle an empty sentence', function() {
var pangram = new Pangram('');
expect(pangram.isPangram()).toBe(false);
});

xit('pangram with only lower case', function() {
var pangram = new Pangram("the quick brown fox jumps over the lazy dog");
expect(pangram.isPangram()).toBe(true);
xit('handles an undefined message as empty message', function() {
var pangram = new Pangram();
expect(pangram.isPangram()).toBe(false);
});

xit("missing character 'x'", function() {
var pangram = new Pangram("a quick movement of the enemy will jeopardize five gunboats");
expect(pangram.isPangram()).toBe(false);
xit('recognizes a lower case pangram', function() {
var pangram = new Pangram('thequickbrownfoxjumpsoverthelazydog');
expect(pangram.isPangram()).toBe(true);
});

xit("another missing character 'x'", function() {
var pangram = new Pangram("the quick brown fish jumps over the lazy dog");
xit('recognizes a missing character', function() {
// missing 'x'
var pangram = new Pangram('aquickmovementoftheenemywilljeopardizefivegunboats');
expect(pangram.isPangram()).toBe(false);
// missing 'h'
var pangram = new Pangram('fiveboxingwizardsjumpquicklyatit');
expect(pangram.isPangram()).toBe(false);
});

xit("pangram with underscores", function() {
var pangram = new Pangram("the_quick_brown_fox_jumps_over_the_lazy_dog");
xit('recognizes an upper case pangram', function() {
var pangram = new Pangram('THEQUICKBROWNFOXJUMPSOVERTHELAZYDOG');
expect(pangram.isPangram()).toBe(true);
// missing 'G'
var pangram = new Pangram('THEQUICKBROWNFOXJUMPSOVERTHELAZYDOLL');
expect(pangram.isPangram()).toBe(false);
});

xit("pangram with numbers", function() {
var pangram = new Pangram("the 1 quick brown fox jumps over the 2 lazy dogs");
xit('recognizes a mixed case pangram', function() {
var pangram = new Pangram('ThEFiVebOxInGWiZaRdSJuMpqUiCkLy');
expect(pangram.isPangram()).toBe(true);
});

xit('missing letters replaced by numbers', function() {
var pangram = new Pangram("7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog");
// missing 'y'
var pangram = new Pangram('ThEFiVebOxInGWiZaRdSJuMpqUiCkL');
expect(pangram.isPangram()).toBe(false);
});

xit('pangram with mixed case and punctuation', function() {
var pangram = new Pangram("\"Five quacking Zephyrs jolt my wax bed.\"");
xit('ignores other characters', function() {
var pangram = new Pangram('Victor_jagt-zwölf.B0xkämpfer >qu3r< über; den \'großen" Sylter#Deich!');
expect(pangram.isPangram()).toBe(true);
// missing 'd'
var pangram = new Pangram('Victor_jagt-zwölf.B0xkämpfer >qu3r< über; einen \'großen" Sylter#Teich!');
expect(pangram.isPangram()).toBe(false);
});

xit('pangram with non-ascii characters', function() {
var pangram = new Pangram("Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich.");
xit('ignores non-ANSI characters', function() {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to bring Unicode to devs attention.

var pangram = new Pangram('Few quips galvanized the ① mock 😮 jury box 🗃️.');
expect(pangram.isPangram()).toBe(true);
// substituted 'v' with '℣'
var pangram = new Pangram('Few quips gal℣anized the ① mock 😮 jury box 🗃️.');
expect(pangram.isPangram()).toBe(false);
});

});