FIX: Trim whitespaces and do a global replace.

This commit is contained in:
Guo Xiang Tan 2016-06-16 16:35:23 +08:00
parent ab11251f63
commit 4df224bb79
No known key found for this signature in database
GPG Key ID: 19C321C8952B0F72
2 changed files with 5 additions and 5 deletions

View File

@ -91,7 +91,7 @@ export default Ember.Controller.extend({
let pollHeader = '[poll';
let output = '';
if (pollName) pollHeader += ` name=${pollName.replace(' ', '-')}`;
if (pollName) pollHeader += ` name=${pollName.trim().replace(/\s/g, '-')}`;
if (pollType) pollHeader += ` type=${pollType}`;
if (pollMin && showMinMax) pollHeader += ` min=${pollMin}`;
if (pollMax) pollHeader += ` max=${pollMax}`;

View File

@ -169,17 +169,17 @@ test("number pollOutput", function() {
equal(controller.get("pollOutput"), "[poll name=test type=number min=1 max=20 step=1]\n[/poll]", "it should return the right output");
controller.set("pollName", 'test poll');
controller.set("pollName", ' test poll more ');
equal(controller.get("pollOutput"), "[poll name=test-poll type=number min=1 max=20 step=1]\n[/poll]", "it should return the right output");
equal(controller.get("pollOutput"), "[poll name=test-poll-more type=number min=1 max=20 step=1]\n[/poll]", "it should return the right output");
controller.set("pollStep", 2);
equal(controller.get("pollOutput"), "[poll name=test-poll type=number min=1 max=20 step=2]\n[/poll]", "it should return the right output");
equal(controller.get("pollOutput"), "[poll name=test-poll-more type=number min=1 max=20 step=2]\n[/poll]", "it should return the right output");
controller.set("publicPoll", true);
equal(controller.get("pollOutput"), "[poll name=test-poll type=number min=1 max=20 step=2 public=true]\n[/poll]", "it should return the right output");
equal(controller.get("pollOutput"), "[poll name=test-poll-more type=number min=1 max=20 step=2 public=true]\n[/poll]", "it should return the right output");
});
test("regular pollOutput", function() {