Skip to content

Commit

Permalink
test: Replace expect.stringContaining with expect.toEndWith in utils.…
Browse files Browse the repository at this point in the history
…spec.ts
  • Loading branch information
svsool committed Aug 7, 2020
1 parent cf6747b commit 6c5c4b6
Showing 1 changed file with 47 additions and 18 deletions.
65 changes: 47 additions & 18 deletions src/utils/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ describe('findReferences()', () => {
location: {
uri: {
$mid: 1,
path: expect.stringContaining(`${name0}.md`),
path: expect.toEndWith(`${name0}.md`),
scheme: 'file',
},
range: [
Expand All @@ -1043,7 +1043,7 @@ describe('findReferences()', () => {
location: {
uri: {
$mid: 1,
path: expect.stringContaining(`${name0}.md`),
path: expect.toEndWith(`${name0}.md`),
scheme: 'file',
},
range: [
Expand All @@ -1055,6 +1055,35 @@ describe('findReferences()', () => {
},
]);
});

it('should find references bypassing excluded paths', async () => {
const name0 = rndName();
const name1 = rndName();

await createFile(`${name0}.md`, '[[test]]');
await createFile(`${name1}.md`, '[[test1]]');

const refs = await findReferences('test', [path.join(getWorkspaceFolder()!, `${name1}.md`)]);

expect(refs).toHaveLength(1);

expect(toPlainObject(refs)).toMatchObject([
{
location: {
uri: {
$mid: 1,
path: expect.toEndWith(`${name0}.md`),
scheme: 'file',
},
range: [
{ line: 0, character: 2 },
{ line: 0, character: 6 },
],
},
matchText: '[[test]]',
},
]);
});
});

describe('getFileUrlForMarkdownPreview()', () => {
Expand Down Expand Up @@ -1108,12 +1137,12 @@ describe('findFilesByExts()', () => {
).toMatchObject([
{
$mid: 1,
path: expect.stringContaining(`a-${name0}.md`),
path: expect.toEndWith(`a-${name0}.md`),
scheme: 'file',
},
{
$mid: 1,
path: expect.stringContaining(`b-${name1}.png`),
path: expect.toEndWith(`b-${name1}.png`),
scheme: 'file',
},
]);
Expand Down Expand Up @@ -1161,12 +1190,12 @@ describe('findAllUrisWithUnknownExts()', () => {
).toMatchObject([
{
$mid: 1,
path: expect.stringContaining(`${name0}.html`),
path: expect.toEndWith(`${name0}.html`),
scheme: 'file',
},
{
$mid: 1,
path: expect.stringContaining(`${name0}.psd`),
path: expect.toEndWith(`${name0}.psd`),
scheme: 'file',
},
]);
Expand Down Expand Up @@ -1203,8 +1232,8 @@ describe('findUriByRef()', () => {
).toEqual(
expect.objectContaining({
$mid: 1,
fsPath: expect.stringContaining('File.md'),
path: expect.stringContaining('File.md'),
fsPath: expect.toEndWith('File.md'),
path: expect.toEndWith('File.md'),
scheme: 'file',
}),
);
Expand All @@ -1225,8 +1254,8 @@ describe('findUriByRef()', () => {
).toEqual(
expect.objectContaining({
$mid: 1,
fsPath: expect.stringContaining('File.png'),
path: expect.stringContaining('File.png'),
fsPath: expect.toEndWith('File.png'),
path: expect.toEndWith('File.png'),
scheme: 'file',
}),
);
Expand All @@ -1247,8 +1276,8 @@ describe('findUriByRef()', () => {
).toEqual(
expect.objectContaining({
$mid: 1,
fsPath: expect.stringContaining('File.md'),
path: expect.stringContaining('File.md'),
fsPath: expect.toEndWith('File.md'),
path: expect.toEndWith('File.md'),
scheme: 'file',
}),
);
Expand All @@ -1269,8 +1298,8 @@ describe('findUriByRef()', () => {
).toEqual(
expect.objectContaining({
$mid: 1,
fsPath: expect.stringContaining('File.png'),
path: expect.stringContaining('File.png'),
fsPath: expect.toEndWith('File.png'),
path: expect.toEndWith('File.png'),
scheme: 'file',
}),
);
Expand All @@ -1291,8 +1320,8 @@ describe('findUriByRef()', () => {
).toEqual(
expect.objectContaining({
$mid: 1,
fsPath: expect.stringContaining('File.md'),
path: expect.stringContaining('File.md'),
fsPath: expect.toEndWith('File.md'),
path: expect.toEndWith('File.md'),
scheme: 'file',
}),
);
Expand All @@ -1314,8 +1343,8 @@ describe('findUriByRef()', () => {
).toEqual(
expect.objectContaining({
$mid: 1,
fsPath: expect.stringContaining('File.unknown'),
path: expect.stringContaining('File.unknown'),
fsPath: expect.toEndWith('File.unknown'),
path: expect.toEndWith('File.unknown'),
scheme: 'file',
}),
);
Expand Down

0 comments on commit 6c5c4b6

Please sign in to comment.