Skip to content

Commit

Permalink
feat/improve-tests (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
RaresAil authored Dec 10, 2023
1 parent c0ccb3f commit 7cc49d0
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 14 deletions.
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

| Version | Supported |
| ------- | ------------------ |
| 1.5.x | :white_check_mark: |
| < 1.5 | :x: |
| 1.6.x | :white_check_mark: |
| < 1.6 | :x: |

## Reporting a Vulnerability

Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@raresail/prisma-mapper",
"version": "1.6.4",
"version": "1.6.5",
"description": "A CLI that adds @Map, @@Map, @updatedAt based on a json or camel case for the prisma schema",
"main": "bin/index.js",
"preferGlobal": true,
Expand Down Expand Up @@ -29,14 +29,14 @@
],
"homepage": "https://github.com/RaresAil/prisma-mapper",
"repository": "https://github.com/RaresAil/prisma-mapper.git",
"author": "RaresAil <ailincairares1@gmail.com>",
"author": "RaresAil <rares.ailincai@raresdesigns.com>",
"license": "Apache-2.0",
"private": false,
"scripts": {
"prepublishOnly": "yarn build",
"dev:bin": "yarn build && NODE_ENV=dev node bin/commands.js",
"dev": "NODE_ENV=dev ts-node src/commands.ts",
"build": "yarn lint && rm -rf ./bin/ && tsc -p .",
"build": "yarn lint && rimraf -rf ./bin/ && tsc -p .",
"lint": "eslint src/**/*.ts",
"test": "jest"
},
Expand All @@ -59,6 +59,7 @@
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-security": "^1.7.1",
"jest": "^29.7.0",
"rimraf": "^5.0.5",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.2",
"typescript": "5.3.3"
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/expected.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ model ModelOne {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
someId Int @unique @map("some_id")
json Json? @db.Json
jsonB Json? @map("json_b") @db.JsonB
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamptz(6)
deletedAt DateTime? @map("deleted_at") @db.Timestamptz(6)
Expand Down
10 changes: 8 additions & 2 deletions src/__tests__/map-multi-schema.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ describe('Test map command with multiSchema feature', () => {

mapCommand(programMock);

expectedPrisma = await fs.readFile(EXPECTED_PRISMA, 'utf-8');
expectedPrisma = (await fs.readFile(EXPECTED_PRISMA, 'utf-8')).replace(
/\r\n/g,
'\n'
);
});

it('command should pass', async () => {
Expand All @@ -35,7 +38,10 @@ describe('Test map command with multiSchema feature', () => {

expect(expectedPrisma).not.toEqual('');

const outputPrisma = await fs.readFile(OUTPUT_PRISMA, 'utf-8');
const outputPrisma = (await fs.readFile(OUTPUT_PRISMA, 'utf-8')).replace(
/\r\n/g,
'\n'
);
expect(outputPrisma).toEqual(expectedPrisma);
});

Expand Down
10 changes: 8 additions & 2 deletions src/__tests__/map.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ describe('Test map command', () => {

mapCommand(programMock);

expectedPrisma = await fs.readFile(EXPECTED_PRISMA, 'utf-8');
expectedPrisma = (await fs.readFile(EXPECTED_PRISMA, 'utf-8')).replace(
/\r\n/g,
'\n'
);
});

it('command should pass', async () => {
Expand All @@ -35,7 +38,10 @@ describe('Test map command', () => {

expect(expectedPrisma).not.toEqual('');

const outputPrisma = await fs.readFile(OUTPUT_PRISMA, 'utf-8');
const outputPrisma = (await fs.readFile(OUTPUT_PRISMA, 'utf-8')).replace(
/\r\n/g,
'\n'
);
expect(outputPrisma).toEqual(expectedPrisma);
});

Expand Down
1 change: 1 addition & 0 deletions src/__tests__/mock.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ model model_one {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
some_id Int @unique
json Json? @db.Json
json_b Json? @db.JsonB
created_at DateTime @default(now()) @db.Timestamptz(6)
updated_at DateTime? @db.Timestamptz(6)
deleted_at DateTime? @db.Timestamptz(6)
Expand Down
Loading

0 comments on commit 7cc49d0

Please sign in to comment.