Uint8Array migration

This commit is contained in:
Fedor Indutny 2021-09-23 17:49:05 -07:00 committed by GitHub
parent daf75190b8
commit 4ef0bf96cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
137 changed files with 2202 additions and 3170 deletions

View file

@ -6,7 +6,7 @@ const sinon = require('sinon');
const Message = require('../../../js/modules/types/message');
const { SignalService } = require('../../../ts/protobuf');
const { stringToArrayBuffer } = require('../../../ts/util/stringToArrayBuffer');
const Bytes = require('../../../ts/Bytes');
describe('Message', () => {
const logger = {
@ -60,7 +60,7 @@ describe('Message', () => {
attachments: [
{
path: 'ab/abcdefghi',
data: stringToArrayBuffer('Its easy if you try'),
data: Bytes.fromString('Its easy if you try'),
},
],
};
@ -78,9 +78,9 @@ describe('Message', () => {
const writeExistingAttachmentData = attachment => {
assert.equal(attachment.path, 'ab/abcdefghi');
assert.deepEqual(
attachment.data,
stringToArrayBuffer('Its easy if you try')
assert.strictEqual(
Bytes.toString(attachment.data),
'Its easy if you try'
);
};
@ -101,7 +101,7 @@ describe('Message', () => {
{
thumbnail: {
path: 'ab/abcdefghi',
data: stringToArrayBuffer('Its easy if you try'),
data: Bytes.fromString('Its easy if you try'),
},
},
],
@ -126,9 +126,9 @@ describe('Message', () => {
const writeExistingAttachmentData = attachment => {
assert.equal(attachment.path, 'ab/abcdefghi');
assert.deepEqual(
attachment.data,
stringToArrayBuffer('Its easy if you try')
assert.strictEqual(
Bytes.toString(attachment.data),
'Its easy if you try'
);
};
@ -151,7 +151,7 @@ describe('Message', () => {
isProfile: false,
avatar: {
path: 'ab/abcdefghi',
data: stringToArrayBuffer('Its easy if you try'),
data: Bytes.fromString('Its easy if you try'),
},
},
},
@ -177,9 +177,9 @@ describe('Message', () => {
const writeExistingAttachmentData = attachment => {
assert.equal(attachment.path, 'ab/abcdefghi');
assert.deepEqual(
attachment.data,
stringToArrayBuffer('Its easy if you try')
assert.strictEqual(
Bytes.toString(attachment.data),
'Its easy if you try'
);
};
@ -268,7 +268,7 @@ describe('Message', () => {
{
contentType: 'audio/aac',
flags: SignalService.AttachmentPointer.Flags.VOICE_MESSAGE,
data: stringToArrayBuffer('Its easy if you try'),
data: Bytes.fromString('Its easy if you try'),
fileName: 'test\u202Dfig.exe',
size: 1111,
},
@ -292,12 +292,13 @@ describe('Message', () => {
contact: [],
};
const expectedAttachmentData = stringToArrayBuffer(
'Its easy if you try'
);
const expectedAttachmentData = 'Its easy if you try';
const context = {
writeNewAttachmentData: async attachmentData => {
assert.deepEqual(attachmentData, expectedAttachmentData);
assert.strictEqual(
Bytes.toString(attachmentData),
expectedAttachmentData
);
return 'abc/abcdefg';
},
getRegionCode: () => 'US',

View file

@ -1,23 +0,0 @@
// Copyright 2018-2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
require('mocha-testcheck').install();
const { assert } = require('chai');
const SchemaVersion = require('../../../js/modules/types/schema_version');
describe('SchemaVersion', () => {
describe('isValid', () => {
check.it('should return true for positive integers', gen.posInt, input => {
assert.isTrue(SchemaVersion.isValid(input));
});
check.it(
'should return false for any other value',
gen.primitive.suchThat(value => typeof value !== 'number' || value < 0),
input => {
assert.isFalse(SchemaVersion.isValid(input));
}
);
});
});