Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sass
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
楚学文
node-sass
Commits
203f8d66
Commit
203f8d66
authored
Jan 31, 2017
by
xzyfer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mirror render and renderSync tests
parent
43106236
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
152 additions
and
15 deletions
+152
-15
api.js
test/api.js
+152
-15
No files found.
test/api.js
View file @
203f8d66
...
...
@@ -87,6 +87,19 @@ describe('api', function() {
});
});
it
(
'should compile sass to css using indented syntax'
,
function
(
done
)
{
var
src
=
read
(
fixture
(
'indent/index.sass'
),
'utf8'
);
var
expected
=
read
(
fixture
(
'indent/expected.css'
),
'utf8'
).
trim
();
sass
.
render
({
data
:
src
,
indentedSyntax
:
true
},
function
(
error
,
result
)
{
assert
.
equal
(
result
.
css
.
toString
().
trim
(),
expected
.
replace
(
/
\r\n
/g
,
'
\
n'
));
done
();
});
});
it
(
'should NOT compile empty data string'
,
function
(
done
)
{
sass
.
render
({
data
:
''
...
...
@@ -96,27 +109,14 @@ describe('api', function() {
});
});
it
(
'should NOT compile without
parameters
'
,
function
(
done
)
{
it
(
'should NOT compile without
any input
'
,
function
(
done
)
{
sass
.
render
({
},
function
(
error
)
{
assert
.
equal
(
error
.
message
,
'No input specified: provide a file name or a source string to process'
);
done
();
});
});
it
(
'should compile sass to css using indented syntax'
,
function
(
done
)
{
var
src
=
read
(
fixture
(
'indent/index.sass'
),
'utf8'
);
var
expected
=
read
(
fixture
(
'indent/expected.css'
),
'utf8'
).
trim
();
sass
.
render
({
data
:
src
,
indentedSyntax
:
true
},
function
(
error
,
result
)
{
assert
.
equal
(
result
.
css
.
toString
().
trim
(),
expected
.
replace
(
/
\r\n
/g
,
'
\
n'
));
done
();
});
});
it
(
'should throw error status 1 for bad input'
,
function
(
done
)
{
it
(
'should returnn error status 1 for bad input'
,
function
(
done
)
{
sass
.
render
({
data
:
'#navbar width 80%;'
},
function
(
error
)
{
...
...
@@ -1406,6 +1406,143 @@ describe('api', function() {
done
();
});
it
(
'should compile with include paths'
,
function
(
done
)
{
var
src
=
read
(
fixture
(
'include-path/index.scss'
),
'utf8'
);
var
expected
=
read
(
fixture
(
'include-path/expected.css'
),
'utf8'
).
trim
();
var
result
=
sass
.
renderSync
({
data
:
src
,
includePaths
:
[
fixture
(
'include-path/functions'
),
fixture
(
'include-path/lib'
)
]
});
assert
.
equal
(
result
.
css
.
toString
().
trim
(),
expected
.
replace
(
/
\r\n
/g
,
'
\
n'
));
done
();
});
it
(
'should add cwd to the front on include paths'
,
function
(
done
)
{
var
src
=
fixture
(
'cwd-include-path/root/index.scss'
);
var
expected
=
read
(
fixture
(
'cwd-include-path/expected.css'
),
'utf8'
).
trim
();
var
cwd
=
process
.
cwd
();
process
.
chdir
(
fixture
(
'cwd-include-path'
));
var
result
=
sass
.
renderSync
({
file
:
src
,
includePaths
:
[
fixture
(
'include-path/functions'
),
fixture
(
'include-path/lib'
)
]
});
process
.
chdir
(
cwd
);
assert
.
equal
(
result
.
css
.
toString
().
trim
(),
expected
.
replace
(
/
\r\n
/g
,
'
\
n'
));
done
();
});
it
(
'should check SASS_PATH in the specified order'
,
function
(
done
)
{
var
src
=
read
(
fixture
(
'sass-path/index.scss'
),
'utf8'
);
var
expectedRed
=
read
(
fixture
(
'sass-path/expected-red.css'
),
'utf8'
).
trim
();
var
expectedOrange
=
read
(
fixture
(
'sass-path/expected-orange.css'
),
'utf8'
).
trim
();
var
envIncludes
=
[
fixture
(
'sass-path/red'
),
fixture
(
'sass-path/orange'
)
];
process
.
env
.
SASS_PATH
=
envIncludes
.
join
(
path
.
delimiter
);
var
result
=
sass
.
renderSync
({
data
:
src
,
includePaths
:
[]
});
assert
.
equal
(
result
.
css
.
toString
().
trim
(),
expectedRed
.
replace
(
/
\r\n
/g
,
'
\
n'
));
process
.
env
.
SASS_PATH
=
envIncludes
.
reverse
().
join
(
path
.
delimiter
);
result
=
sass
.
renderSync
({
data
:
src
,
includePaths
:
[]
});
assert
.
equal
(
result
.
css
.
toString
().
trim
(),
expectedOrange
.
replace
(
/
\r\n
/g
,
'
\
n'
));
done
();
});
it
(
'should prefer include path over SASS_PATH'
,
function
(
done
)
{
var
src
=
read
(
fixture
(
'sass-path/index.scss'
),
'utf8'
);
var
expectedRed
=
read
(
fixture
(
'sass-path/expected-red.css'
),
'utf8'
).
trim
();
var
expectedOrange
=
read
(
fixture
(
'sass-path/expected-orange.css'
),
'utf8'
).
trim
();
var
envIncludes
=
[
fixture
(
'sass-path/red'
)
];
process
.
env
.
SASS_PATH
=
envIncludes
.
join
(
path
.
delimiter
);
var
result
=
sass
.
renderSync
({
data
:
src
,
includePaths
:
[]
});
assert
.
equal
(
result
.
css
.
toString
().
trim
(),
expectedRed
.
replace
(
/
\r\n
/g
,
'
\
n'
));
result
=
sass
.
renderSync
({
data
:
src
,
includePaths
:
[
fixture
(
'sass-path/orange'
)]
});
assert
.
equal
(
result
.
css
.
toString
().
trim
(),
expectedOrange
.
replace
(
/
\r\n
/g
,
'
\
n'
));
done
();
});
it
(
'should render with precision option'
,
function
(
done
)
{
var
src
=
read
(
fixture
(
'precision/index.scss'
),
'utf8'
);
var
expected
=
read
(
fixture
(
'precision/expected.css'
),
'utf8'
).
trim
();
var
result
=
sass
.
renderSync
({
data
:
src
,
precision
:
10
});
assert
.
equal
(
result
.
css
.
toString
().
trim
(),
expected
.
replace
(
/
\r\n
/g
,
'
\
n'
));
done
();
});
it
(
'should contain all included files in stats when data is passed'
,
function
(
done
)
{
var
src
=
read
(
fixture
(
'include-files/index.scss'
),
'utf8'
);
var
expected
=
[
fixture
(
'include-files/bar.scss'
).
replace
(
/
\\
/g
,
'/'
),
fixture
(
'include-files/foo.scss'
).
replace
(
/
\\
/g
,
'/'
)
];
var
result
=
sass
.
renderSync
({
data
:
src
,
includePaths
:
[
fixture
(
'include-files'
)]
});
assert
.
deepEqual
(
result
.
stats
.
includedFiles
,
expected
);
done
();
});
it
(
'should render with indentWidth and indentType options'
,
function
(
done
)
{
var
result
=
sass
.
renderSync
({
data
:
'div { color: transparent; }'
,
indentWidth
:
7
,
indentType
:
'tab'
});
assert
.
equal
(
result
.
css
.
toString
().
trim
(),
'div {
\
n
\
t
\
t
\
t
\
t
\
t
\
t
\
tcolor: transparent; }'
);
done
();
});
it
(
'should render with linefeed option'
,
function
(
done
)
{
var
result
=
sass
.
renderSync
({
data
:
'div { color: transparent; }'
,
linefeed
:
'lfcr'
});
assert
.
equal
(
result
.
css
.
toString
().
trim
(),
'div {
\
n
\
r color: transparent; }'
);
done
();
});
});
describe
(
'.renderSync(importer)'
,
function
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment