nx/packages/create-nx-workspace/src/create-workspace.spec.ts
Katerina Skroumpelou 467f343e3d
feat(misc): only create one commit with cloud onboard URL on cnw (#27093)
* Only create one commit during CNW
* Commit includes cloud onboarding URL
![Screenshot 2024-07-24 at 7 15
54 PM](https://github.com/user-attachments/assets/39b50443-4fbd-4423-b25c-68c45099af66)
2024-07-24 14:05:34 -05:00

60 lines
2.1 KiB
TypeScript

import { extractConnectUrl } from './create-workspace';
describe('extractConnectUrl', () => {
test('should extract the correct URL from the given string', () => {
const inputString = `
NX Your Nx Cloud workspace is ready.
To claim it, connect it to your Nx Cloud account:
- Push your repository to your git hosting provider.
- Go to the following URL to connect your workspace to Nx Cloud:
https://staging.nx.app/connect/O8dfB0jYgvd
`;
const expectedUrl = 'https://staging.nx.app/connect/O8dfB0jYgvd';
expect(extractConnectUrl(inputString)).toBe(expectedUrl);
});
test('should return null if no URL is present', () => {
const inputString = `
NX Your Nx Cloud workspace is ready.
To claim it, connect it to your Nx Cloud account:
- Push your repository to your git hosting provider.
- Go to the following URL to connect your workspace to Nx Cloud:
No URL here.
`;
expect(extractConnectUrl(inputString)).toBeNull();
});
test('should handle URLs with different domains and paths', () => {
const inputString = `
NX Your Nx Cloud workspace is ready.
To claim it, connect it to your Nx Cloud account:
- Push your repository to your git hosting provider.
- Go to the following URL to connect your workspace to Nx Cloud:
https://example.com/connect/abcd1234
`;
const expectedUrl = 'https://example.com/connect/abcd1234';
expect(extractConnectUrl(inputString)).toBe(expectedUrl);
});
test('should handle URLs with query parameters and fragments', () => {
const inputString = `
NX Your Nx Cloud workspace is ready.
To claim it, connect it to your Nx Cloud account:
- Push your repository to your git hosting provider.
- Go to the following URL to connect your workspace to Nx Cloud:
https://example.com/connect/abcd1234?query=param#fragment
`;
const expectedUrl =
'https://example.com/connect/abcd1234?query=param#fragment';
expect(extractConnectUrl(inputString)).toBe(expectedUrl);
});
});