Skip to content

Commit

Permalink
chore: add itly unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
j-luong committed Aug 31, 2023
1 parent 1f3d74a commit 393449b
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions src/test/unit/common/analytics/itly.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { strictEqual } from 'assert';
import { Iteratively } from '../../../../snyk/common/analytics/itly';
import { SnykConfiguration } from '../../../../snyk/common/configuration/snykConfiguration';
import { User } from '../../../../snyk/common/user';
import { LoggerMock } from '../../mocks/logger.mock';

suite.only('Iteratively', () => {
const snykConfig = {} as SnykConfiguration;
const isDevelopment = false;

suite('.load()', () => {
suite('when connecting to FEDRAMP endpoints', () => {
const isFedramp = true;
[true, false].forEach(shouldReportEvents => {
test(`Returns "null" when shouldReportEvents == ${shouldReportEvents}`, () => {
const iteratively = new Iteratively(
new User(),
new LoggerMock(),
shouldReportEvents,
isFedramp,
isDevelopment,
snykConfig,
);

const result = iteratively.load();

strictEqual(result, null);
});
});
});

suite('when connecting to non-FEDRAMP endpoints', () => {
const isFedramp = false;

test('Returns "null" when shouldReportEvents == false', () => {
const iteratively = new Iteratively(new User(), new LoggerMock(), false, isFedramp, isDevelopment, snykConfig);

const result = iteratively.load();

strictEqual(result, null);
});

test('Returns "Iteratively" when shouldReportEvents == true', () => {
const iteratively = new Iteratively(new User(), new LoggerMock(), true, isFedramp, isDevelopment, snykConfig);

const result = iteratively.load();

strictEqual(result instanceof Iteratively, true);
});
});
});
});

0 comments on commit 393449b

Please sign in to comment.