Skip to content

Commit

Permalink
Fixed DirectiveCase tests and removed duplicate test
Browse files Browse the repository at this point in the history
  • Loading branch information
richardm90 committed Mar 18, 2024
1 parent b9adf3d commit f192db7
Showing 1 changed file with 6 additions and 39 deletions.
45 changes: 6 additions & 39 deletions tests/suite/directives.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -517,53 +517,20 @@ test('uppercase1', async () => {

const cache = await parser.getDocs(uri, lines, { withIncludes: true, ignoreCache: true });
const { errors } = Linter.getErrors({ uri, content: lines }, {
DirectiveCasing: `upper`
DirectiveCase: `upper`
}, cache);

expect(errors.length).toBe(2);

expect(errors[0]).toEqual({
offset: { position: 31, end: 36 },
type: `DirectiveCasing`,
type: `DirectiveCase`,
newValue: `/COPY`
});

expect(errors[1]).toEqual({
offset: { position: 65, end: 70 },
type: `DirectiveCasing`,
newValue: `/COPY`
});
})

test('uppercase2', async () => {
const lines = [
`**FREE`,
`Ctl-Opt DftActGrp(*No);`,
`/copy './tests/rpgle/copy1.rpgle'`,
`/Copy './tests/rpgle/copy2.rpgle'`,
`/COPY './tests/rpgle/copy3.rpgle'`,
`Dcl-S MyCustomerName1 like(CustomerName_t);`,
`MyCustomerName1 = 'John Smith';`,
`dsply MyCustomerName1;`,
`Return;`
].join(`\n`);

const cache = await parser.getDocs(uri, lines, { withIncludes: true, ignoreCache: true });
const { errors } = Linter.getErrors({ uri, content: lines }, {
UppercaseDirectives: true
}, cache);

expect(errors.length).toBe(2);

expect(errors[0]).toEqual({
offset: { position: 31, end: 36 },
type: `UppercaseDirectives`,
newValue: `/COPY`
});

expect(errors[1]).toEqual({
offset: { position: 65, end: 70 },
type: `UppercaseDirectives`,
type: `DirectiveCase`,
newValue: `/COPY`
});
})
Expand All @@ -583,20 +550,20 @@ test('lowercase1', async () => {

const cache = await parser.getDocs(uri, lines, { withIncludes: true, ignoreCache: true });
const { errors } = Linter.getErrors({ uri, content: lines }, {
DirectiveCasing: `lower`
DirectiveCase: `lower`
}, cache);

expect(errors.length).toBe(2);

expect(errors[0]).toEqual({
offset: { position: 65, end: 70 },
type: `DirectiveCasing`,
type: `DirectiveCase`,
newValue: `/copy`
});

expect(errors[1]).toEqual({
offset: { position: 99, end: 104 },
type: `DirectiveCasing`,
type: `DirectiveCase`,
newValue: `/copy`
});
})

0 comments on commit f192db7

Please sign in to comment.