Skip to content

Commit dba8c32

Browse files
committed
yarn prettier on webchannel_wrapper.test.ts
1 parent 0362147 commit dba8c32

File tree

1 file changed

+148
-58
lines changed

1 file changed

+148
-58
lines changed

packages/firestore/test/unit/core/webchannel_wrapper.test.ts

Lines changed: 148 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ describe('Integer', () => {
5353
expect(new Integer([0xffffffff, 1], 0).toNumber()).equals(8589934591);
5454
expect(new Integer([0, 2], 0).toNumber()).equals(8589934592);
5555
expect(new Integer([1, 2], 0).toNumber()).equals(8589934593);
56-
expect(new Integer([0x992ce530, 0xbc1f3bbb, 0x2080e2ee, 0xe53c0595], 0).toString()).equals("304704862073361391914321619654827369776");
56+
expect(
57+
new Integer(
58+
[0x992ce530, 0xbc1f3bbb, 0x2080e2ee, 0xe53c0595],
59+
0
60+
).toString()
61+
).equals('304704862073361391914321619654827369776');
5762
});
5863

5964
it('constructor should construct big negative values', () => {
@@ -69,39 +74,101 @@ describe('Integer', () => {
6974
expect(new Integer([0xf0000000], -1).toNumber()).equals(-268435456);
7075
expect(new Integer([0x00000001], -1).toNumber()).equals(-4294967295);
7176
expect(new Integer([0x00000000], -1).toNumber()).equals(-4294967296);
72-
expect(new Integer([0x00000000, 0xffffffff], -1).toNumber()).equals(-4294967296);
73-
expect(new Integer([0xffffffff, 0xfffffffe], -1).toNumber()).equals(-4294967297);
74-
expect(new Integer([0xfffffffe, 0xfffffffe], -1).toNumber()).equals(-4294967298);
77+
expect(new Integer([0x00000000, 0xffffffff], -1).toNumber()).equals(
78+
-4294967296
79+
);
80+
expect(new Integer([0xffffffff, 0xfffffffe], -1).toNumber()).equals(
81+
-4294967297
82+
);
83+
expect(new Integer([0xfffffffe, 0xfffffffe], -1).toNumber()).equals(
84+
-4294967298
85+
);
7586
});
7687

7788
it('add() should produce the sum of the two numbers', () => {
78-
expect(Integer.fromNumber(0).add(Integer.fromNumber(0)).toNumber()).equals(0);
79-
expect(Integer.fromNumber(1).add(Integer.fromNumber(1)).toNumber()).equals(2);
80-
expect(Integer.fromNumber(0xffffffff).add(Integer.fromNumber(1)).toNumber()).equals(4294967296);
81-
expect(Integer.fromString("304704862073361391914321619654827369776").add(Integer.fromString("77393247566944052149773810817307943505")).toString()).equals("382098109640305444064095430472135313281");
82-
expect(Integer.fromNumber(0).add(Integer.fromNumber(-1)).toNumber()).equals(-1);
89+
expect(Integer.fromNumber(0).add(Integer.fromNumber(0)).toNumber()).equals(
90+
0
91+
);
92+
expect(Integer.fromNumber(1).add(Integer.fromNumber(1)).toNumber()).equals(
93+
2
94+
);
95+
expect(
96+
Integer.fromNumber(0xffffffff).add(Integer.fromNumber(1)).toNumber()
97+
).equals(4294967296);
98+
expect(
99+
Integer.fromString('304704862073361391914321619654827369776')
100+
.add(Integer.fromString('77393247566944052149773810817307943505'))
101+
.toString()
102+
).equals('382098109640305444064095430472135313281');
103+
expect(Integer.fromNumber(0).add(Integer.fromNumber(-1)).toNumber()).equals(
104+
-1
105+
);
83106
});
84107

85108
it('multiply() should produce the product of the two numbers', () => {
86-
expect(Integer.fromNumber(0).multiply(Integer.fromNumber(0)).toNumber()).equals(0);
87-
expect(Integer.fromNumber(1).multiply(Integer.fromNumber(0)).toNumber()).equals(0);
88-
expect(Integer.fromNumber(1).multiply(Integer.fromNumber(1)).toNumber()).equals(1);
89-
expect(Integer.fromNumber(9).multiply(Integer.fromNumber(3)).toNumber()).equals(27);
90-
expect(Integer.fromNumber(0xffffffff).multiply(Integer.fromNumber(0xca11ba11)).toString()).equals("14560623649052575215");
91-
expect(Integer.fromString("304704862073361391914321619654827369776").multiply(Integer.fromString("77393247566944052149773810817307943505")).toString()).equals("23582098825295199538298333106941184620809785262540690532878112097410752504880");
92-
expect(Integer.fromNumber(5).multiply(Integer.fromNumber(-1)).toNumber()).equals(-5);
109+
expect(
110+
Integer.fromNumber(0).multiply(Integer.fromNumber(0)).toNumber()
111+
).equals(0);
112+
expect(
113+
Integer.fromNumber(1).multiply(Integer.fromNumber(0)).toNumber()
114+
).equals(0);
115+
expect(
116+
Integer.fromNumber(1).multiply(Integer.fromNumber(1)).toNumber()
117+
).equals(1);
118+
expect(
119+
Integer.fromNumber(9).multiply(Integer.fromNumber(3)).toNumber()
120+
).equals(27);
121+
expect(
122+
Integer.fromNumber(0xffffffff)
123+
.multiply(Integer.fromNumber(0xca11ba11))
124+
.toString()
125+
).equals('14560623649052575215');
126+
expect(
127+
Integer.fromString('304704862073361391914321619654827369776')
128+
.multiply(Integer.fromString('77393247566944052149773810817307943505'))
129+
.toString()
130+
).equals(
131+
'23582098825295199538298333106941184620809785262540690532878112097410752504880'
132+
);
133+
expect(
134+
Integer.fromNumber(5).multiply(Integer.fromNumber(-1)).toNumber()
135+
).equals(-5);
93136
});
94137

95138
it('modulo() should produce the division remainder of the two numbers', () => {
96-
expect(() => Integer.fromNumber(0).modulo(Integer.fromNumber(0))).to.throw("division by zero");
97-
expect(() => Integer.fromNumber(42).modulo(Integer.fromNumber(0))).to.throw("division by zero");
98-
expect(Integer.fromNumber(20).modulo(Integer.fromNumber(1)).toNumber()).equals(0);
99-
expect(Integer.fromNumber(2).modulo(Integer.fromNumber(2)).toNumber()).equals(0);
100-
expect(Integer.fromNumber(3).modulo(Integer.fromNumber(2)).toNumber()).equals(1);
101-
expect(Integer.fromNumber(4).modulo(Integer.fromNumber(2)).toNumber()).equals(0);
102-
expect(Integer.fromNumber(0xffffffff).modulo(Integer.fromNumber(0xca11ba11)).toNumber()).equals(904807918);
103-
expect(Integer.fromString("304704862073361391914321619654827369776").modulo(Integer.fromString("77393247566944052149773810817307943505")).toString()).equals("72525119372529235465000187202903539261");
104-
expect(Integer.fromString("304704862073361391914321619654827369776").modulo(Integer.fromNumber(313)).toNumber()).equals(167);
139+
expect(() => Integer.fromNumber(0).modulo(Integer.fromNumber(0))).to.throw(
140+
'division by zero'
141+
);
142+
expect(() => Integer.fromNumber(42).modulo(Integer.fromNumber(0))).to.throw(
143+
'division by zero'
144+
);
145+
expect(
146+
Integer.fromNumber(20).modulo(Integer.fromNumber(1)).toNumber()
147+
).equals(0);
148+
expect(
149+
Integer.fromNumber(2).modulo(Integer.fromNumber(2)).toNumber()
150+
).equals(0);
151+
expect(
152+
Integer.fromNumber(3).modulo(Integer.fromNumber(2)).toNumber()
153+
).equals(1);
154+
expect(
155+
Integer.fromNumber(4).modulo(Integer.fromNumber(2)).toNumber()
156+
).equals(0);
157+
expect(
158+
Integer.fromNumber(0xffffffff)
159+
.modulo(Integer.fromNumber(0xca11ba11))
160+
.toNumber()
161+
).equals(904807918);
162+
expect(
163+
Integer.fromString('304704862073361391914321619654827369776')
164+
.modulo(Integer.fromString('77393247566944052149773810817307943505'))
165+
.toString()
166+
).equals('72525119372529235465000187202903539261');
167+
expect(
168+
Integer.fromString('304704862073361391914321619654827369776')
169+
.modulo(Integer.fromNumber(313))
170+
.toNumber()
171+
).equals(167);
105172
});
106173

107174
it('compare() should correctly compare two numbers for order', () => {
@@ -113,14 +180,14 @@ describe('Integer', () => {
113180
Integer.fromNumber(1),
114181
Integer.fromNumber(2),
115182
Integer.fromNumber(0xffffffff),
116-
Integer.fromString("77393247566944052149773810817307943505"),
117-
Integer.fromString("304704862073361391914321619654827369776"),
183+
Integer.fromString('77393247566944052149773810817307943505'),
184+
Integer.fromString('304704862073361391914321619654827369776')
118185
]);
119186
for (let i1 = 0; i1 < numbers.length; i1++) {
120187
for (let i2 = 0; i2 < numbers.length; i2++) {
121188
const num1 = numbers[i1];
122189
const num2 = numbers[i2];
123-
const expected = (i1 == i2) ? 0 : ((i1 < i2) ? -1 : 1);
190+
const expected = i1 == i2 ? 0 : i1 < i2 ? -1 : 1;
124191
expect(num1.compare(num2)).equals(expected);
125192
}
126193
}
@@ -132,47 +199,70 @@ describe('Integer', () => {
132199
expect(Integer.fromNumber(0).toNumber()).equals(0);
133200
expect(Integer.fromNumber(1).toNumber()).equals(1);
134201
expect(Integer.fromNumber(-1).toNumber()).equals(-1);
135-
expect(Integer.fromNumber(Number.MAX_SAFE_INTEGER).toNumber()).equals(Number.MAX_SAFE_INTEGER);
136-
expect(Integer.fromNumber(Number.MIN_SAFE_INTEGER).toNumber()).equals(Number.MIN_SAFE_INTEGER);
137-
expect(Integer.fromNumber(Number.MAX_SAFE_INTEGER).add(one).toNumber()).equals(Number.MAX_SAFE_INTEGER + 1);
138-
expect(Integer.fromNumber(Number.MAX_SAFE_INTEGER).add(two).toNumber()).equals(Number.MAX_SAFE_INTEGER + 1);
202+
expect(Integer.fromNumber(Number.MAX_SAFE_INTEGER).toNumber()).equals(
203+
Number.MAX_SAFE_INTEGER
204+
);
205+
expect(Integer.fromNumber(Number.MIN_SAFE_INTEGER).toNumber()).equals(
206+
Number.MIN_SAFE_INTEGER
207+
);
208+
expect(
209+
Integer.fromNumber(Number.MAX_SAFE_INTEGER).add(one).toNumber()
210+
).equals(Number.MAX_SAFE_INTEGER + 1);
211+
expect(
212+
Integer.fromNumber(Number.MAX_SAFE_INTEGER).add(two).toNumber()
213+
).equals(Number.MAX_SAFE_INTEGER + 1);
139214
});
140215

141216
it('toString() should return the correct number', () => {
142217
const one = Integer.fromNumber(1);
143218
const two = Integer.fromNumber(2);
144-
expect(Integer.fromNumber(0).toString()).equals("0");
145-
expect(Integer.fromNumber(1).toString()).equals("1");
146-
expect(Integer.fromNumber(-1).toString()).equals("-1");
147-
expect(Integer.fromNumber(Number.MAX_SAFE_INTEGER).toString()).equals("9007199254740991");
148-
expect(Integer.fromNumber(Number.MIN_SAFE_INTEGER).toString()).equals("-9007199254740991");
149-
expect(Integer.fromNumber(Number.MAX_SAFE_INTEGER).add(one).toString()).equals("9007199254740992");
150-
expect(Integer.fromNumber(Number.MAX_SAFE_INTEGER).add(two).toString()).equals("9007199254740993");
151-
expect(Integer.fromString("304704862073361391914321619654827369776").toString()).equals("304704862073361391914321619654827369776");
152-
153-
expect(Integer.fromNumber(0).toString(2)).equals("0");
154-
expect(Integer.fromNumber(43981).toString(2)).equals("1010101111001101");
155-
expect(Integer.fromNumber(43981).toString(8)).equals("125715");
156-
expect(Integer.fromNumber(43981).toString(10)).equals("43981");
157-
expect(Integer.fromNumber(43981).toString(16)).equals("abcd");
219+
expect(Integer.fromNumber(0).toString()).equals('0');
220+
expect(Integer.fromNumber(1).toString()).equals('1');
221+
expect(Integer.fromNumber(-1).toString()).equals('-1');
222+
expect(Integer.fromNumber(Number.MAX_SAFE_INTEGER).toString()).equals(
223+
'9007199254740991'
224+
);
225+
expect(Integer.fromNumber(Number.MIN_SAFE_INTEGER).toString()).equals(
226+
'-9007199254740991'
227+
);
228+
expect(
229+
Integer.fromNumber(Number.MAX_SAFE_INTEGER).add(one).toString()
230+
).equals('9007199254740992');
231+
expect(
232+
Integer.fromNumber(Number.MAX_SAFE_INTEGER).add(two).toString()
233+
).equals('9007199254740993');
234+
expect(
235+
Integer.fromString('304704862073361391914321619654827369776').toString()
236+
).equals('304704862073361391914321619654827369776');
237+
238+
expect(Integer.fromNumber(0).toString(2)).equals('0');
239+
expect(Integer.fromNumber(43981).toString(2)).equals('1010101111001101');
240+
expect(Integer.fromNumber(43981).toString(8)).equals('125715');
241+
expect(Integer.fromNumber(43981).toString(10)).equals('43981');
242+
expect(Integer.fromNumber(43981).toString(16)).equals('abcd');
158243
});
159244

160245
it('fromNumber() create a new Integer with the given value', () => {
161246
// The tests for toString() and toNumber() cover this method.
162247
});
163248

164249
it('fromString() create a new Integer with the given value', () => {
165-
expect(Integer.fromString("0").toNumber()).equals(0);
166-
expect(Integer.fromString("1").toNumber()).equals(1);
167-
expect(Integer.fromString("-1").toNumber()).equals(-1);
168-
expect(Integer.fromString("42").toNumber()).equals(42);
169-
expect(Integer.fromString("9007199254740991").toNumber()).equals(Number.MAX_SAFE_INTEGER);
170-
expect(Integer.fromString("-9007199254740991").toNumber()).equals(Number.MIN_SAFE_INTEGER);
171-
expect(Integer.fromString("304704862073361391914321619654827369776").toString()).equals("304704862073361391914321619654827369776");
172-
173-
expect(Integer.fromString("abcd", 16).toNumber()).equals(43981);
174-
expect(Integer.fromString("125715", 8).toNumber()).equals(43981);
175-
expect(Integer.fromString("1010101111001101", 2).toNumber()).equals(43981);
176-
});
250+
expect(Integer.fromString('0').toNumber()).equals(0);
251+
expect(Integer.fromString('1').toNumber()).equals(1);
252+
expect(Integer.fromString('-1').toNumber()).equals(-1);
253+
expect(Integer.fromString('42').toNumber()).equals(42);
254+
expect(Integer.fromString('9007199254740991').toNumber()).equals(
255+
Number.MAX_SAFE_INTEGER
256+
);
257+
expect(Integer.fromString('-9007199254740991').toNumber()).equals(
258+
Number.MIN_SAFE_INTEGER
259+
);
260+
expect(
261+
Integer.fromString('304704862073361391914321619654827369776').toString()
262+
).equals('304704862073361391914321619654827369776');
177263

264+
expect(Integer.fromString('abcd', 16).toNumber()).equals(43981);
265+
expect(Integer.fromString('125715', 8).toNumber()).equals(43981);
266+
expect(Integer.fromString('1010101111001101', 2).toNumber()).equals(43981);
267+
});
178268
});

0 commit comments

Comments
 (0)