--- a/services/common/tests/unit/test_canonicaljson.js
+++ b/services/common/tests/unit/test_canonicaljson.js
@@ -1,62 +1,60 @@
const { CanonicalJSON } = Cu.import("resource://services-common/canonical-json.js");
function stringRepresentation(obj) {
const clone = JSON.parse(JSON.stringify(obj));
return JSON.stringify(clone);
}
add_task(function* test_canonicalJSON_should_preserve_array_order() {
- const input = ['one', 'two', 'three'];
- // No sorting should be done on arrays.
- do_check_eq(CanonicalJSON.stringify(input), '["one","two","three"]');
+ const input = ['one', 'two', 'three'];
+ // No sorting should be done on arrays.
+ do_check_eq(CanonicalJSON.stringify(input), '["one","two","three"]');
});
add_task(function* test_canonicalJSON_orders_object_keys() {
- const input = [{
- b: ['two', 'three'],
- a: ['zero', 'one']
- }];
-
- do_check_eq(
- CanonicalJSON.stringify(input),
- '[{"a":["zero","one"],"b":["two","three"]}]'
- );
+ const input = [{
+ b: ['two', 'three'],
+ a: ['zero', 'one']
+ }];
+ do_check_eq(
+ CanonicalJSON.stringify(input),
+ '[{"a":["zero","one"],"b":["two","three"]}]'
+ );
});
add_task(function* test_canonicalJSON_orders_nested_object_keys() {
- const input = [{
- b: {d: 'd', c: 'c'},
- a: {b: 'b', a: 'a'}
- }];
-
- do_check_eq(
- CanonicalJSON.stringify(input),
- '[{"a":{"a":"a","b":"b"},"b":{"c":"c","d":"d"}}]'
- );
+ const input = [{
+ b: {d: 'd', c: 'c'},
+ a: {b: 'b', a: 'a'}
+ }];
+ do_check_eq(
+ CanonicalJSON.stringify(input),
+ '[{"a":{"a":"a","b":"b"},"b":{"c":"c","d":"d"}}]'
+ );
});
add_task(function* test_canonicalJSON_escapes_unicode_values() {
- do_check_eq(
- CanonicalJSON.stringify([{key: '✓'}]),
- '[{"key":"\\u2713"}]'
- );
- // Unicode codepoints should be output in lowercase.
- do_check_eq(
- CanonicalJSON.stringify([{key: 'é'}]),
- '[{"key":"\\u00e9"}]'
- );
+ do_check_eq(
+ CanonicalJSON.stringify([{key: '✓'}]),
+ '[{"key":"\\u2713"}]'
+ );
+ // Unicode codepoints should be output in lowercase.
+ do_check_eq(
+ CanonicalJSON.stringify([{key: 'é'}]),
+ '[{"key":"\\u00e9"}]'
+ );
});
add_task(function* test_canonicalJSON_escapes_unicode_object_keys() {
- do_check_eq(
- CanonicalJSON.stringify([{'é': 'check'}]),
- '[{"\\u00e9":"check"}]'
- );
+ do_check_eq(
+ CanonicalJSON.stringify([{'é': 'check'}]),
+ '[{"\\u00e9":"check"}]'
+ );
});
add_task(function* test_canonicalJSON_does_not_alter_input() {
const records = [
{'foo': 'bar', 'last_modified': '12345', 'id': '1'},
{'bar': 'baz', 'last_modified': '45678', 'id': '2'}
];