|
1 | 1 | import { Utils } from './Utils'; |
| 2 | +import { expect } from 'chai'; |
2 | 3 |
|
3 | 4 | describe('Utils', () => { |
4 | 5 | it('should add range', () => { |
5 | 6 | let target: string[]; |
6 | | - expect(Utils.addRange(target)).toEqual([]); |
7 | | - expect(target).toBeUndefined(); |
| 7 | + expect(Utils.addRange(target)).to.eql([]); |
| 8 | + expect(target).to.be.undefined; |
8 | 9 |
|
9 | | - expect(Utils.addRange(target, '1', '2')).toEqual(['1', '2']); |
10 | | - expect(Utils.addRange(target, '1', '2')).toEqual(['1', '2']); |
| 10 | + expect(Utils.addRange(target, '1', '2')).to.eql(['1', '2']); |
| 11 | + expect(Utils.addRange(target, '1', '2')).to.eql(['1', '2']); |
11 | 12 |
|
12 | 13 | target = ['3']; |
13 | | - expect(Utils.addRange(target, '1', '2')).toEqual(['3', '1', '2']); |
14 | | - expect(target).toEqual(['3', '1', '2']); |
| 14 | + expect(Utils.addRange(target, '1', '2')).to.eql(['3', '1', '2']); |
| 15 | + expect(target).to.eql(['3', '1', '2']); |
15 | 16 | }); |
16 | 17 |
|
17 | 18 | describe('stringify', () => { |
@@ -61,53 +62,53 @@ describe('Utils', () => { |
61 | 62 | 'tags': [] |
62 | 63 | }; |
63 | 64 |
|
64 | | - expect(Utils.stringify(error)).toBe(JSON.stringify(error)); |
65 | | - expect(Utils.stringify([error, error])).toBe(JSON.stringify([error, error])); |
| 65 | + expect(Utils.stringify(error)).to.equal(JSON.stringify(error)); |
| 66 | + expect(Utils.stringify([error, error])).to.equal(JSON.stringify([error, error])); |
66 | 67 | }); |
67 | 68 |
|
68 | 69 | it('circular reference', () => { |
69 | 70 | let afoo: any = { a: 'foo' }; |
70 | 71 | afoo.b = afoo; |
71 | 72 |
|
72 | | - expect(Utils.stringify(afoo)).toBe('{"a":"foo"}'); |
73 | | - expect(Utils.stringify([{ one: afoo, two: afoo }])).toBe('[{"one":{"a":"foo"}}]'); |
| 73 | + expect(Utils.stringify(afoo)).to.equal('{"a":"foo"}'); |
| 74 | + expect(Utils.stringify([{ one: afoo, two: afoo }])).to.equal('[{"one":{"a":"foo"}}]'); |
74 | 75 | }); |
75 | 76 |
|
76 | 77 | it('should behave like JSON.stringify', () => { |
77 | | - expect(Utils.stringify(user)).toBe(JSON.stringify(user)); |
| 78 | + expect(Utils.stringify(user)).to.equal(JSON.stringify(user)); |
78 | 79 | }); |
79 | 80 |
|
80 | 81 | describe('with exclude pattern', () => { |
81 | 82 | it('pAssword', () => { |
82 | | - expect(Utils.stringify(user, ['pAssword'])).toBe('{"id":1,"name":"Blake","passwordResetToken":"a reset token","myPasswordValue":"123456","myPassword":"123456","customValue":"Password","value":{}}'); |
| 83 | + expect(Utils.stringify(user, ['pAssword'])).to.equal('{"id":1,"name":"Blake","passwordResetToken":"a reset token","myPasswordValue":"123456","myPassword":"123456","customValue":"Password","value":{}}'); |
83 | 84 | }); |
84 | 85 |
|
85 | 86 | it('*password', () => { |
86 | | - expect(Utils.stringify(user, ['*password'])).toBe('{"id":1,"name":"Blake","passwordResetToken":"a reset token","myPasswordValue":"123456","customValue":"Password","value":{}}'); |
| 87 | + expect(Utils.stringify(user, ['*password'])).to.equal('{"id":1,"name":"Blake","passwordResetToken":"a reset token","myPasswordValue":"123456","customValue":"Password","value":{}}'); |
87 | 88 | }); |
88 | 89 |
|
89 | 90 | it('password*', () => { |
90 | | - expect(Utils.stringify(user, ['password*'])).toBe('{"id":1,"name":"Blake","myPasswordValue":"123456","myPassword":"123456","customValue":"Password","value":{}}'); |
| 91 | + expect(Utils.stringify(user, ['password*'])).to.equal('{"id":1,"name":"Blake","myPasswordValue":"123456","myPassword":"123456","customValue":"Password","value":{}}'); |
91 | 92 | }); |
92 | 93 |
|
93 | 94 | it('*password*', () => { |
94 | | - expect(Utils.stringify(user, ['*password*'])).toBe('{"id":1,"name":"Blake","customValue":"Password","value":{}}'); |
| 95 | + expect(Utils.stringify(user, ['*password*'])).to.equal('{"id":1,"name":"Blake","customValue":"Password","value":{}}'); |
95 | 96 | }); |
96 | 97 |
|
97 | 98 | it('*Address', () => { |
98 | 99 | let event = { type: 'usage', source: 'about' }; |
99 | | - expect(Utils.stringify(event, ['*Address'])).toBe(JSON.stringify(event)); |
| 100 | + expect(Utils.stringify(event, ['*Address'])).to.equal(JSON.stringify(event)); |
100 | 101 | }); |
101 | 102 | }); |
102 | 103 | }); |
103 | 104 |
|
104 | 105 | it('should parse version from url', () => { |
105 | | - expect(Utils.parseVersion('https://code.jquery.com/jquery-2.1.3.js')).toBe('2.1.3'); |
106 | | - expect(Utils.parseVersion('//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css')).toBe('3.3.4'); |
107 | | - expect(Utils.parseVersion('https://cdnjs.cloudflare.com/ajax/libs/1140/2.0/1140.css')).toBe('2.0'); |
108 | | - expect(Utils.parseVersion('https://cdnjs.cloudflare.com/ajax/libs/Base64/0.3.0/base64.min.js')).toBe('0.3.0'); |
109 | | - expect(Utils.parseVersion('https://cdnjs.cloudflare.com/ajax/libs/angular-google-maps/2.1.0-X.10/angular-google-maps.min.js')).toBe('2.1.0-X.10'); |
110 | | - expect(Utils.parseVersion('https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/2.1.8-M1/swagger-ui.min.js')).toBe('2.1.8-M1'); |
111 | | - expect(Utils.parseVersion('https://cdnjs.cloudflare.com/BLAH/BLAH.min.js')).toBe(null); |
| 106 | + expect(Utils.parseVersion('https://code.jquery.com/jquery-2.1.3.js')).to.equal('2.1.3'); |
| 107 | + expect(Utils.parseVersion('//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css')).to.equal('3.3.4'); |
| 108 | + expect(Utils.parseVersion('https://cdnjs.cloudflare.com/ajax/libs/1140/2.0/1140.css')).to.equal('2.0'); |
| 109 | + expect(Utils.parseVersion('https://cdnjs.cloudflare.com/ajax/libs/Base64/0.3.0/base64.min.js')).to.equal('0.3.0'); |
| 110 | + expect(Utils.parseVersion('https://cdnjs.cloudflare.com/ajax/libs/angular-google-maps/2.1.0-X.10/angular-google-maps.min.js')).to.equal('2.1.0-X.10'); |
| 111 | + expect(Utils.parseVersion('https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/2.1.8-M1/swagger-ui.min.js')).to.equal('2.1.8-M1'); |
| 112 | + expect(Utils.parseVersion('https://cdnjs.cloudflare.com/BLAH/BLAH.min.js')).to.equal(null); |
112 | 113 | }); |
113 | 114 | }); |
0 commit comments