Skip to content

Commit

Permalink
Update tests to use the public entry point to the module (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
richvdh authored Nov 29, 2024
1 parent 39b253c commit 81a02f6
Show file tree
Hide file tree
Showing 20 changed files with 144 additions and 80 deletions.
15 changes: 10 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
"ruma",
"nio"
],
"main": "pkg/index.js",
"types": "pkg/index.d.ts",
"exports": {
".": {
"types": "./pkg/index.d.ts",
"default": "./pkg/index.js"
}
},
"files": [
"pkg/matrix_sdk_crypto_wasm_bg.wasm.js",
"pkg/matrix_sdk_crypto_wasm_bg.wasm.d.ts",
Expand All @@ -30,20 +34,21 @@
"@babel/core": "^7.23.5",
"@babel/preset-env": "^7.23.5",
"@babel/preset-typescript": "^7.23.3",
"@tsconfig/node18": "^18.2.4",
"@types/jest": "^29.5.10",
"babel-jest": "^29.7.0",
"cross-env": "^7.0.3",
"eslint": "^8.55.0",
"fake-indexeddb": "^4.0",
"jest": "^28.1.0",
"prettier": "^2.8.3",
"typedoc": "^0.22.17",
"typescript": "4.7",
"typedoc": "^0.27.1",
"typescript": "5.7.2",
"wasm-pack": "^0.12.1",
"yargs-parser": "~21.0.1"
},
"engines": {
"node": ">= 10"
"node": ">= 18"
},
"scripts": {
"lint": "npm run lint:eslint && npm run lint:prettier && npm run lint:types",
Expand Down
2 changes: 1 addition & 1 deletion tests/asyncload.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { UserId, initAsync } = require("../pkg");
const { UserId, initAsync } = require("@matrix-org/matrix-sdk-crypto-wasm");

test("can instantiate rust objects with async initialiser", async () => {
initUserId = () => new UserId("@foo:bar.org");
Expand Down
2 changes: 1 addition & 1 deletion tests/attachment.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { Attachment, EncryptedAttachment } = require("../pkg");
const { Attachment, EncryptedAttachment } = require("@matrix-org/matrix-sdk-crypto-wasm");

describe(Attachment.name, () => {
const originalData = "hello";
Expand Down
2 changes: 1 addition & 1 deletion tests/backup.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { BackupDecryptionKey } = require("../pkg");
const { BackupDecryptionKey } = require("@matrix-org/matrix-sdk-crypto-wasm");

const aMegolmKey = {
algorithm: "m.megolm.v1.aes-sha2",
Expand Down
2 changes: 1 addition & 1 deletion tests/dehydrated_devices.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
RoomId,
TrustRequirement,
UserId,
} from "../pkg/matrix_sdk_crypto_wasm";
} from "@matrix-org/matrix-sdk-crypto-wasm";
import "fake-indexeddb/auto";

afterEach(() => {
Expand Down
6 changes: 3 additions & 3 deletions tests/device.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ const {
Qr,
QrCode,
QrCodeScan,
} = require("../pkg");
} = require("@matrix-org/matrix-sdk-crypto-wasm");
const { zip, addMachineToMachine } = require("./helper");
const { VerificationRequestPhase, QrState } = require("../pkg");
const { VerificationRequestPhase, QrState } = require("@matrix-org/matrix-sdk-crypto-wasm");

// Uncomment to enable debug logging for tests
//const { Tracing, LoggerLevel } = require("../pkg");
//const { Tracing, LoggerLevel } = require("@matrix-org/matrix-sdk-crypto-wasm");
//new Tracing(LoggerLevel.Trace).turnOn();

describe("LocalTrust", () => {
Expand Down
9 changes: 8 additions & 1 deletion tests/ecies.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
const { Ecies, SecretsBundle, UserId, DeviceId, OlmMachine, RequestType } = require("../pkg/matrix_sdk_crypto_wasm");
const {
Ecies,
SecretsBundle,
UserId,
DeviceId,
OlmMachine,
RequestType,
} = require("@matrix-org/matrix-sdk-crypto-wasm");

describe(Ecies.name, () => {
test("can establish a channel and decrypt the initial message", () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/encryption.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const {
EncryptionSettings,
HistoryVisibility,
VerificationState,
} = require("../pkg");
} = require("@matrix-org/matrix-sdk-crypto-wasm");

describe("EncryptionAlgorithm", () => {
test("has the correct variant values", () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/events.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { HistoryVisibility } = require("../pkg");
const { HistoryVisibility } = require("@matrix-org/matrix-sdk-crypto-wasm");

describe("HistoryVisibility", () => {
test("has the correct variant values", () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/helper.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { DeviceLists, RequestType, KeysUploadRequest, KeysQueryRequest } = require("../pkg");
const { DeviceLists, RequestType, KeysUploadRequest, KeysQueryRequest } = require("@matrix-org/matrix-sdk-crypto-wasm");

function* zip(...arrays) {
const len = Math.min(...arrays.map((array) => array.length));
Expand Down
2 changes: 1 addition & 1 deletion tests/identifiers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const {
RoomId,
ServerName,
UserId,
} = require("../pkg");
} = require("@matrix-org/matrix-sdk-crypto-wasm");

describe(UserId.name, () => {
test("cannot be invalid", () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/libolm_migration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
StoreHandle,
Tracing,
UserId,
} from "../pkg";
} from "@matrix-org/matrix-sdk-crypto-wasm";

beforeAll(() => {
new Tracing(LoggerLevel.Trace).turnOn();
Expand Down
2 changes: 1 addition & 1 deletion tests/machine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
OtherUserIdentity,
VerificationRequest,
Versions,
} from "../pkg";
} from "@matrix-org/matrix-sdk-crypto-wasm";
import "fake-indexeddb/auto";
import * as crypto from "node:crypto";

Expand Down
2 changes: 1 addition & 1 deletion tests/qr_code.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { QrCodeData, QrCodeMode, Curve25519PublicKey } = require("../pkg/matrix_sdk_crypto_wasm");
const { QrCodeData, QrCodeMode, Curve25519PublicKey } = require("@matrix-org/matrix-sdk-crypto-wasm");

describe(QrCodeData.name, () => {
test("can parse the QR code bytes from the MSC", () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/requests.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const {
SignatureUploadRequest,
RoomMessageRequest,
KeysBackupRequest,
} = require("../pkg");
} = require("@matrix-org/matrix-sdk-crypto-wasm");

describe("RequestType", () => {
test("has the correct variant values", () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/sync_events.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { DeviceLists, UserId } = require("../pkg");
const { DeviceLists, UserId } = require("@matrix-org/matrix-sdk-crypto-wasm");

describe(DeviceLists.name, () => {
test("can be empty", () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/tracing.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { Tracing, LoggerLevel, OlmMachine, UserId, DeviceId } = require("../pkg");
const { Tracing, LoggerLevel, OlmMachine, UserId, DeviceId } = require("@matrix-org/matrix-sdk-crypto-wasm");

describe("LoggerLevel", () => {
test("has the correct variant values", () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/vodozemac_types.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { Curve25519PublicKey } = require("../pkg");
const { Curve25519PublicKey } = require("@matrix-org/matrix-sdk-crypto-wasm");

describe(Curve25519PublicKey.name, () => {
test("Can create a Curve25519PublicKey from a base64 string", async () => {
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "@tsconfig/node18/tsconfig.json",
"compilerOptions": {
"strict": true
"lib": ["DOM"]
},
"typedocOptions": {
"entryPoints": ["pkg/matrix_sdk_crypto_wasm.d.ts"],
Expand Down
Loading

0 comments on commit 81a02f6

Please sign in to comment.