|
22 | 22 | */ |
23 | 23 |
|
24 | 24 | /*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 */ |
26 | 26 |
|
27 | 27 | define(function (require, exports, module) { |
28 | | - 'use strict'; |
| 28 | + "use strict"; |
29 | 29 |
|
30 | 30 | var NativeFileSystem = require("file/NativeFileSystem").NativeFileSystem, |
31 | 31 | Async = require("utils/Async"), |
@@ -568,7 +568,7 @@ define(function (require, exports, module) { |
568 | 568 | }); // describe("CSSUtils") |
569 | 569 |
|
570 | 570 |
|
571 | | - describe("CSS Parsing: ", function () { |
| 571 | + describe("CSS Parsing", function () { |
572 | 572 |
|
573 | 573 | var lastCssCode, |
574 | 574 | match, |
@@ -639,7 +639,7 @@ define(function (require, exports, module) { |
639 | 639 | }); |
640 | 640 |
|
641 | 641 |
|
642 | | - describe("Simple selectors: ", function () { |
| 642 | + describe("Simple selectors", function () { |
643 | 643 |
|
644 | 644 | it("should match a lone type selector given a type", function () { |
645 | 645 | var result = match("div { color:red }", { tag: "div" }); |
@@ -1366,143 +1366,136 @@ define(function (require, exports, module) { |
1366 | 1366 |
|
1367 | 1367 | }); // describe("Known Issues") |
1368 | 1368 |
|
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 | | - }); |
1406 | 1369 |
|
1407 | | - |
1408 | | - describe("Working with unsaved changes", function () { |
| 1370 | + describe("CSS Intgration Tests", function () { |
1409 | 1371 | this.category = "integration"; |
1410 | 1372 |
|
1411 | 1373 | var testPath = SpecRunnerUtils.getTestPath("/spec/CSSUtils-test-files"), |
| 1374 | + testWindow, |
1412 | 1375 | CSSUtils, |
1413 | 1376 | DocumentManager, |
1414 | 1377 | 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 | + |
1418 | 1383 | // Load module instances from brackets.test |
1419 | 1384 | CSSUtils = testWindow.brackets.test.CSSUtils; |
1420 | 1385 | DocumentManager = testWindow.brackets.test.DocumentManager; |
1421 | 1386 | FileViewController = testWindow.brackets.test.FileViewController; |
1422 | | - |
| 1387 | + |
| 1388 | + // Load test project |
1423 | 1389 | SpecRunnerUtils.loadProjectInTestWindow(testPath); |
1424 | 1390 | }); |
1425 | 1391 | }); |
1426 | | - |
1427 | | - afterEach(function () { |
| 1392 | + |
| 1393 | + afterLast(function () { |
1428 | 1394 | CSSUtils = null; |
1429 | 1395 | DocumentManager = null; |
1430 | 1396 | FileViewController = null; |
1431 | 1397 | SpecRunnerUtils.closeTestWindow(); |
1432 | 1398 | }); |
1433 | 1399 |
|
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 () { |
1447 | 1406 |
|
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); |
1457 | 1414 |
|
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 | + }); |
1467 | 1420 | }); |
1468 | 1421 | }); |
1469 | 1422 |
|
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 () { |
1479 | 1424 |
|
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; |
1486 | 1428 |
|
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 | + }); |
1489 | 1434 |
|
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 | + }); |
1495 | 1459 | }); |
1496 | 1460 |
|
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 | + }); |
1503 | 1495 | }); |
1504 | 1496 | }); |
1505 | 1497 | }); |
| 1498 | + |
1506 | 1499 | }); //describe("CSS Parsing") |
1507 | 1500 |
|
1508 | 1501 | // Unit Tests: "HTMLUtils (css)" |
|
0 commit comments