-
Notifications
You must be signed in to change notification settings - Fork 677
Expand file tree
/
Copy pathproject.test.ts
More file actions
56 lines (51 loc) · 1.78 KB
/
project.test.ts
File metadata and controls
56 lines (51 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { afterEach, beforeEach, describe, it } from 'node:test';
import sinon from 'sinon';
import { mockProcess } from '../../utils/test';
import { shell } from '../shell';
import project from './project';
describe('project', () => {
const sandbox = sinon.createSandbox();
let spawnSpy: sinon.SinonStub;
beforeEach(() => {
const process = mockProcess();
spawnSpy = sandbox.stub(shell, 'spawnProcess').returns({
command: 'something',
finished: true,
output: 'hi',
process,
});
sandbox.stub(shell, 'checkIfFinished').resolves();
});
afterEach(() => {
sandbox.restore();
});
describe('create', () => {
it('should invoke `create <appPath>`', async () => {
await project.create({ appPath: 'myApp' });
sandbox.assert.calledWith(spawnSpy, sinon.match.string, sinon.match.array.contains(['create', 'myApp']));
});
it('should invoke `create <appPath> --template` if template specified', async () => {
await project.create({ appPath: 'myApp', template: 'slack-samples/deno-hello-world' });
sandbox.assert.calledWith(
spawnSpy,
sinon.match.string,
sinon.match.array.contains(['create', 'myApp', '--template', 'slack-samples/deno-hello-world']),
);
});
it('should invoke `create <appPath> --template --branch` if both template and branch specified', async () => {
await project.create({ appPath: 'myApp', template: 'slack-samples/deno-hello-world', branch: 'feat-functions' });
sandbox.assert.calledWith(
spawnSpy,
sinon.match.string,
sinon.match.array.contains([
'create',
'myApp',
'--template',
'slack-samples/deno-hello-world',
'--branch',
'feat-functions',
]),
);
});
});
});