mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-28 10:05:03 +08:00
[*] Run the isomorphic-core specs as part of the client test suite
Summary: Convert the isomorphic-core specs to Jasmine 1 and symlink them into client-app/internal_packages so they are run as part of the client test suite. Test Plan: Ran the suite with fdescribes in iso-core to ensure they were being called properly Reviewers: evan, spang, juan Reviewed By: spang, juan Differential Revision: https://phab.nylas.com/D4055
This commit is contained in:
parent
8c30697241
commit
953a8e438e
3 changed files with 34 additions and 20 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -15,6 +15,7 @@
|
|||
**/internal_packages/activity-list
|
||||
**/internal_packages/composer-mail-merge
|
||||
**/internal_packages/composer-scheduler
|
||||
**/internal_packages/isomorphic-core
|
||||
**/internal_packages/link-tracking
|
||||
**/internal_packages/open-tracking
|
||||
**/internal_packages/send-later
|
||||
|
|
|
@ -13,10 +13,10 @@ describe('IMAPConnectionPool', function describeBlock() {
|
|||
};
|
||||
IMAPConnectionPool._poolMap = {};
|
||||
this.logger = {};
|
||||
spyOn(IMAPConnection.prototype, 'connect').and.callFake(function connectFake() {
|
||||
spyOn(IMAPConnection.prototype, 'connect').andCallFake(function connectFake() {
|
||||
return this;
|
||||
});
|
||||
spyOn(IMAPConnection.prototype, 'end').and.callFake(() => {});
|
||||
spyOn(IMAPConnection.prototype, 'end').andCallFake(() => {});
|
||||
});
|
||||
|
||||
it('opens IMAP connection and properly returns to pool at end of scope', async () => {
|
||||
|
@ -31,8 +31,8 @@ describe('IMAPConnectionPool', function describeBlock() {
|
|||
},
|
||||
});
|
||||
expect(invokedCallback).toBe(true);
|
||||
expect(IMAPConnection.prototype.connect.calls.count()).toBe(1);
|
||||
expect(IMAPConnection.prototype.end.calls.count()).toBe(0);
|
||||
expect(IMAPConnection.prototype.connect.calls.length).toBe(1);
|
||||
expect(IMAPConnection.prototype.end.calls.length).toBe(0);
|
||||
});
|
||||
|
||||
it('opens multiple IMAP connections and properly returns to pool at end of scope', async () => {
|
||||
|
@ -48,8 +48,8 @@ describe('IMAPConnectionPool', function describeBlock() {
|
|||
},
|
||||
});
|
||||
expect(invokedCallback).toBe(true);
|
||||
expect(IMAPConnection.prototype.connect.calls.count()).toBe(2);
|
||||
expect(IMAPConnection.prototype.end.calls.count()).toBe(0);
|
||||
expect(IMAPConnection.prototype.connect.calls.length).toBe(2);
|
||||
expect(IMAPConnection.prototype.end.calls.length).toBe(0);
|
||||
});
|
||||
|
||||
it('opens an IMAP connection properly and only returns to pool on done', async () => {
|
||||
|
@ -66,8 +66,8 @@ describe('IMAPConnectionPool', function describeBlock() {
|
|||
},
|
||||
});
|
||||
expect(invokedCallback).toBe(true);
|
||||
expect(IMAPConnection.prototype.connect.calls.count()).toBe(1);
|
||||
expect(IMAPConnection.prototype.end.calls.count()).toBe(0);
|
||||
expect(IMAPConnection.prototype.connect.calls.length).toBe(1);
|
||||
expect(IMAPConnection.prototype.end.calls.length).toBe(0);
|
||||
expect(IMAPConnectionPool._poolMap[this.account.id]._availableConns.length === 2);
|
||||
doneCallback();
|
||||
expect(IMAPConnectionPool._poolMap[this.account.id]._availableConns.length === 3);
|
||||
|
@ -85,8 +85,8 @@ describe('IMAPConnectionPool', function describeBlock() {
|
|||
},
|
||||
});
|
||||
expect(invokedCallback).toBe(true);
|
||||
expect(IMAPConnection.prototype.connect.calls.count()).toBe(1);
|
||||
expect(IMAPConnection.prototype.end.calls.count()).toBe(0);
|
||||
expect(IMAPConnection.prototype.connect.calls.length).toBe(1);
|
||||
expect(IMAPConnection.prototype.end.calls.length).toBe(0);
|
||||
|
||||
invokedCallback = false;
|
||||
await IMAPConnectionPool.withConnectionsForAccount(this.account, {
|
||||
|
@ -100,8 +100,8 @@ describe('IMAPConnectionPool', function describeBlock() {
|
|||
});
|
||||
|
||||
expect(invokedCallback).toBe(true);
|
||||
expect(IMAPConnection.prototype.connect.calls.count()).toBe(1);
|
||||
expect(IMAPConnection.prototype.end.calls.count()).toBe(0);
|
||||
expect(IMAPConnection.prototype.connect.calls.length).toBe(1);
|
||||
expect(IMAPConnection.prototype.end.calls.length).toBe(0);
|
||||
});
|
||||
|
||||
it('waits for an available IMAP connection', async () => {
|
||||
|
@ -118,8 +118,8 @@ describe('IMAPConnectionPool', function describeBlock() {
|
|||
},
|
||||
});
|
||||
expect(invokedCallback).toBe(true);
|
||||
expect(IMAPConnection.prototype.connect.calls.count()).toBe(3);
|
||||
expect(IMAPConnection.prototype.end.calls.count()).toBe(0);
|
||||
expect(IMAPConnection.prototype.connect.calls.length).toBe(3);
|
||||
expect(IMAPConnection.prototype.end.calls.length).toBe(0);
|
||||
|
||||
invokedCallback = false;
|
||||
const promise = IMAPConnectionPool.withConnectionsForAccount(this.account, {
|
||||
|
@ -137,8 +137,8 @@ describe('IMAPConnectionPool', function describeBlock() {
|
|||
await promise;
|
||||
|
||||
expect(invokedCallback).toBe(true);
|
||||
expect(IMAPConnection.prototype.connect.calls.count()).toBe(3);
|
||||
expect(IMAPConnection.prototype.end.calls.count()).toBe(0);
|
||||
expect(IMAPConnection.prototype.connect.calls.length).toBe(3);
|
||||
expect(IMAPConnection.prototype.end.calls.length).toBe(0);
|
||||
});
|
||||
|
||||
it('retries on IMAP connection timeout', async () => {
|
||||
|
@ -158,8 +158,8 @@ describe('IMAPConnectionPool', function describeBlock() {
|
|||
});
|
||||
|
||||
expect(invokeCount).toBe(2);
|
||||
expect(IMAPConnection.prototype.connect.calls.count()).toBe(2);
|
||||
expect(IMAPConnection.prototype.end.calls.count()).toBe(1);
|
||||
expect(IMAPConnection.prototype.connect.calls.length).toBe(2);
|
||||
expect(IMAPConnection.prototype.end.calls.length).toBe(1);
|
||||
});
|
||||
|
||||
it('does not retry on other IMAP error', async () => {
|
||||
|
@ -185,7 +185,7 @@ describe('IMAPConnectionPool', function describeBlock() {
|
|||
|
||||
expect(invokeCount).toBe(1);
|
||||
expect(errorCount).toBe(1);
|
||||
expect(IMAPConnection.prototype.connect.calls.count()).toBe(1);
|
||||
expect(IMAPConnection.prototype.end.calls.count()).toBe(1);
|
||||
expect(IMAPConnection.prototype.connect.calls.length).toBe(1);
|
||||
expect(IMAPConnection.prototype.end.calls.length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -96,11 +96,24 @@ async function electronRebuild() {
|
|||
})
|
||||
}
|
||||
|
||||
function linkIsomorphicCoreSpecs() {
|
||||
console.log("\n---> Linking isomorphic-core specs to client-app")
|
||||
const dir = path.resolve(path.join('packages', 'client-app', 'internal_packages', 'isomorphic-core'))
|
||||
if (!fs.existsSync(dir)) {
|
||||
fs.mkdirSync(dir)
|
||||
}
|
||||
const from = path.resolve(path.join('packages', 'isomorphic-core', 'spec'))
|
||||
const to = path.resolve(path.join(dir, 'spec'))
|
||||
unlinkIfExistsSync(to)
|
||||
fs.symlinkSync(from, to, 'dir')
|
||||
}
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
await installPrivateResources()
|
||||
await lernaBootstrap();
|
||||
await electronRebuild();
|
||||
linkIsomorphicCoreSpecs();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
|
|
Loading…
Reference in a new issue