Skip to content

Commit

Permalink
test: adjust specs structure
Browse files Browse the repository at this point in the history
  • Loading branch information
pmstss committed Jul 15, 2024
1 parent 72fd6b5 commit 231286f
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 43 deletions.
38 changes: 20 additions & 18 deletions test/sec/fn-date.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,25 @@ describe('DateService', () => {

afterEach(() => runner.clear());

it('calculateWeekdays() should not have DATE_MANIPULATION', async () => {
type FnArgs = {
from: string;
to: string;
};
const inputSample: FnArgs = {
from: '2022-11-30',
to: '2024-06-21'
};
const fn = ({ from, to }: FnArgs) =>
dateService.calculateWeekdays(from, to);

await runner
.createScan({
name: expect.getState().currentTestName,
tests: [TestType.DATE_MANIPULATION]
})
.run({ inputSample, fn });
describe('calculateWeekdays', () => {
it('should not have DATE_MANIPULATION', async () => {
type FnArgs = {
from: string;
to: string;
};
const inputSample: FnArgs = {
from: '2022-11-30',
to: '2024-06-21'
};
const fn = ({ from, to }: FnArgs) =>
dateService.calculateWeekdays(from, to);

await runner
.createScan({
name: expect.getState().currentTestName,
tests: [TestType.DATE_MANIPULATION]
})
.run({ inputSample, fn });
});
});
});
32 changes: 17 additions & 15 deletions test/sec/fn-file.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,22 @@ describe('FileService', () => {

afterEach(() => runner.clear());

it('fetch() should not have RFI', async () => {
type FnArgs = {
url: string;
};
const inputSample: FnArgs = {
url: 'https://brightsec.com/robots.txt'
};
const fn = ({ url }: FnArgs) => fileService.fetch(url);

await runner
.createScan({
name: expect.getState().currentTestName,
tests: [TestType.RFI]
})
.run({ inputSample, fn });
describe('fetch', () => {
it('should not have RFI', async () => {
type FnArgs = {
url: string;
};
const inputSample: FnArgs = {
url: 'https://brightsec.com/robots.txt'
};
const fn = ({ url }: FnArgs) => fileService.fetch(url);

await runner
.createScan({
name: expect.getState().currentTestName,
tests: [TestType.RFI]
})
.run({ inputSample, fn });
});
});
});
22 changes: 12 additions & 10 deletions test/sec/fn-xml.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,17 @@ describe('XmlService', () => {

afterEach(() => runner.clear());

it('parse() should not have XXE', async () => {
const inputSample = '<root />';
const fn = (data: string) => xmlService.parse(data);

await runner
.createScan({
name: expect.getState().currentTestName,
tests: [TestType.XXE]
})
.run({ inputSample, fn });
describe('parse', () => {
it('should not have XXE', async () => {
const inputSample = '<root />';
const fn = (data: string) => xmlService.parse(data);

await runner
.createScan({
name: expect.getState().currentTestName,
tests: [TestType.XXE]
})
.run({ inputSample, fn });
});
});
});

0 comments on commit 231286f

Please sign in to comment.