Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit e921555

Browse files
committed
Merge pull request #4635 from TomMalbran/tom/one-window-per-suite
Use one window for all specs in the suite on more integration tests
2 parents 28138e7 + 2f76106 commit e921555

File tree

5 files changed

+239
-224
lines changed

5 files changed

+239
-224
lines changed

test/spec/CSSUtils-test.js

Lines changed: 101 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
*/
2323

2424
/*jslint vars: true, plusplus: true, devel: true, browser: true, nomen: true, indent: 4, maxerr: 50 */
25-
/*global define: false, describe: false, xdescribe: false, it: false, xit: false, expect: false, beforeEach: false, afterEach: false, waitsFor: false, runs: false, $: false, CodeMirror: false */
25+
/*global define, describe, xdescribe, it, xit, expect, beforeEach, afterEach, waitsFor, runs, $, CodeMirror, beforeFirst, afterLast */
2626

2727
define(function (require, exports, module) {
28-
'use strict';
28+
"use strict";
2929

3030
var NativeFileSystem = require("file/NativeFileSystem").NativeFileSystem,
3131
Async = require("utils/Async"),
@@ -568,7 +568,7 @@ define(function (require, exports, module) {
568568
}); // describe("CSSUtils")
569569

570570

571-
describe("CSS Parsing: ", function () {
571+
describe("CSS Parsing", function () {
572572

573573
var lastCssCode,
574574
match,
@@ -639,7 +639,7 @@ define(function (require, exports, module) {
639639
});
640640

641641

642-
describe("Simple selectors: ", function () {
642+
describe("Simple selectors", function () {
643643

644644
it("should match a lone type selector given a type", function () {
645645
var result = match("div { color:red }", { tag: "div" });
@@ -1366,143 +1366,136 @@ define(function (require, exports, module) {
13661366

13671367
}); // describe("Known Issues")
13681368

1369-
1370-
describe("Working with real public CSSUtils API", function () {
1371-
this.category = "integration";
1372-
1373-
var CSSUtils;
1374-
1375-
beforeEach(function () {
1376-
SpecRunnerUtils.createTestWindowAndRun(this, function (testWindow) {
1377-
// Load module instances from brackets.test
1378-
CSSUtils = testWindow.brackets.test.CSSUtils;
1379-
1380-
// Load test project
1381-
var testPath = SpecRunnerUtils.getTestPath("/spec/CSSUtils-test-files");
1382-
SpecRunnerUtils.loadProjectInTestWindow(testPath);
1383-
});
1384-
});
1385-
afterEach(function () {
1386-
CSSUtils = null;
1387-
SpecRunnerUtils.closeTestWindow();
1388-
});
1389-
1390-
it("should include comment preceding selector (issue #403)", function () {
1391-
var rules;
1392-
runs(function () {
1393-
CSSUtils.findMatchingRules("#issue403")
1394-
.done(function (result) { rules = result; });
1395-
});
1396-
waitsFor(function () { return rules !== undefined; }, "CSSUtils.findMatchingRules() timeout", 1000);
1397-
1398-
runs(function () {
1399-
expect(rules.length).toBe(1);
1400-
expect(rules[0].lineStart).toBe(4);
1401-
expect(rules[0].lineEnd).toBe(7);
1402-
});
1403-
});
1404-
1405-
});
14061369

1407-
1408-
describe("Working with unsaved changes", function () {
1370+
describe("CSS Intgration Tests", function () {
14091371
this.category = "integration";
14101372

14111373
var testPath = SpecRunnerUtils.getTestPath("/spec/CSSUtils-test-files"),
1374+
testWindow,
14121375
CSSUtils,
14131376
DocumentManager,
14141377
FileViewController;
1415-
1416-
beforeEach(function () {
1417-
SpecRunnerUtils.createTestWindowAndRun(this, function (testWindow) {
1378+
1379+
beforeFirst(function () {
1380+
SpecRunnerUtils.createTestWindowAndRun(this, function (w) {
1381+
testWindow = w;
1382+
14181383
// Load module instances from brackets.test
14191384
CSSUtils = testWindow.brackets.test.CSSUtils;
14201385
DocumentManager = testWindow.brackets.test.DocumentManager;
14211386
FileViewController = testWindow.brackets.test.FileViewController;
1422-
1387+
1388+
// Load test project
14231389
SpecRunnerUtils.loadProjectInTestWindow(testPath);
14241390
});
14251391
});
1426-
1427-
afterEach(function () {
1392+
1393+
afterLast(function () {
14281394
CSSUtils = null;
14291395
DocumentManager = null;
14301396
FileViewController = null;
14311397
SpecRunnerUtils.closeTestWindow();
14321398
});
14331399

1434-
it("should return the correct offsets if the file has changed", function () {
1435-
var didOpen = false,
1436-
gotError = false;
1437-
1438-
runs(function () {
1439-
FileViewController.openAndSelectDocument(testPath + "/simple.css", FileViewController.PROJECT_MANAGER)
1440-
.done(function () { didOpen = true; })
1441-
.fail(function () { gotError = true; });
1442-
});
1443-
1444-
waitsFor(function () { return didOpen && !gotError; }, "FileViewController.addToWorkingSetAndSelect() timeout", 1000);
1445-
1446-
var rules = null;
1400+
afterEach(function () {
1401+
testWindow.closeAllFiles();
1402+
});
1403+
1404+
1405+
describe("Working with real public CSSUtils API", function () {
14471406

1448-
runs(function () {
1449-
var doc = DocumentManager.getCurrentDocument();
1450-
1451-
// Add several blank lines at the beginning of the text
1452-
doc.setText("\n\n\n\n" + doc.getText());
1453-
1454-
// Look for ".FIRSTGRADE"
1455-
CSSUtils.findMatchingRules(".FIRSTGRADE")
1456-
.done(function (result) { rules = result; });
1407+
it("should include comment preceding selector (issue #403)", function () {
1408+
var rules;
1409+
runs(function () {
1410+
CSSUtils.findMatchingRules("#issue403")
1411+
.done(function (result) { rules = result; });
1412+
});
1413+
waitsFor(function () { return rules !== undefined; }, "CSSUtils.findMatchingRules() timeout", 1000);
14571414

1458-
doc = null;
1459-
});
1460-
1461-
waitsFor(function () { return rules !== null; }, "CSSUtils.findMatchingRules() timeout", 1000);
1462-
1463-
runs(function () {
1464-
expect(rules.length).toBe(1);
1465-
expect(rules[0].lineStart).toBe(16);
1466-
expect(rules[0].lineEnd).toBe(18);
1415+
runs(function () {
1416+
expect(rules.length).toBe(1);
1417+
expect(rules[0].lineStart).toBe(4);
1418+
expect(rules[0].lineEnd).toBe(7);
1419+
});
14671420
});
14681421
});
14691422

1470-
it("should return a newly created rule in an unsaved file", function () {
1471-
var didOpen = false,
1472-
gotError = false;
1473-
1474-
runs(function () {
1475-
FileViewController.openAndSelectDocument(testPath + "/simple.css", FileViewController.PROJECT_MANAGER)
1476-
.done(function () { didOpen = true; })
1477-
.fail(function () { gotError = true; });
1478-
});
1423+
describe("Working with unsaved changes", function () {
14791424

1480-
waitsFor(function () { return didOpen && !gotError; }, "FileViewController.addToWorkingSetAndSelect() timeout", 1000);
1481-
1482-
var rules = null;
1483-
1484-
runs(function () {
1485-
var doc = DocumentManager.getCurrentDocument();
1425+
it("should return the correct offsets if the file has changed", function () {
1426+
var didOpen = false,
1427+
gotError = false;
14861428

1487-
// Add a new selector to the file
1488-
doc.setText(doc.getText() + "\n\n.TESTSELECTOR {\n font-size: 12px;\n}\n");
1429+
runs(function () {
1430+
FileViewController.openAndSelectDocument(testPath + "/simple.css", FileViewController.PROJECT_MANAGER)
1431+
.done(function () { didOpen = true; })
1432+
.fail(function () { gotError = true; });
1433+
});
14891434

1490-
// Look for the selector we just created
1491-
CSSUtils.findMatchingRules(".TESTSELECTOR")
1492-
.done(function (result) { rules = result; });
1493-
1494-
doc = null;
1435+
waitsFor(function () { return didOpen && !gotError; }, "FileViewController.addToWorkingSetAndSelect() timeout", 1000);
1436+
1437+
var rules = null;
1438+
1439+
runs(function () {
1440+
var doc = DocumentManager.getCurrentDocument();
1441+
1442+
// Add several blank lines at the beginning of the text
1443+
doc.setText("\n\n\n\n" + doc.getText());
1444+
1445+
// Look for ".FIRSTGRADE"
1446+
CSSUtils.findMatchingRules(".FIRSTGRADE")
1447+
.done(function (result) { rules = result; });
1448+
1449+
doc = null;
1450+
});
1451+
1452+
waitsFor(function () { return rules !== null; }, "CSSUtils.findMatchingRules() timeout", 1000);
1453+
1454+
runs(function () {
1455+
expect(rules.length).toBe(1);
1456+
expect(rules[0].lineStart).toBe(16);
1457+
expect(rules[0].lineEnd).toBe(18);
1458+
});
14951459
});
14961460

1497-
waitsFor(function () { return rules !== null; }, "CSSUtils.findMatchingRules() timeout", 1000);
1498-
1499-
runs(function () {
1500-
expect(rules.length).toBe(1);
1501-
expect(rules[0].lineStart).toBe(24);
1502-
expect(rules[0].lineEnd).toBe(26);
1461+
it("should return a newly created rule in an unsaved file", function () {
1462+
var didOpen = false,
1463+
gotError = false;
1464+
1465+
runs(function () {
1466+
FileViewController.openAndSelectDocument(testPath + "/simple.css", FileViewController.PROJECT_MANAGER)
1467+
.done(function () { didOpen = true; })
1468+
.fail(function () { gotError = true; });
1469+
});
1470+
1471+
waitsFor(function () { return didOpen && !gotError; }, "FileViewController.addToWorkingSetAndSelect() timeout", 1000);
1472+
1473+
var rules = null;
1474+
1475+
runs(function () {
1476+
var doc = DocumentManager.getCurrentDocument();
1477+
1478+
// Add a new selector to the file
1479+
doc.setText(doc.getText() + "\n\n.TESTSELECTOR {\n font-size: 12px;\n}\n");
1480+
1481+
// Look for the selector we just created
1482+
CSSUtils.findMatchingRules(".TESTSELECTOR")
1483+
.done(function (result) { rules = result; });
1484+
1485+
doc = null;
1486+
});
1487+
1488+
waitsFor(function () { return rules !== null; }, "CSSUtils.findMatchingRules() timeout", 1000);
1489+
1490+
runs(function () {
1491+
expect(rules.length).toBe(1);
1492+
expect(rules[0].lineStart).toBe(24);
1493+
expect(rules[0].lineEnd).toBe(26);
1494+
});
15031495
});
15041496
});
15051497
});
1498+
15061499
}); //describe("CSS Parsing")
15071500

15081501
// Unit Tests: "HTMLUtils (css)"

test/spec/ExtensionUtils-test.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121
*
2222
*/
2323

24+
2425
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
25-
/*global $, define, describe, it, expect, beforeEach, afterEach, waitsFor, runs, waitsForDone, waitsForFail */
26+
/*global $, define, describe, it, expect, beforeEach, afterEach, waitsFor, runs, waitsForDone, waitsForFail, beforeFirst, afterLast */
2627

2728
define(function (require, exports, module) {
28-
'use strict';
29+
"use strict";
2930

30-
var ExtensionUtils,
31+
var ExtensionUtils, // Load from brackets.test
3132
FileUtils = require("file/FileUtils"),
3233
SpecRunnerUtils = require("spec/SpecRunnerUtils"),
3334
LESS_RESULT = require("text!spec/ExtensionUtils-test-files/less.text");
@@ -38,7 +39,7 @@ define(function (require, exports, module) {
3839

3940
var testWindow;
4041

41-
beforeEach(function () {
42+
beforeFirst(function () {
4243
SpecRunnerUtils.createTestWindowAndRun(this, function (w) {
4344
testWindow = w;
4445

@@ -47,7 +48,7 @@ define(function (require, exports, module) {
4748
});
4849
});
4950

50-
afterEach(function () {
51+
afterLast(function () {
5152
testWindow = null;
5253
ExtensionUtils = null;
5354
SpecRunnerUtils.closeTestWindow();

0 commit comments

Comments
 (0)