Allow response in webviewclosed event to optionally be URI encoded

This commit is contained in:
Keegan
2016-06-14 22:57:36 -07:00
parent 87807f180c
commit c3c8de77fc
3 changed files with 20 additions and 2 deletions
+17 -1
View File
@@ -239,7 +239,7 @@ describe('Clay', function() {
});
describe('.getSettings', function() {
it('stores the response to localStorage and returns the decoded data',
it('it writes to localStorage and returns the data when input is encoded',
function() {
var clay = fixture.clay([]);
var settings = encodeURIComponent(JSON.stringify({
@@ -255,6 +255,22 @@ describe('Clay', function() {
assert.deepEqual(result, expected);
});
it('it writes to localStorage and returns the data when input is not encoded',
function() {
var clay = fixture.clay([]);
var settings = JSON.stringify({
key1: 'value1',
key2: {value: 'value2%7Dbreaks'}
});
var expected = {
key1: 'value1',
key2: 'value2%7Dbreaks'
};
var result = clay.getSettings(settings);
assert.equal(localStorage.getItem('clay-settings'), JSON.stringify(expected));
assert.deepEqual(result, expected);
});
it('does not store the response if it is invalid JSON and logs an error',
function() {
var clay = fixture.clay([]);