Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tolga1452 committed Jul 12, 2023
1 parent 435c484 commit 6838d46
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
npm run build
- name: Tests
run: npm test
env:
TEST_KEY: ${{secrets.TEST_KEY}}
- name: Publish
run: npm publish --access public
env:
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Tests

on:
release:
types: [published]

jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- name: Build
run: |
npm install
npm ci
npm run build
- name: Run Tests
run: npm test
env:
TEST_KEY: ${{secrets.TEST_KEY}}
3 changes: 1 addition & 2 deletions __tests__/v1/Chat.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import Chat from '../../src/v1/classes/Chat';
import request from '../../src/v1/request';
import { apiKey } from '../../test.config';

import { CreateChatCompletionSettings, CreateChatCompletionResponse, RequestMethod, RequestEndpoint, CreateChatCompletionMessageRole, Model, PurGPTKey } from '../../src/v1/types';

jest.mock('../../src/v1/request');

describe('Chat', () => {
const key = apiKey as PurGPTKey;
const key = process.env.TEST_KEY as PurGPTKey;
const chat = new Chat(key);

afterEach(() => {
Expand Down
3 changes: 1 addition & 2 deletions __tests__/v1/Personalities.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import Personalities from '../../src/v1/classes/Personalities';
import request from '../../src/v1/request';
import { GetPersonalityResponse, Personality, RequestMethod, RequestEndpoint, PurGPTKey } from '../../src/v1/types';
import { apiKey } from '../../test.config';

jest.mock('../../src/v1/request');

describe('Personalities', () => {
const key = apiKey as PurGPTKey;
const key = process.env.TEST_KEY as PurGPTKey;
const personalities = new Personalities(key);

afterEach(() => {
Expand Down
3 changes: 1 addition & 2 deletions __tests__/v1/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import Chat from '../../src/v1/classes/Chat';
import Personalities from '../../src/v1/classes/Personalities';
import request from '../../src/v1/request';
import { CreateCompletionSettings, Model, PurGPTKey } from '../../src/v1/types';
import { apiKey } from '../../test.config';

jest.mock('../../src/v1/request');
jest.mock('../../src/v1/classes/Chat');
jest.mock('../../src/v1/classes/Personalities');

describe('PurGPT', () => {
const key = apiKey as PurGPTKey;
const key = process.env.TEST_KEY as PurGPTKey;
const purgpt = new PurGPT.PurGPT(key);

afterEach(() => {
Expand Down
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
"jest": "^29.5.0",
"ts-jest": "^29.1.0",
"ts-node-dev": "^2.0.0",
"typescript": "^5.0.4"
"typescript": "^5.0.4",
"@types/node": "^20.4.1",
"@types/typescript": "^2.0.0"
},
"jest": {
"moduleFileExtensions": [
Expand All @@ -51,9 +53,5 @@
"homepage": "https://github.com/Tolga1452/purgpt.js#readme",
"bugs": {
"url": "https://github.com/Tolga1452/purgpt.js/issues"
},
"dependencies": {
"@types/node": "^20.4.1",
"@types/typescript": "^2.0.0"
}
}
}

0 comments on commit 6838d46

Please sign in to comment.