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

Commit

Permalink
Fix CSSUtils unit tests.
Browse files Browse the repository at this point in the history
The tests assumed that CodeMirror modes are loaded at the time of test
definition.
  • Loading branch information
busykai committed Jul 14, 2013
1 parent c3df4c9 commit b87f6a0
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions test/spec/CSSUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,32 +515,35 @@ define(function (require, exports, module) {
});

describe("find correct positions of selectors", function () {
var selectors;

selectors = CSSUtils.extractAllSelectors(selectorPositionsTestCss);

it("should find selector positions when whitespace between selector and '{'", function () {
var selectors = CSSUtils.extractAllSelectors(selectorPositionsTestCss);
expect([selectors[0].selectorStartChar, selectors[0].selectorEndChar]).toEqual([0, 3]);
});

it("should find selector positions when no whitespace between selector and '{'", function () {
var selectors = CSSUtils.extractAllSelectors(selectorPositionsTestCss);
expect([selectors[1].selectorStartChar, selectors[1].selectorEndChar]).toEqual([0, 3]);
});

it("should find selector positions when '{' on the next line", function () {
var selectors = CSSUtils.extractAllSelectors(selectorPositionsTestCss);
expect([selectors[2].selectorStartChar, selectors[2].selectorEndChar]).toEqual([0, 3]);
});

it("should find selector positions when '{' on the next line and selector is indented", function () {
var selectors = CSSUtils.extractAllSelectors(selectorPositionsTestCss);
expect([selectors[3].selectorStartChar, selectors[3].selectorEndChar]).toEqual([4, 7]);
});

it("should find selector positions when '{' on the next line and selector is indented with tabs", function () {
var selectors = CSSUtils.extractAllSelectors(selectorPositionsTestCss);
expect([selectors[4].selectorStartChar, selectors[4].selectorEndChar]).toEqual([1, 4]);
});

it("should find selector positions in a selector group when '{' on the next line", function () {
var expected = [0, 2, 4, 6, 8, 10],
var selectors = CSSUtils.extractAllSelectors(selectorPositionsTestCss),
expected = [0, 2, 4, 6, 8, 10],
result = [
selectors[5].selectorStartChar, selectors[5].selectorEndChar,
selectors[6].selectorStartChar, selectors[6].selectorEndChar,
Expand All @@ -551,7 +554,8 @@ define(function (require, exports, module) {
});

it("should find selector positions in a selector group when '{' on the next line and selector group is indented", function () {
var expected = [4, 6, 8, 10, 12, 14],
var selectors = CSSUtils.extractAllSelectors(selectorPositionsTestCss),
expected = [4, 6, 8, 10, 12, 14],
result = [
selectors[8].selectorStartChar, selectors[8].selectorEndChar,
selectors[9].selectorStartChar, selectors[9].selectorEndChar,
Expand Down

0 comments on commit b87f6a0

Please sign in to comment.