it("can check for falsy values", function(done) {
   assert.equal(true, sassUtils.isFalsy(sass.types.Null()));
   assert.equal(true, sassUtils.isFalsy(sass.types.Boolean(false)));
   assert.equal(false, sassUtils.isFalsy(sass.types.Boolean(true)));
   assert.equal(false, sassUtils.isFalsy(sass.types.Number(0)));
   assert.equal(false, sassUtils.isFalsy(sass.types.String("")));
   assert.equal(false, sassUtils.isFalsy(sass.types.List(0)));
   assert.equal(false, sassUtils.isFalsy(sass.types.Map(0)));
   done();
 });
 it("value.isFalsy()", function(done) {
   assert.equal(true, sass.types.Null().isFalsy());
   assert.equal(true, sass.types.Boolean(false).isFalsy());
   assert.equal(false, sass.types.Boolean(true).isFalsy());
   assert.equal(false, sass.types.Number(0).isFalsy());
   assert.equal(false, sass.types.String("").isFalsy());
   assert.equal(false, sass.types.List(0).isFalsy());
   assert.equal(false, sass.types.Map(0).isFalsy());
   done();
 });
Example #3
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 lists", function (done) {
   var l = sass.types.List(3);
   l.setValue(0, sass.types.Number(5, "px"));
   l.setValue(1, sass.types.Boolean(true));
   l.setValue(2, sass.types.String("'asdf'"));
   assert.equal("(5px, true, 'asdf')", sassUtils.sassString(l));
   done();
 });
 it("can check for null", function(done) {
   assert.equal(true, sassUtils.isNull(sass.types.Null()));
   assert.equal(false, sassUtils.isNull(sass.types.Boolean(true)));
   assert.equal(false, sassUtils.isNull(sass.types.Number(2, "px")));
   assert.equal(false, sassUtils.isNull(sass.types.String("foo")));
   assert.equal(false, sassUtils.isNull(sass.types.List(0)));
   assert.equal(false, sassUtils.isNull(sass.types.Map(0)));
   done();
 });
 it("knows simplified type names (as returned by sass's type-of function)", function(done) {
   assert.equal("null", sassUtils.typeOf(sass.types.Null()));
   assert.equal("bool", sassUtils.typeOf(sass.types.Boolean(true)));
   assert.equal("number", sassUtils.typeOf(sass.types.Number(2, "px")));
   assert.equal("string", sassUtils.typeOf(sass.types.String("foo")));
   assert.equal("list", sassUtils.typeOf(sass.types.List(0)));
   assert.equal("map", sassUtils.typeOf(sass.types.Map(0)));
   done();
 });
 it("should stringify space delimited lists", function (done) {
   var l = sass.types.List(3);
   l.setSeparator(false);
   l.setValue(0, sass.types.Number(5, "px"));
   l.setValue(1, sass.types.Boolean(true));
   l.setValue(2, sass.types.String("'asdf'"));
   assert.equal("(5px true 'asdf')", sassUtils.sassString(l));
   done();
 });
 it("should stringify false", function (done) {
   assert.equal("false", sassUtils.sassString(sass.types.Boolean(false)));
   done();
 });
 it("boolean.sassString()", function (done) {
   assert.equal("true", sass.types.Boolean(true).sassString());
   done();
 });