Skip to content

Commit

Permalink
test(win): add tests for windows line endings
Browse files Browse the repository at this point in the history
  • Loading branch information
jgranstrom committed Nov 29, 2017
1 parent 1091bea commit 257db5f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
23 changes: 21 additions & 2 deletions test/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ const { EOL } = require('os');
const basicImplicitFile = path.join(__dirname, 'sass', 'basic-implicit.scss');
const basicExplicitFile = path.join(__dirname, 'sass', 'basic-explicit.scss');
const basicMixedFile = path.join(__dirname, 'sass', 'basic-mixed.scss');
const basicMixedFileWinLe = path.join(__dirname, 'sass', 'basic-mixed-win-le.scss');

function verifyBasic(rendered, sourceFile, explicit, mixed) {
function verifyBasic(rendered, sourceFile, explicit, mixed, expectedEol = EOL) {
expect(rendered.vars).to.exist;
expect(rendered.vars).to.have.property('global');
expect(rendered.vars.global).to.have.property('$number1');
Expand Down Expand Up @@ -117,7 +118,7 @@ function verifyBasic(rendered, sourceFile, explicit, mixed) {
expect(rendered.vars.global.$map.sources[0]).to.equal(normalizePath(sourceFile));
expect(rendered.vars.global.$map.declarations).to.have.length(1);
expect(rendered.vars.global.$map.declarations[0].expression).to.be.oneOf([
`(${EOL} number: 2em,${EOL} string: 'mapstring'${EOL})${ explicit ? ' !global' : ''}`,
`(${expectedEol} number: 2em,${expectedEol} string: 'mapstring'${expectedEol})${ explicit ? ' !global' : ''}`,
`(\n number: 2em,\n string: 'mapstring'\n)${ explicit ? ' !global' : ''}`,
]);
if(explicit) {
Expand Down Expand Up @@ -178,3 +179,21 @@ describe('basic-mixed', () => {
});
});
});

describe('basic-mixed-win-le', () => {
describe('sync', () => {
it('should extract all variables', () => {
const rendered = renderSync({ file: basicMixedFileWinLe })
verifyBasic(rendered, basicMixedFileWinLe, false, true, '\r\n');
});
});

describe('async', () => {
it('should extract all variables', () => {
return render({ file: basicMixedFileWinLe })
.then(rendered => {
verifyBasic(rendered, basicMixedFileWinLe, false, true, '\r\n');
});
});
});
});
27 changes: 27 additions & 0 deletions test/sass/basic-mixed-win-le.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@mixin fg($color: green) {
color: $color;
}
@function get-color() {
@return red;
}

@function test($attr1, $attr2, $attr3: null, $attr4: null, $attr5: null) {
@return 'hello';
}


$list: 1px solid black;
$string: 'string';
$map: (
number: 2em,
string: 'mapstring'
);

div {
$number1: 100px !global;
$number2: $number1 * 2 !global;
$color: get-color() !global;
}

$boolean: true;
$null: null;

0 comments on commit 257db5f

Please sign in to comment.