Skip to content

Commit

Permalink
Merge pull request #186 from snyk-tech-services/feat/snykapiclient-test
Browse files Browse the repository at this point in the history
feat: prepare plugin for upcoming backend auth changes
  • Loading branch information
SnykOleg authored Apr 3, 2024
2 parents 6db390d + 2e414c5 commit 53cff4a
Show file tree
Hide file tree
Showing 7 changed files with 1,089 additions and 1,083 deletions.
2 changes: 1 addition & 1 deletion backstage.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "1.22.2"
"version": "1.25.0"
}
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
},
"scripts": {
"build": "yarn tsc",
"test": "snyk test"
"test": "backstage-cli test"
},
"dependencies": {
"@backstage/catalog-model": "^1.4.3",
"@backstage/core-components": "^0.13.10",
"@backstage/core-plugin-api": "^1.8.2",
"@backstage/plugin-catalog-react": "^1.9.3",
"@backstage/catalog-model": "^1.4.5",
"@backstage/core-components": "^0.14.3",
"@backstage/core-plugin-api": "^1.9.1",
"@backstage/plugin-catalog-react": "^1.11.2",
"@material-ui/icons": "4.11.3",
"@material-ui/lab": "4.0.0-alpha.61",
"@snyk/dep-graph": "2.8.1",
Expand All @@ -25,8 +25,9 @@
"react-use": "^17.4.0"
},
"devDependencies": {
"@backstage/cli": "^0.25.1",
"@backstage/dev-utils": "^1.0.26",
"@backstage/cli": "^0.26.2",
"@backstage/dev-utils": "^1.0.30",
"@backstage/test-utils": "^1.5.3",
"@testing-library/jest-dom": "^6.1.4",
"@testing-library/react": "^14.2.0",
"@testing-library/user-event": "^14.5.1",
Expand Down
21 changes: 21 additions & 0 deletions src/api/SnykApiClient.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { SnykApiClient } from './index';
import {MockConfigApi, MockFetchApi} from "@backstage/test-utils";
import { UrlPatternDiscovery } from '@backstage/core-app-api';

const EXAMPLE_ORG_ID = '361fd3c0-41d4-4ea4-ba77-09bb17890967';

describe('SnykApiClient', () => {
const mockBaseUrl = 'http://localhost:3000';
const configApi = new MockConfigApi({ 'snyk.mocked': false });
const discoveryApi = UrlPatternDiscovery.compile(mockBaseUrl);
const fetchApi = new MockFetchApi({});
const snykApiClient = new SnykApiClient({ discoveryApi, configApi, fetchApi });
describe('getCompleteProjectsListFromAnnotations', () => {
describe('when there are no annotations', () => {
it('should return an empty array', async () => {
const result = await snykApiClient.getCompleteProjectsListFromAnnotations(EXAMPLE_ORG_ID, {});
expect(result).toEqual([]);
});
});
});
});
Loading

0 comments on commit 53cff4a

Please sign in to comment.