Skip to content

Commit 250e95a

Browse files
committed
added a failing test and a few pending ones
1 parent 93e749e commit 250e95a

3 files changed

Lines changed: 29 additions & 9 deletions

File tree

index.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
'use strict';
22

3-
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; };
4-
53
Object.defineProperty(exports, '__esModule', {
64
value: true
75
});
86

7+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
8+
99
var _postcss = require('postcss');
1010

11-
var _postcss2 = _interopRequireWildcard(_postcss);
11+
var _postcss2 = _interopRequireDefault(_postcss);
12+
13+
var processor = function processor(css, result) {};
1214

13-
exports['default'] = function (css, result) {};
15+
processor.defaultRandomStr = function () {
16+
return Math.random().toString(36).substr(2, 8);
17+
};
18+
processor.getRandomStr = processor.defaultRandomStr; // Easy to be mocked out
1419

20+
exports['default'] = processor;
1521
module.exports = exports['default'];

index.src.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
import postcss from 'postcss'
22

3-
export default (css, result) => {
3+
const processor = (css, result) => {
4+
45
}
6+
7+
processor.defaultRandomStr = () => Math.random().toString(36).substr(2,8)
8+
processor.getRandomStr = processor.defaultRandomStr // Easy to be mocked out
9+
10+
export default processor

test.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,24 @@ import postcss from "postcss"
33
import processor from "./index.src.js"
44

55
let pipeline = postcss([processor]),
6-
check = (desc, input, expected) => {
6+
check = (desc, input, expected, randomStrs) => {
77
it(desc, () => {
8+
processor.getRandomStr = randomStrs ? () => randomStrs.shift() : processor.defaultRandomStr
89
assert.equal(pipeline.process(input).css, expected)
910
})
1011
}
1112

1213
describe("processor", () => {
1314
check(
14-
"it should do nothing",
15-
"a { b: c; }",
16-
"a { b: c; }"
15+
"it should extract an import within a :local",
16+
`:local(.exportName) { extends: importName from "path/library.css"; other: rule; }`,
17+
`:import("path/library.css") { importName: __tmp-rand0ml0l0l; } :local(.exportName) { extends: __tmp-rand0ml0l0l; other: rule; }`,
18+
["rand0ml0l0l"]
1719
)
20+
21+
it("it should not care if single-quotes are used")
22+
it("should import multiple classes on a single line")
23+
it("should consolidate imports by file for multiple files and multiple classes")
24+
it("should ignore imports not inside a :local")
25+
it("should ignore imports not inside our rule whitelist")
1826
})

0 commit comments

Comments
 (0)