Skip to content

Commit

Permalink
test(remix): fix e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
philipjfulcher committed Apr 12, 2023
1 parent 9869934 commit b286db4
Showing 1 changed file with 30 additions and 33 deletions.
63 changes: 30 additions & 33 deletions e2e/remix-e2e/tests/nx-remix.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
checkFilesExist,
ensureNxProject,
readJson,
runCommandAsync,
Expand Down Expand Up @@ -82,61 +83,57 @@ describe('remix e2e', () => {
}, 120000);

it('should check for un-escaped dollar signs in routes', async () => {
expect.assertions(2);
try {
await runNxCommandAsync(
`generate @nrwl/remix:route --project ${plugin} --path my.route.$withParams.tsx`
);
} catch (e) {
expect(e.toString()).toContain('Error: Command failed:');
}
await expect(
async () =>
await runNxCommandAsync(
`generate @nrwl/remix:route --project ${plugin} --path my.route.$withParams.tsx`
)
).rejects.toThrow();

const result = await runNxCommandAsync(
await runNxCommandAsync(
`generate @nrwl/remix:route --project ${plugin} --path my.route.\\$withParams.tsx`
);

expect(result.stdout).toContain(
`CREATE ${plugin}/app/routes/my.route.$withParams.tsx`
);
expect(() =>
checkFilesExist(`${plugin}/app/routes/my.route.$withParams.tsx`)
).not.toThrow();
}, 120000);

it('should pass un-escaped dollar signs in routes with skipChecks flag', async () => {
const result = await runCommandAsync(
await runCommandAsync(
`someWeirdUseCase=route-segment && yarn nx generate @nrwl/remix:route --project ${plugin} --path my.route.$someWeirdUseCase.tsx --force`
);

expect(result.stdout).toContain(
`CREATE ${plugin}/app/routes/my.route.route-segment.tsx`
);
expect(() =>
checkFilesExist(`${plugin}/app/routes/my.route.route-segment.tsx`)
).not.toThrow();
}, 120000);

it('should check for un-escaped dollar signs in resource routes', async () => {
expect.assertions(2);
try {
await runNxCommandAsync(
`generate @nrwl/remix:resource-route --project ${plugin} --path my.route.$withParams.ts`
);
} catch (e) {
expect(e.toString()).toContain('Error: Command failed:');
}
await expect(
async () =>
await runNxCommandAsync(
`generate @nrwl/remix:resource-route --project ${plugin} --path my.route.$withParams.ts`
)
).rejects.toThrow();

const result = await runNxCommandAsync(
await runNxCommandAsync(
`generate @nrwl/remix:resource-route --project ${plugin} --path my.route.\\$withParams.ts`
);

expect(result.stdout).toContain(
`CREATE ${plugin}/app/routes/my.route.$withParams.ts`
);
expect(() =>
checkFilesExist(`${plugin}/app/routes/my.route.$withParams.ts`)
).not.toThrow();
}, 120000);

it('should pass un-escaped dollar signs in resource routes with skipChecks flag', async () => {
const result = await runCommandAsync(
`someWeirdUseCase=route-segment && yarn nx generate @nrwl/remix:resource-route --project ${plugin} --path my.route.$someWeirdUseCase.tsx --force`
await runCommandAsync(
`someWeirdUseCase=route-segment && yarn nx generate @nrwl/remix:resource-route --project ${plugin} --path my.route.$someWeirdUseCase.ts --force`
);

expect(result.stdout).toContain(
`CREATE ${plugin}/app/routes/my.route.route-segment.ts`
);
expect(() =>
checkFilesExist(`${plugin}/app/routes/my.route.route-segment.ts`)
).not.toThrow();
}, 120000);
});
});

0 comments on commit b286db4

Please sign in to comment.