summaryrefslogtreecommitdiff
path: root/packages/create-astro/test/project-name.test.js
diff options
context:
space:
mode:
authorGravatar Shoaib Khan <56039103+shoaibkh4n@users.noreply.github.com> 2024-02-13 20:11:59 +0530
committerGravatar GitHub <noreply@github.com> 2024-02-13 14:41:59 +0000
commit3007d24c98e607442903a3c0aaaea195390a25e7 (patch)
tree8a993608a3d35b47c8c5e016cc45359f4578af64 /packages/create-astro/test/project-name.test.js
parentbd877d389a6ebdd995e253bcb9daccef52b2277f (diff)
downloadastro-3007d24c98e607442903a3c0aaaea195390a25e7.tar.gz
astro-3007d24c98e607442903a3c0aaaea195390a25e7.tar.zst
astro-3007d24c98e607442903a3c0aaaea195390a25e7.zip
chore: Migrate all `packages/create-astro/test` to node:test (#10084)
* chore: Migrate All packages/create-astro/test to node:test * Some minor fix * Requested Changes done * Reopen * Apply suggestions from code review * let's test with concurrency * chore: fix possible false positive tests * todo test * skip tests * Apply suggestions from code review --------- Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
Diffstat (limited to 'packages/create-astro/test/project-name.test.js')
-rw-r--r--packages/create-astro/test/project-name.test.js69
1 files changed, 27 insertions, 42 deletions
diff --git a/packages/create-astro/test/project-name.test.js b/packages/create-astro/test/project-name.test.js
index 905f4a158..74196a35a 100644
--- a/packages/create-astro/test/project-name.test.js
+++ b/packages/create-astro/test/project-name.test.js
@@ -1,5 +1,5 @@
-import { expect } from 'chai';
-
+import assert from 'node:assert/strict';
+import { describe, it } from 'node:test';
import { projectName } from '../dist/index.js';
import { setup } from './utils.js';
@@ -9,25 +9,22 @@ describe('project name', async () => {
it('pass in name', async () => {
const context = { projectName: '', cwd: './foo/bar/baz', prompt: () => {} };
await projectName(context);
-
- expect(context.cwd).to.eq('./foo/bar/baz');
- expect(context.projectName).to.eq('baz');
+ assert.equal(context.cwd, './foo/bar/baz');
+ assert.equal(context.projectName, 'baz');
});
it('dot', async () => {
const context = { projectName: '', cwd: '.', prompt: () => ({ name: 'foobar' }) };
await projectName(context);
-
- expect(fixture.hasMessage('"." is not empty!')).to.be.true;
- expect(context.projectName).to.eq('foobar');
+ assert.ok(fixture.hasMessage('"." is not empty!'));
+ assert.equal(context.projectName, 'foobar');
});
it('dot slash', async () => {
const context = { projectName: '', cwd: './', prompt: () => ({ name: 'foobar' }) };
await projectName(context);
-
- expect(fixture.hasMessage('"./" is not empty!')).to.be.true;
- expect(context.projectName).to.eq('foobar');
+ assert.ok(fixture.hasMessage('"./" is not empty!'));
+ assert.equal(context.projectName, 'foobar');
});
it('empty', async () => {
@@ -37,9 +34,8 @@ describe('project name', async () => {
prompt: () => ({ name: 'foobar' }),
};
await projectName(context);
-
- expect(fixture.hasMessage('"./test/fixtures/empty" is not empty!')).to.be.false;
- expect(context.projectName).to.eq('empty');
+ assert.ok(!fixture.hasMessage('"./test/fixtures/empty" is not empty!'));
+ assert.equal(context.projectName, 'empty');
});
it('not empty', async () => {
@@ -49,59 +45,48 @@ describe('project name', async () => {
prompt: () => ({ name: 'foobar' }),
};
await projectName(context);
-
- expect(fixture.hasMessage('"./test/fixtures/not-empty" is not empty!')).to.be.true;
- expect(context.projectName).to.eq('foobar');
+ assert.ok(fixture.hasMessage('"./test/fixtures/not-empty" is not empty!'));
+ assert.equal(context.projectName, 'foobar');
});
it('basic', async () => {
const context = { projectName: '', cwd: '', prompt: () => ({ name: 'foobar' }) };
await projectName(context);
-
- expect(context.cwd).to.eq('foobar');
- expect(context.projectName).to.eq('foobar');
+ assert.equal(context.cwd, 'foobar');
+ assert.equal(context.projectName, 'foobar');
});
it('blank space', async () => {
- const context = { projectName: '', cwd: '', prompt: () => ({ name: 'foobar ' }) };
+ const context = { projectName: '', cwd: '', prompt: () => ({ name: 'foobar' }) };
await projectName(context);
-
- expect(context.cwd).to.eq('foobar');
- expect(context.projectName).to.eq('foobar');
+ assert.equal(context.cwd, 'foobar');
+ assert.equal(context.projectName, 'foobar');
});
it('normalize', async () => {
const context = { projectName: '', cwd: '', prompt: () => ({ name: 'Invalid Name' }) };
await projectName(context);
-
- expect(context.cwd).to.eq('Invalid Name');
- expect(context.projectName).to.eq('invalid-name');
+ assert.equal(context.cwd, 'Invalid Name');
+ assert.equal(context.projectName, 'invalid-name');
});
it('remove leading/trailing dashes', async () => {
const context = { projectName: '', cwd: '', prompt: () => ({ name: '(invalid)' }) };
await projectName(context);
-
- expect(context.projectName).to.eq('invalid');
+ assert.equal(context.projectName, 'invalid');
});
it('handles scoped packages', async () => {
const context = { projectName: '', cwd: '', prompt: () => ({ name: '@astro/site' }) };
await projectName(context);
-
- expect(context.cwd).to.eq('@astro/site');
- expect(context.projectName).to.eq('@astro/site');
+ assert.equal(context.cwd, '@astro/site');
+ assert.equal(context.projectName, '@astro/site');
});
it('--yes', async () => {
- const context = {
- projectName: '',
- cwd: './foo/bar/baz',
- yes: true,
- prompt: () => {},
- };
+ const context = { projectName: '', cwd: './foo/bar/baz', yes: true, prompt: () => {} };
await projectName(context);
- expect(context.projectName).to.eq('baz');
+ assert.equal(context.projectName, 'baz');
});
it('dry run with name', async () => {
@@ -112,7 +97,7 @@ describe('project name', async () => {
prompt: () => {},
};
await projectName(context);
- expect(context.projectName).to.eq('baz');
+ assert.equal(context.projectName, 'baz');
});
it('dry run with dot', async () => {
@@ -123,7 +108,7 @@ describe('project name', async () => {
prompt: () => ({ name: 'foobar' }),
};
await projectName(context);
- expect(context.projectName).to.eq('foobar');
+ assert.equal(context.projectName, 'foobar');
});
it('dry run with empty', async () => {
@@ -134,6 +119,6 @@ describe('project name', async () => {
prompt: () => ({ name: 'foobar' }),
};
await projectName(context);
- expect(context.projectName).to.eq('empty');
+ assert.equal(context.projectName, 'empty');
});
});