Skip to content

Commit

Permalink
chore: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Romakita committed Sep 28, 2024
1 parent f2f8290 commit ed54e29
Show file tree
Hide file tree
Showing 64 changed files with 299 additions and 506 deletions.
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {join} from "node:path";

export default [
{
ignores: ["**/coverage", "**/lib", "**/dist", "processes.config.js", "**/templates", "**/docs/**", "**/docs-references/**"]
ignores: ["**/coverage", "**/lib", "**/dist", "processes.config.js", "**/snapshots", "**/templates", "**/docs/**", "**/docs-references/**"]
},
{
files: ["**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"],
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql/typegraphql/test/app/Server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "@tsed/ajv";
import "@tsed/graphql-ws";
import "@tsed/passport";
import "../..";
import "../../src/index.js";
import "./graphql/index.js";
import "./protocols/GraphQLProtocol.js";
import "./services/RecipeService.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {RESTDataSource} from "@apollo/datasource-rest";
import {ApolloContext} from "@tsed/apollo";
import {InjectContext} from "@tsed/common";

import {DataSource} from "../../../..";
import {DataSource} from "../../../../src/index.js";

@DataSource()
export class MyDataSource extends RESTDataSource {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {InjectContext, PlatformContext} from "@tsed/common";
import {Inject} from "@tsed/di";
import {Arg, Mutation, Query, Root, Subscription} from "type-graphql";

import {ResolverController} from "../../../..";
import {ResolverController} from "../../../../src/index.js";
import {RecipeService} from "../../services/RecipeService";
import {PubSubProvider} from "../pubsub/pubsub.js";
import {Recipe, RecipeNotification} from "./Recipe";
Expand Down
2 changes: 1 addition & 1 deletion packages/orm/adapters/src/adapters/FileSyncAdapter.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import faker from "@faker-js/faker";
import {faker} from "@faker-js/faker";
import {PlatformTest} from "@tsed/common";
import {Property} from "@tsed/schema";

Expand Down
4 changes: 2 additions & 2 deletions packages/orm/adapters/src/adapters/MemoryAdapter.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import faker from "@faker-js/faker";
import {faker} from "@faker-js/faker";
import {PlatformTest} from "@tsed/common";
import {deserialize} from "@tsed/json-mapper";
import {Format, getJsonSchema, Name, Property} from "@tsed/schema";
Expand Down Expand Up @@ -134,7 +134,7 @@ describe("MemoryAdapter", () => {
name: faker.name.jobTitle()
};

const client = await adapter.updateOne({_id: faker.datatype.uuid()}, base);
const client = await adapter.updateOne({_id: faker.string.uuid()}, base);

expect(client).toBeUndefined();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {DITest} from "@tsed/di";
import Redis from "ioredis";
import {Redis} from "ioredis";

import {registerConnectionProvider} from "./registerConnectionProvider.js";

Expand Down Expand Up @@ -38,7 +38,7 @@ vi.mock("ioredis", () => {
}
}

return {default: MockRedis};
return {Redis: MockRedis};
});

const REDIS_CONNECTION = Symbol.for("REDIS_CONNECTION");
Expand Down
4 changes: 2 additions & 2 deletions packages/orm/mongoose/test/buffer.integration.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import faker from "@faker-js/faker";
import {faker} from "@faker-js/faker";
import {PlatformTest} from "@tsed/common";
import {TestContainersMongo} from "@tsed/testcontainers-mongo";
import axios from "axios";
Expand All @@ -15,7 +15,7 @@ describe("Mongoose", () => {
"Should save and load buffer",
PlatformTest.inject([TestAvatar], async (avatarModel: MongooseModel<TestAvatar>) => {
const imageBuffer = await axios
.get(faker.image.people(256, 256), {
.get(faker.image.avatarGitHub(), {
responseType: "arraybuffer"
})
.then((response) => Buffer.from(response.data, "binary"));
Expand Down
2 changes: 1 addition & 1 deletion packages/orm/mongoose/test/helpers/Server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "../..";
import "../../src/index.js";
import "@tsed/platform-express";

import {Configuration, Inject, PlatformApplication} from "@tsed/common";
Expand Down
2 changes: 1 addition & 1 deletion packages/orm/mongoose/test/helpers/models/Customer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {CollectionOf} from "@tsed/schema";

import {Model, ObjectID, Ref} from "../../..";
import {Model, ObjectID, Ref} from "../../../src/index.js";
import {TestClient} from "./Client.js";
import {TestContract} from "./Contract.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/orm/mongoose/test/helpers/models/User.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {CollectionOf, Groups, Ignore, MinLength, Property, Required} from "@tsed/schema";

import {Model, MongooseNextCB, ObjectID, PostHook, PreHook, Ref, Schema, Unique} from "../../..";
import {Model, MongooseNextCB, ObjectID, PostHook, PreHook, Ref, Schema, Unique} from "../../../src/index.js";

export class BaseModel {
@ObjectID("id")
Expand Down
2 changes: 1 addition & 1 deletion packages/orm/mongoose/test/helpers/models/UserWorkspace.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {CollectionOf, Property} from "@tsed/schema";
import {Types} from "mongoose";

import {Model, MongooseModel, ObjectID, Ref, Schema} from "../../..";
import {Model, MongooseModel, ObjectID, Ref, Schema} from "../../../src/index.js";

@Model()
export class Workspace {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {PlatformTest} from "@tsed/common";
import {Property} from "@tsed/schema";
import {TestContainersMongo} from "@tsed/testcontainers-mongo";
import {afterEach, beforeEach, describe, expect, it} from "vitest";

import {Model, MongooseModel, MongooseService, ObjectID} from "..";
import {Model, MongooseModel, MongooseService, ObjectID} from "../src/index.js";
import {Server} from "./helpers/Server.js";

@Model({
Expand Down
6 changes: 3 additions & 3 deletions packages/orm/mongoose/test/ref-array.integration.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import faker from "@faker-js/faker";
import {faker} from "@faker-js/faker";
import {BodyParams, Controller, Get, Inject, PlatformTest, Post, QueryParams} from "@tsed/common";
import {deserialize, serialize} from "@tsed/json-mapper";
import {PlatformExpress} from "@tsed/platform-express";
Expand Down Expand Up @@ -36,12 +36,12 @@ class ProfilesCtrl {
async function getServiceFixture() {
const baseUser = {
email: faker.internet.email(),
password: faker.internet.password(12)
password: faker.internet.password({length: 12})
};

const baseProfile = {
image: faker.image.avatar(),
age: faker.datatype.number(2)
age: faker.number.int(2)
};

const repository = PlatformTest.get<ProfilesCtrl>(ProfilesCtrl)!;
Expand Down
6 changes: 3 additions & 3 deletions packages/orm/mongoose/test/ref.integration.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import faker from "@faker-js/faker";
import {faker} from "@faker-js/faker";
import {BodyParams, Controller, Get, Inject, PlatformTest, Post, QueryParams} from "@tsed/common";
import {deserialize, serialize} from "@tsed/json-mapper";
import {PlatformExpress} from "@tsed/platform-express";
Expand Down Expand Up @@ -35,12 +35,12 @@ class ProfilesCtrl {

const baseUser = {
email: faker.internet.email(),
password: faker.internet.password(12)
password: faker.internet.password({length: 12})
};

const baseProfile = {
image: faker.image.avatar(),
age: faker.datatype.number(2)
age: faker.number.int(2)
};

async function getServiceFixture() {
Expand Down
8 changes: 4 additions & 4 deletions packages/orm/mongoose/test/resources.integration.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import faker from "@faker-js/faker";
import {faker} from "@faker-js/faker";
import {BodyParams, Controller, Get, Inject, Injectable, PathParams, PlatformTest, Post} from "@tsed/common";
import {isArray} from "@tsed/core";
import {deserialize} from "@tsed/json-mapper";
Expand Down Expand Up @@ -75,7 +75,7 @@ class ResourcesCtrl {

await role.save();

user.name = faker.name.firstName();
user.name = faker.person.firstName();

user.roles = [role._id];

Expand All @@ -93,12 +93,12 @@ async function getServiceFixture() {

const baseUser = {
email: faker.internet.email(),
password: faker.internet.password(12)
password: faker.internet.password({length: 12})
};

const baseUser2 = {
email: faker.internet.email(),
password: faker.internet.password(12)
password: faker.internet.password({length: 12})
};

const currentUser2 = await repository.create(baseUser2);
Expand Down
6 changes: 3 additions & 3 deletions packages/orm/mongoose/test/user.integration.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import faker from "@faker-js/faker";
import {faker} from "@faker-js/faker";
import {PlatformTest} from "@tsed/common";
import {TestContainersMongo} from "@tsed/testcontainers-mongo";

Expand All @@ -16,7 +16,7 @@ describe("Mongoose", () => {
// GIVEN
const user = new userModel({
email: "[email protected]",
password: faker.internet.password(12)
password: faker.internet.password({length: 12})
});

// WHEN
Expand All @@ -42,7 +42,7 @@ describe("Mongoose", () => {
// GIVEN
const user = new userModel({
email: "[email protected]",
password: faker.internet.password(12)
password: faker.internet.password({length: 12})
});

// WHEN
Expand Down
2 changes: 1 addition & 1 deletion packages/orm/objection/test/helpers/Server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "../..";
import "../../src/index.js";
import "@tsed/platform-express";

import {Configuration, Inject, PlatformApplication} from "@tsed/common";
Expand Down
3 changes: 1 addition & 2 deletions packages/orm/objection/test/helpers/models/User.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {Groups, MaxLength, MinLength, Required} from "@tsed/schema";
import {Model} from "objection";

import {Entity} from "../../..";
import {IdColumn} from "../../../src/index.js";
import {Entity, IdColumn} from "../../../src/index.js";

@Entity("users")
export class User extends Model {
Expand Down
2 changes: 1 addition & 1 deletion packages/platform/common/test/integration/groups.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import cookieParser from "cookie-parser";
import methodOverride from "method-override";
import SuperTest from "supertest";

import {BodyParams, Configuration, Controller, Get, PlatformTest} from "../..";
import {BodyParams, Configuration, Controller, Get, PlatformTest} from "../../src/index.ts";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build

Expand Down
2 changes: 1 addition & 1 deletion packages/platform/common/test/integration/platform.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import cookieParser from "cookie-parser";
import methodOverride from "method-override";
import SuperTest from "supertest";

import {Configuration, Controller, Get, PlatformTest} from "../..";
import {Configuration, Controller, Get, PlatformTest} from "../../src/index.js";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build

Expand Down
5 changes: 1 addition & 4 deletions packages/platform/common/test/integration/route.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import {OperationVerbs} from "@tsed/schema";

import {All, Delete, EndpointMetadata, Get, Head, Options, Patch, Post, Put} from "../..";

const middleware: any = vi.fn();
const useStub: any = vi.fn().mockReturnValue(middleware);
import {All, Delete, EndpointMetadata, Get, Head, Options, Patch, Post, Put} from "../../src/index.js";

describe("Route decorators", () => {
describe("All", () => {
Expand Down
1 change: 1 addition & 0 deletions packages/platform/platform-exceptions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"@tsed/exceptions": "workspace:*",
"@tsed/schema": "workspace:*",
"@tsed/typescript": "workspace:*",
"ajv": "^8.17.1",
"eslint": "^8.57.0",
"typescript": "4.9.5",
"vitest": "2.0.4"
Expand Down
2 changes: 1 addition & 1 deletion packages/platform/platform-koa/test/app/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {$log, Controller, Get} from "@tsed/common";

import {PlatformKoa} from "../..";
import {PlatformKoa} from "../../src/index.js";
import {Server} from "./Server.js";

if (process.env.NODE_ENV !== "test") {
Expand Down
Loading

0 comments on commit ed54e29

Please sign in to comment.