Skip to content

Commit

Permalink
test: convert json to runtime fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber committed Sep 13, 2023
1 parent 497ea8d commit 3f94114
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
3 changes: 0 additions & 3 deletions tests/fixtures/lib/json/index.json

This file was deleted.

19 changes: 13 additions & 6 deletions tests/specs/json.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import path from 'path';
import { testSuite, expect } from 'manten';
import { createFixture } from 'fs-fixture';
import type { NodeApis } from '../utils/tsx';

export default testSuite(async ({ describe }, node: NodeApis) => {
describe('Load JSON', ({ describe }) => {
describe('full path', ({ test }) => {
const importPath = './lib/json/index.json';
describe('Load JSON', async ({ describe }) => {
const fixture = await createFixture({
'index.json': JSON.stringify({
loaded: 'json',
}),
});

describe('full path', async ({ test }) => {
const importPath = path.join(fixture.path, 'index.json');
test('Load', async () => {
const nodeProcess = await node.load(importPath);
const nodeProcess = await node.load(fixture.path);
expect(nodeProcess.stdout).toBe('');
expect(nodeProcess.exitCode).toBe(0);
});
Expand All @@ -26,7 +33,7 @@ export default testSuite(async ({ describe }, node: NodeApis) => {
});

describe('extensionless', ({ test }) => {
const importPath = './lib/json/index';
const importPath = path.join(fixture.path, 'index');

test('Load', async () => {
const nodeProcess = await node.load(importPath);
Expand All @@ -48,7 +55,7 @@ export default testSuite(async ({ describe }, node: NodeApis) => {
});

describe('directory', ({ test }) => {
const importPath = './lib/json';
const importPath = fixture.path;

test('Load', async () => {
const nodeProcess = await node.load(importPath);
Expand Down

0 comments on commit 3f94114

Please sign in to comment.