Skip to content

Commit f924985

Browse files
committed
Added a test case that was breaking Utils.stringify
1 parent 1a61157 commit f924985

File tree

1 file changed

+50
-45
lines changed

1 file changed

+50
-45
lines changed

src/Utils-spec.ts

Lines changed: 50 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@ describe('Utils', () => {
1414
expect(target).toEqual(['3', '1', '2']);
1515
});
1616

17-
it('should stringify circular reference', () => {
18-
let afoo:any = {a: 'foo'};
19-
afoo.b = afoo;
20-
21-
expect(Utils.stringify(afoo)).toBe('{"a":"foo"}');
22-
expect(Utils.stringify([{one: afoo, two: afoo}])).toBe('[{"one":{"a":"foo"}}]');
23-
});
24-
2517
describe('stringify', () => {
2618
let user:any = {
2719
id:1,
@@ -36,6 +28,51 @@ describe('Utils', () => {
3628
}
3729
};
3830

31+
it('array', () => {
32+
let error = {
33+
'type': 'error',
34+
'data': {
35+
'@error': {
36+
'type': 'Error',
37+
'message': 'string error message',
38+
'stack_trace': [
39+
{
40+
'name': 'throwStringErrorImpl',
41+
'parameters': [],
42+
'file_name': 'http://localhost/index.js',
43+
'line_number': 22,
44+
'column': 9
45+
},
46+
{
47+
'name': 'throwStringError',
48+
'parameters': [],
49+
'file_name': 'http://localhost/index.js',
50+
'line_number': 10,
51+
'column': 10
52+
}, {
53+
'name': 'HTMLButtonElement.onclick',
54+
'parameters': [],
55+
'file_name': 'http://localhost/',
56+
'line_number': 22,
57+
'column': 10
58+
}]
59+
}, '@submission_method': 'onerror'
60+
},
61+
'tags': []
62+
};
63+
64+
expect(Utils.stringify(error)).toBe(JSON.stringify(error));
65+
expect(Utils.stringify([error, error])).toBe(JSON.stringify([error, error]));
66+
});
67+
68+
it('circular reference', () => {
69+
let afoo:any = {a: 'foo'};
70+
afoo.b = afoo;
71+
72+
expect(Utils.stringify(afoo)).toBe('{"a":"foo"}');
73+
expect(Utils.stringify([{one: afoo, two: afoo}])).toBe('[{"one":{"a":"foo"}}]');
74+
});
75+
3976
it('should behave like JSON.stringify', () => {
4077
expect(Utils.stringify(user)).toBe(JSON.stringify(user));
4178
});
@@ -56,44 +93,12 @@ describe('Utils', () => {
5693
it('*password*', () => {
5794
expect(Utils.stringify(user, ['*password*'])).toBe('{"id":1,"name":"Blake","customValue":"Password","value":{}}');
5895
});
59-
});
60-
});
6196

62-
it('should stringify array', () => {
63-
let error = {
64-
'type': 'error',
65-
'data': {
66-
'@error': {
67-
'type': 'Error',
68-
'message': 'string error message',
69-
'stack_trace': [
70-
{
71-
'name': 'throwStringErrorImpl',
72-
'parameters': [],
73-
'file_name': 'http://localhost/index.js',
74-
'line_number': 22,
75-
'column': 9
76-
},
77-
{
78-
'name': 'throwStringError',
79-
'parameters': [],
80-
'file_name': 'http://localhost/index.js',
81-
'line_number': 10,
82-
'column': 10
83-
}, {
84-
'name': 'HTMLButtonElement.onclick',
85-
'parameters': [],
86-
'file_name': 'http://localhost/',
87-
'line_number': 22,
88-
'column': 10
89-
}]
90-
}, '@submission_method': 'onerror'
91-
},
92-
'tags': []
93-
};
94-
95-
expect(Utils.stringify(error)).toBe(JSON.stringify(error));
96-
expect(Utils.stringify([error, error])).toBe(JSON.stringify([error, error]));
97+
it('*Address', () => {
98+
let event = {"type":"usage","source":"about" };
99+
expect(Utils.stringify(event, ['*Address'])).toBe(JSON.stringify(event));
100+
});
101+
});
97102
});
98103

99104
it('should parse version from url', () => {

0 commit comments

Comments
 (0)