Skip to content

Commit

Permalink
run tests in ci, remove tests from removed methods, jest config
Browse files Browse the repository at this point in the history
  • Loading branch information
giankotarola committed Jul 30, 2020
1 parent 62cd19d commit 51865fa
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 65 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ jobs:
matrix:
node-version: [10.x]
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
- uses: actions/checkout@v2
- uses: actions/setup-node@v2-beta
with:
node-version: '10.x'
- name: install dependencies
run: yarn install
- name: run lint
run: yarn lint
- name: run tests
run: yarn test --coverage
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
![Publish Action Status](https://github.com/FleekHQ/space-client/workflows/Publish/badge.svg?branch=master)
![Tests Action Status](https://github.com/FleekHQ/space-client/workflows/Tests/badge.svg)

# Space Client

## Overview
Expand Down
7 changes: 7 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
resetMocks: true,
testMatch: ['**/__tests__/**/*.+(ts)'],
transform: {
'^.+\\.(ts)$': 'ts-jest',
},
collectCoverageFrom: [
'src/{!(definitions),}',
],
globals: {
'ts-jest': {
tsConfig: 'tsconfig.json',
Expand Down
69 changes: 7 additions & 62 deletions src/__tests__/client-calls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ client.instance = {
joinBucket: jest.fn(),
shareItemsToSelectGroup: jest.fn(),
notificationSubscribe: jest.fn(),
getPublicKey: jest.fn(),
};

it('listDirectory makes the right requests', async () => {
Expand Down Expand Up @@ -89,51 +90,6 @@ it('createFolder makes the right requests', async () => {
expect(client.instance.createFolder).toHaveBeenCalledTimes(1);
});

it('createUsernameAndEmail makes the right requests', async () => {
client.createUsernameAndEmail({
email: '[email protected]',
username: 'fleek',
});

expect(client.instance.createUsernameAndEmail).toHaveBeenCalledTimes(1);
});

it('getIdentityByUsername makes the right requests', async () => {
client.getIdentityByUsername({
username: 'fleek',
});

expect(client.instance.getIdentityByUsername).toHaveBeenCalledTimes(1);
});

it('shareBucketViaEmail makes the right requests', async () => {
client.shareBucketViaEmail({
email: '[email protected]',
bucket: 'my-bucket',
});

expect(client.instance.shareBucketViaEmail).toHaveBeenCalledTimes(1);
});

it('shareBucketViaIdentity makes the right requests', async () => {
client.shareBucketViaIdentity({
identityType: 0,
identityValue: 'fleek',
bucket: 'my-bucket',
});

expect(client.instance.shareBucketViaIdentity).toHaveBeenCalledTimes(1);
});

it('generateFileShareLink makes the right requests', async () => {
client.generateFileShareLink({
filepath: '/',
bucket: 'my-bucket',
});

expect(client.instance.generateFileShareLink).toHaveBeenCalledTimes(1);
});

it('backupKeysByPassphrase makes the right requests', async () => {
client.backupKeysByPassphrase({
passphrase: '123',
Expand Down Expand Up @@ -196,25 +152,14 @@ it('joinBucket makes the right requests', async () => {
expect(client.instance.joinBucket).toHaveBeenCalledTimes(1);
});

it('should call shareItemsToSelectGroup', async () => {
const payload = {
bucket: 'test',
itemPaths: ['path/1/file.txt', 'path/2/key.txt'],
invitations: [
{
invitationType: 'INVITE_THROUGH_ADDRESS',
invitationValue: '[email protected]',
},
],
};

client.shareItemsToSelectGroup(payload);

expect(client.instance.shareItemsToSelectGroup).toHaveBeenCalledTimes(1);
});

it('notificationSubscribe makes the right requests', async () => {
client.notificationSubscribe({});

expect(client.instance.notificationSubscribe).toHaveBeenCalledTimes(1);
});

it('getPublicKey makes the right requests', async () => {
client.getPublicKey({});

expect(client.instance.getPublicKey).toHaveBeenCalledTimes(1);
});
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
],
"exclude": [
"dist",
"**/*.spec.ts"
"**/__tests__/*"
]
}

0 comments on commit 51865fa

Please sign in to comment.