Skip to content

Commit

Permalink
test: add more test #5
Browse files Browse the repository at this point in the history
Signed-off-by: seven <zilisheng1996@gmail.com>
  • Loading branch information
Blankll committed Sep 23, 2024
1 parent 6431dd7 commit b0a8e38
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions tests/commands/deploy.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { deploy } from '../../src/commands/deploy';

const mockedDeployStack = jest.fn();
jest.mock('../../src/stack', () => ({
...jest.requireActual('../../src/stack'),
deployStack: (...args: unknown[]) => mockedDeployStack(...args),
}));

describe('unit test for deploy command', () => {
it('should construct valid context and deploy the stack when deploy with valid iac', async () => {
const stackName = 'my-demo-stack';
await deploy(stackName, { location: 'tests/fixtures/serverless-insight.yml', parameters: {} });
expect(mockedDeployStack).toHaveBeenCalledTimes(1);
expect(mockedDeployStack).toHaveBeenCalledWith(stackName, expect.any(Object), {
accessKeyId: undefined,
accessKeySecret: undefined,
iacLocation:
'/Users/blank/Documents/dev/geekfun/serverlessinsight/tests/fixtures/serverless-insight.yml',
parameters: [],
region: 'cn-hangzhou',
securityToken: undefined,
stackName: 'my-demo-stack',
stage: 'default',
});
});
});
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/stack/validate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { validateYaml } from '../../src/stack';
import { RawServerlessIac } from '../../src/types';

const jsonIac = parse(
readFileSync(path.resolve(__dirname, '../fixtures/serverless-insignt.yml'), 'utf8'),
readFileSync(path.resolve(__dirname, '../fixtures/serverless-insight.yml'), 'utf8'),
) as RawServerlessIac;

describe('unit test for validate', () => {
Expand Down

0 comments on commit b0a8e38

Please sign in to comment.