-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: added UT for site #279
base: main
Are you sure you want to change the base?
Conversation
strictEqual(typeof LightningDevSite.examples, 'object', 'Examples should be an array'); | ||
}); | ||
|
||
it('result should be undefined if local development is not enabled', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you look at the beforeEach method, they are mocking org data, auth, etc. Thats what you need to get the unit tests running:
beforeEach(async () => {
stubUx($$.SANDBOX);
stubSpinner($$.SANDBOX);
await $$.stubAuths(testOrgData);
$$.SANDBOX.stub(SfConfig, 'create').withArgs($$.SANDBOX.match.any).resolves(SfConfig.prototype);
$$.SANDBOX.stub(SfConfig, 'addAllowedProperties').withArgs($$.SANDBOX.match.any);
$$.SANDBOX.stub(SfConfig.prototype, 'get').returns(undefined);
$$.SANDBOX.stub(SfConfig.prototype, 'set');
$$.SANDBOX.stub(SfConfig.prototype, 'write').resolves();
$$.SANDBOX.stub(Connection.prototype, 'getUsername').returns(testUsername);
$$.SANDBOX.stub(PreviewUtils, 'getOrCreateAppServerIdentity').resolves(testIdentityData);
$$.SANDBOX.stub(OrgUtils, 'isLocalDevEnabled').resolves(true);
$$.SANDBOX.stub(OrgUtils, 'ensureMatchingAPIVersion').returns();
MockedLightningPreviewApp = await esmock<typeof LightningDevApp>('../../../../src/commands/lightning/dev/app.js', {
'../../../../src/lwc-dev-server/index.js': {
startLWCServer: async () => ({ stopServer: () => {} }),
},
});
});
siteDir: 'test-site-dir', | ||
}; | ||
|
||
$$.SANDBOX.stub(LightningDevSite, 'run').resolves(Promise.resolve(startupParams)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test isn't testing anything. You are mocking the entire run method and having it always return startupParams. So you are just testing if(startupParams === startupParams).
These tests are written solely for the purpose of beginning with UT for the site and for proper testing need to have a mocked implementation of org data, auth, etc. |
What does this PR do?
Added UT for site
What issues does this PR fix or reference?
@W-15440486@