|
| 1 | +/*globals describe */ |
| 2 | + |
| 3 | +var testLocals = require("./helpers").testLocals; |
| 4 | +var test = require("./helpers").test; |
| 5 | + |
| 6 | +function testLocal(name, input, result, localsResult, query, modules) { |
| 7 | +result.locals = localsResult; |
| 8 | +test(name, input, result, query, modules); |
| 9 | +} |
| 10 | + |
| 11 | +describe("values", function() { |
| 12 | +testLocals("should export values", |
| 13 | +"@value def: red; @value ghi: 1px solid black", |
| 14 | +{ |
| 15 | +def: "red", |
| 16 | +ghi: "1px solid black" |
| 17 | +}, |
| 18 | +"" |
| 19 | +); |
| 20 | +testLocals("should export values and locals", |
| 21 | +"@value def: red; .ghi { color: def; }", |
| 22 | +{ |
| 23 | +def: "red", |
| 24 | +ghi: "_ghi" |
| 25 | +}, |
| 26 | +"?modules&localIdentName=_[local]" |
| 27 | +); |
| 28 | +testLocal("should import values from other module", |
| 29 | +"@value def from './file'; .ghi { color: def; }", [ |
| 30 | +[ 2, "", "" ], |
| 31 | +[ 1, ".ghi { color: red; }", "" ] |
| 32 | +], { |
| 33 | +def: "red" |
| 34 | +}, "", { |
| 35 | +"./file": (function() { |
| 36 | +var a = [[2, "", ""]]; |
| 37 | +a.locals = { |
| 38 | +def: "red" |
| 39 | +}; |
| 40 | +return a; |
| 41 | +})() |
| 42 | +} |
| 43 | +); |
| 44 | +testLocal("should import values with renaming", |
| 45 | +"@value def as aaa from './file1'; @value def as bbb from './file2'; .ghi { background: aaa, bbb, def; }", [ |
| 46 | +[ 2, "", "" ], |
| 47 | +[ 3, "", "" ], |
| 48 | +[ 1, ".ghi { background: red, green, def; }", "" ] |
| 49 | +], { |
| 50 | +aaa: "red", |
| 51 | +bbb: "green" |
| 52 | +}, "", { |
| 53 | +"./file1": (function() { |
| 54 | +var a = [[2, "", ""]]; |
| 55 | +a.locals = { |
| 56 | +def: "red" |
| 57 | +}; |
| 58 | +return a; |
| 59 | +})(), |
| 60 | +"./file2": (function() { |
| 61 | +var a = [[3, "", ""]]; |
| 62 | +a.locals = { |
| 63 | +def: "green" |
| 64 | +}; |
| 65 | +return a; |
| 66 | +})() |
| 67 | +} |
| 68 | +); |
| 69 | +}); |
0 commit comments