diff --git a/package.json b/package.json index c2c14d7..e21a05d 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,11 @@ "typescript", "cli-tool" ], + "main": "lib/index.js", + "module": "lib/index.js", + "bin": { + "glitch-deploy-tool": "lib/cli/index.js" + }, "private": false, "homepage": "https://github.com/TeamSTEP/glitch-deploy-tool", "bugs": { @@ -27,10 +32,6 @@ "darwin", "linux" ], - "module": "lib/index.js", - "bin": { - "glitch-deploy-tool": "lib/cli/index.js" - }, "scripts": { "start": "NODE_ENV=production ts-node -r dotenv/config src/index.ts", "dev": "NODE_ENV=development ts-node-dev -r dotenv/config src/index.ts", diff --git a/src/helpers/addNumber.ts b/src/helpers/addNumber.ts deleted file mode 100644 index dd074b3..0000000 --- a/src/helpers/addNumber.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const addNumbers = (...numbers: number[]) => { - return numbers.reduce((a, b) => a + b); -}; diff --git a/src/helpers/index.ts b/src/helpers/index.ts index ff092cd..3559101 100644 --- a/src/helpers/index.ts +++ b/src/helpers/index.ts @@ -1,2 +1 @@ -export * from './addNumber'; export * from './fileUtils'; diff --git a/tests/glitchApi.test.ts b/tests/glitchApi.test.ts new file mode 100644 index 0000000..708a2b2 --- /dev/null +++ b/tests/glitchApi.test.ts @@ -0,0 +1,53 @@ +import { GlitchProject } from '../src'; +import nock from 'nock'; + +describe('Importing Github repositories to Glitch', () => { + // set up a mock token and query params for the test + const token = '7dd3b76-a13c-a13c-a13c-152b3539bdcd'; + const projectId = '8c28b8-9db3-6098-1ab2-54e70d3347b4'; + const repo = 'userorg/project'; + const path = 'build'; + + beforeEach(() => { + nock.disableNetConnect(); + }); + + it('imports the given repo to Glitch with a status 200', async () => { + nock('https://api.glitch.com') + .post('/project/githubImport') + .query({ + authorization: token, + projectId, + repo, + path, + }) + .reply(200, { status: 200 }); + + const glitchApi = new GlitchProject(token, projectId); + const response = await glitchApi.importFromGithub(repo, path); + expect(response.status).toBe(200); + }); + + it('imports the given repo with a subdirectory in the parameter', async () => { + nock('https://api.glitch.com') + .post('/project/githubImport') + .query({ + authorization: token, + projectId, + repo, + path: '/', // default path + }) + .reply(200, { status: 200 }); + + const glitchApi = new GlitchProject(token, projectId); + const response = await glitchApi.importFromGithub(repo); + expect(response.status).toBe(200); + }); + + afterEach(() => { + nock.cleanAll(); + nock.enableNetConnect(); + }); + + //todo: add a unit test for GlitchGit class +}); diff --git a/tests/sample.test.ts b/tests/sample.test.ts deleted file mode 100644 index 5b373e4..0000000 --- a/tests/sample.test.ts +++ /dev/null @@ -1,10 +0,0 @@ -import * as Helpers from '../src/helpers'; - -// this is just a simple test starter for jest - -describe('simple math', () => { - it('should return a value that is the sum of two parameters', async () => { - const response = Helpers.addNumbers(2, 6); - expect(response).toEqual(8); - }); -});