Change the ClayConfig.getSettings() method to convert data types to be compatible with sendAppMessage

This commit is contained in:
Keegan
2016-03-07 12:58:46 +11:00
parent d6659db3ac
commit 271a0d1cfd
4 changed files with 78 additions and 4 deletions
+30
View File
@@ -26,4 +26,34 @@ describe('Utils', function() {
);
});
});
describe('.prepareForAppMessage', function() {
it('converts an array correctly when array contains strings', function() {
assert.deepEqual(
utils.prepareForAppMessage(['one', 'two']),
['one', 0, 'two', 0]
);
});
it('converts an array correctly when array contains numbers', function() {
assert.deepEqual(utils.prepareForAppMessage([1, 2, 3]), [1, 2, 3]);
});
it('converts an array correctly when array contains booleans', function() {
assert.deepEqual(utils.prepareForAppMessage([true, false, true]), [1, 0, 1]);
});
it('converts booleans to ints', function() {
assert.strictEqual(utils.prepareForAppMessage(false), 0);
assert.strictEqual(utils.prepareForAppMessage(true), 1);
});
it('leaves strings alone', function() {
assert.strictEqual(utils.prepareForAppMessage('test'), 'test');
});
it('leaves numbers alone', function() {
assert.strictEqual(utils.prepareForAppMessage(123), 123);
});
});
});