From 7fcfdcec00725960e742e2c9daf4439616be2ae5 Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Mon, 4 Dec 2017 22:58:59 +0100 Subject: [PATCH] Test assertions correctly --- spec/workspace-spec.js | 15 +++++++-------- src/workspace.js | 1 + 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/workspace-spec.js b/spec/workspace-spec.js index 58ceb6a4d..4b115e594 100644 --- a/spec/workspace-spec.js +++ b/spec/workspace-spec.js @@ -659,13 +659,12 @@ describe('Workspace', () => { }) }) - describe('when the file is over user-defined limit', () => { + describe('when the file size is over the limit defined in `core.warnOnLargeFileLimit`', () => { const shouldPromptForFileOfSize = async (size, shouldPrompt) => { spyOn(fs, 'getSizeSync').andReturn(size * 1048577) let selectedButtonIndex = 1 // cancel atom.applicationDelegate.confirm.andCallFake((options, callback) => callback(selectedButtonIndex)) - atom.applicationDelegate.confirm() let editor = await workspace.open('sample.js') if (shouldPrompt) { @@ -683,19 +682,19 @@ describe('Workspace', () => { } } - it('prompts the user to make sure they want to open a file this big', () => { + it('prompts before opening the file', async () => { atom.config.set('core.warnOnLargeFileLimit', 20) - shouldPromptForFileOfSize(20, true) + await shouldPromptForFileOfSize(20, true) }) - it("doesn't prompt on files below the limit", () => { + it("doesn't prompt on files below the limit", async () => { atom.config.set('core.warnOnLargeFileLimit', 30) - shouldPromptForFileOfSize(20, false) + await shouldPromptForFileOfSize(20, false) }) - it('prompts for smaller files with a lower limit', () => { + it('prompts for smaller files with a lower limit', async () => { atom.config.set('core.warnOnLargeFileLimit', 5) - shouldPromptForFileOfSize(10, true) + await shouldPromptForFileOfSize(10, true) }) }) diff --git a/src/workspace.js b/src/workspace.js index 564fa3652..127168748 100644 --- a/src/workspace.js +++ b/src/workspace.js @@ -1221,6 +1221,7 @@ module.exports = class Workspace extends Model { resolveConfirmFileOpenPromise = resolve rejectConfirmFileOpenPromise = reject }) + if (fileSize >= (this.config.get('core.warnOnLargeFileLimit') * 1048576)) { // 40MB by default this.applicationDelegate.confirm({ message: 'Atom will be unresponsive during the loading of very large files.',