Skip to content

Commit

Permalink
Applying fixes made to JavascriptHelper to JsBaseEngine.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Feb 18, 2010
1 parent 2209f19 commit 96bbbb2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cake/libs/view/helpers/js.php
Expand Up @@ -590,7 +590,7 @@ function object($data = array(), $options = array()) {

foreach ($data as $key => $val) {
if (is_array($val) || is_object($val)) {
$val = $this->object($val, $options);
$val = $this->object($val);
} else {
$val = $this->value($val);
}
Expand Down
9 changes: 8 additions & 1 deletion cake/tests/cases/libs/view/helpers/js.test.php
Expand Up @@ -502,7 +502,7 @@ function testSetVarsAtTopOfBufferedScripts() {
$this->Js->alert('hey you!', array('buffer' => true));
$this->Js->confirm('Are you sure?', array('buffer' => true));
$result = $this->Js->getBuffer(false);

$expected = 'window.app = {"height":"tall","color":"purple"};';
$this->assertEqual($result[0], $expected);
$this->assertEqual($result[1], 'alert("hey you!");');
Expand Down Expand Up @@ -665,6 +665,13 @@ function testObject() {
$result = $this->JsEngine->object($data);
$this->assertEqual($result, $expected);
}

$object = array('title' => 'New thing', 'indexes' => array(5, 6, 7, 8), 'object' => array('inner' => array('value' => 1)));
$result = $this->JsEngine->object($object, array('prefix' => 'PREFIX', 'postfix' => 'POSTFIX'));
$this->assertPattern('/^PREFIX/', $result);
$this->assertPattern('/POSTFIX$/', $result);
$this->assertNoPattern('/.PREFIX./', $result);
$this->assertNoPattern('/.POSTFIX./', $result);
}

/**
Expand Down

0 comments on commit 96bbbb2

Please sign in to comment.