Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shilman committed Jul 9, 2024
1 parent 9170d4b commit e9d28db
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
18 changes: 5 additions & 13 deletions code/core/src/telemetry/get-portable-stories-usage.test.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
import { describe, it, expect } from 'vitest';
import { join } from 'path';

import { getPortableStoriesFiles } from './get-portable-stories-usage';
import { getPortableStoriesFileCountUncached } from './get-portable-stories-usage';

describe('getPortableStoriesFiles', () => {
describe('getPortableStoriesFileCountUncached', () => {
it('should ignores node_modules, non-source files', async () => {
const base = join(__dirname, '__fixtures__');
const usage = (await getPortableStoriesFiles(base)).map((f) => f.replace(base, ''));
expect(usage).toMatchInlineSnapshot(`
[
"/b.js",
"/a.js",
"/foo/a.js",
"/.storybook/a.js",
]
`);
const usage = await getPortableStoriesFileCountUncached();
// verify git grep -m1 -c composeStor | wc -l
expect(usage).toMatchInlineSnapshot(`14`);
});
});
2 changes: 1 addition & 1 deletion code/core/src/telemetry/get-portable-stories-usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const cache = createFileSystemCache({
ttl: 24 * 60 * 60 * 1000, // 24h
});

const getPortableStoriesFileCountUncached = async () => {
export const getPortableStoriesFileCountUncached = async () => {
const { stdout } = await execaCommand(`git grep -m1 -c composeStor`, {
cwd: process.cwd(),
shell: true,
Expand Down
1 change: 1 addition & 0 deletions docs/configure/telemetry.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Will generate the following output:
"hasStaticDirs": false,
"hasStorybookEslint": false,
"refCount": 0,
"portableStoriesFileCount": 0,
"packageManager": {
"type": "yarn",
"version": "3.1.1"
Expand Down

0 comments on commit e9d28db

Please sign in to comment.