Skip to content

Commit

Permalink
Testing for Joomla.getOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedik committed Aug 21, 2016
1 parent dae97f2 commit 0b02d96
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/javascript/core/fixtures/fixture.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,11 @@
<form id="table-ordering-test-form">
</form>
</div>
<div id="get-options">
<script type="application/json" id="joomla-script-options">{
"com_foobar": ["my options"],
"com_foobar2": "Alert message!",
"com_foobar3": false
}</script>
</div>
</div>
18 changes: 18 additions & 0 deletions tests/javascript/core/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,22 @@ define(['jquery', 'testsRoot/core/spec-setup', 'jasmineJquery'], function ($) {
expect(this.form.filter_order_Dir.value).toEqual('dir')
});
});

describe('Core Joomla.getOptions', function () {
it('should be Joomla.optionsStorage = null', function () {
expect(Joomla.optionsStorage).toEqual(null)
});
it('should return options array Joomla.getOptions("com_foobar")', function () {
expect(Joomla.getOptions("com_foobar")).toEqual(["my options"])
});
it('should return option string Joomla.getOptions("com_foobar2")', function () {
expect(Joomla.getOptions("com_foobar2")).toEqual("Alert message!")
});
it('should return option Boolean false Joomla.getOptions("com_foobar3")', function () {
expect(Joomla.getOptions("com_foobar3")).toEqual(false)
});
it('should return default value for not existing key Joomla.getOptions("com_foobar4", 123)', function () {
expect(Joomla.getOptions("com_foobar4", 123)).toEqual(123)
});
});
});

0 comments on commit 0b02d96

Please sign in to comment.