Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(common): add accessibility inside accessibility test cases #49

Merged
merged 1 commit into from
May 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions packages/mermaid-parser/tests/common/accessible.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ describe('when parsing accTitle', () => {
expect(value.accTitle).toBeUndefined();
});

it.todo('should handle accTitle inside accTitle', async () => {
const str = `pie accTitle: accTitle: test`;
const result = (await parser(str)).parseResult;
// expect(result.parserErrors).toHaveLength(0);
// expect(result.lexerErrors).toHaveLength(0);

const value = result.value;
expect(value.title).toBeUndefined();
expect(value.accDescr).toBe('accTitle: test');
expect(value.accTitle).toBeUndefined();
});

it.todo('should handle valid accTitle with title', async () => {
const str = `pie accTitle: sample accessibility + title test`;
const result = (await parser(str)).parseResult;
Expand Down Expand Up @@ -198,6 +210,18 @@ describe('when parsing accDescr', () => {
expect(value.accTitle).toBeUndefined();
});

it('should handle single line accDescr inside single line accDescr', async () => {
const str = `pie accDescr: accDescr: test`;
const result = (await parser(str)).parseResult;
// expect(result.parserErrors).toHaveLength(0);
// expect(result.lexerErrors).toHaveLength(0);

const value = result.value;
expect(value.title).toBeUndefined();
expect(value.accDescr).toBe('accDescr: test');
expect(value.accTitle).toBeUndefined();
});

it.todo('should handle valid single line accDescr with title', async () => {
const str = `pie accDescr: sample description + title test`;
const result = (await parser(str)).parseResult;
Expand Down Expand Up @@ -310,6 +334,26 @@ describe('when parsing accDescr', () => {
expect(value.accTitle).toBeUndefined();
});

it.todo(
'should handle multi line accDescr inside multi line accDescr',
async () => {
const str = `pie accDescr {
accDescr {
test
}
}
`;
const result = (await parser(str)).parseResult;
// expect(result.parserErrors).toHaveLength(0);
// expect(result.lexerErrors).toHaveLength(0);

const value = result.value;
expect(value.title).toBeUndefined();
expect(value.accDescr).toBe('accDescr {\ntest\n}');
expect(value.accTitle).toBeUndefined();
},
);

it.todo('should handle valid multi line accDescr with title', async () => {
const str = `pie accDescr {
sample description +
Expand Down Expand Up @@ -362,4 +406,30 @@ describe('when parsing accDescr', () => {
expect(value.accTitle).toBeUndefined();
},
);

it('should handle multi line accDescr inside single line accDescr', async () => {
const str = `pie accDescr: accDescr {test}`;
const result = (await parser(str)).parseResult;
// expect(result.parserErrors).toHaveLength(0);
// expect(result.lexerErrors).toHaveLength(0);

const value = result.value;
expect(value.title).toBeUndefined();
expect(value.accDescr).toBe('accDescr {test}');
expect(value.accTitle).toBeUndefined();
});

it('should handle single line accDescr inside multi line accDescr', async () => {
const str = `pie accDescr {
accDescr: test
}`;
const result = (await parser(str)).parseResult;
// expect(result.parserErrors).toHaveLength(0);
// expect(result.lexerErrors).toHaveLength(0);

const value = result.value;
expect(value.title).toBeUndefined();
expect(value.accDescr).toBe('accDescr: test');
expect(value.accTitle).toBeUndefined();
});
});