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

Fixes issue where todos were deleted from a different engine #86

Merged
merged 1 commit into from
Feb 5, 2021
Merged
Show file tree
Hide file tree
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
21 changes: 21 additions & 0 deletions __tests__/__fixtures__/ember-template-lint-single-error.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"errorCount": 1,
"results": [
{
"messages": [
{
"rule": "require-input-label",
"severity": 2,
"moduleId": "{{path}}/app/templates/components/add-ssh-key.hbs",
"message": "Input elements require a valid associated label.",
"line": 3,
"column": 4,
"source": ""
}
],
"errorCount": 1,
"filePath": "{{path}}/app/templates/components/add-ssh-key.hbs",
"source": ""
}
]
}
45 changes: 45 additions & 0 deletions __tests__/__utils__/get-fixture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { join, resolve } from 'path';
import { ESLint } from 'eslint';
import { readFileSync, readJsonSync } from 'fs-extra';
import { TemplateLintResult } from '@ember-template-lint/todo-utils';

const cache: Map<string, string> = new Map();

export function getStringFixture(fileName: string): string {
if (cache.has(fileName)) {
return cache.get(fileName) || '';
}

const contents = readFileSync(
require.resolve(join('../__fixtures__/', fileName)),
{
encoding: 'utf8',
}
);

cache.set(fileName, contents);

return contents;
}

export function getObjectFixture<
T extends ESLint.LintResult | TemplateLintResult
>(fileName: string, tmp: string): T[] {
const fixture = readJsonSync(
resolve(join('./__tests__/__fixtures__/', fileName))
);

return updatePaths(
tmp,
fixture.hasOwnProperty('results') ? fixture.results : fixture
);
}

function updatePaths<T extends { filePath: string }>(
path: string,
data: T[]
): T[] {
data.forEach((d) => (d.filePath = d.filePath.replace('{{path}}', path)));

return data;
}
21 changes: 0 additions & 21 deletions __tests__/__utils__/read-file-cached.ts

This file was deleted.

Loading