Example #1
0
  describe('Sass value types', function() {
    var testModule = sassport.module('test');
    var sassList = sass.types.List(3);
    sassList.setValue(0, sass.types.String('a'));
    sassList.setValue(1, sass.types.String('b'));
    sassList.setValue(2, sass.types.String('c'));

    var sassMap = sass.types.Map(3);
    sassMap.setKey(0, sass.types.String('a'));
    sassMap.setKey(1, sass.types.String('b'));
    sassMap.setKey(2, sass.types.String('c'));
    sassMap.setValue(0, sass.types.String('one'));
    sassMap.setValue(1, sass.types.String('two'));
    sassMap.setValue(2, sass.types.String('three'));

    testModule.globals({
      '$string': sass.types.String('foobar'),
      '$number': sass.types.Number(123.456),
      '$number-unit': sass.types.Number(123.456, 'px'),
      '$color': sass.types.Color(200, 200, 200, 0.8),
      '$list': sassList,
      '$map': sassMap,
      '$boolean': sass.types.Boolean(false),
      '$null': sass.types.Null()
    });

    it('should map JS value types to Sass types correctly', function(done) {    
      assertRenderSync(
        sassport([testModule]),
        '@import "test"; test {string: type-of($string); number: type-of($number); number-unit: type-of($number-unit); color: type-of($color); list: type-of($list); map: type-of($map); boolean: type-of($boolean); null: type-of($null); }',
        'test{string:string;number:number;number-unit:number;color:color;list:list;map:map;boolean:bool;null:null}\n',
        done);
    });
  });
 it("should stringify maps", function (done) {
   var m = sass.types.Map(1);
   m.setKey(0, sass.types.Number(2, "px"));
   m.setValue(0, sass.types.Color(30, 127, 0, 1.0));
   assert.equal("(2px: rgba(30, 127, 0, 1))", sassUtils.sassString(m));
   done();
 });