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
8114285e
Commit
8114285e
authored
Apr 29, 2014
by
Johannes Ewald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests for stats-object and refactored tests
parent
51f472fe
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
216 additions
and
48 deletions
+216
-48
cli.js
test/cli.js
+4
-2
included_files.scss
test/included_files.scss
+2
-0
sample.js
test/sample.js
+31
-0
stats_spec.js
test/stats_spec.js
+161
-0
test.js
test/test.js
+18
-46
No files found.
test/cli.js
View file @
8114285e
...
@@ -39,7 +39,8 @@ describe('cli', function() {
...
@@ -39,7 +39,8 @@ describe('cli', function() {
exec
(
'node '
+
cliPath
+
' '
+
sampleFilename
,
{
exec
(
'node '
+
cliPath
+
' '
+
sampleFilename
,
{
cwd
:
__dirname
cwd
:
__dirname
},
function
()
{
},
function
(
err
)
{
assert
.
equal
(
err
,
null
);
fs
.
exists
(
resultPath
,
function
(
exists
)
{
fs
.
exists
(
resultPath
,
function
(
exists
)
{
assert
(
exists
);
assert
(
exists
);
...
@@ -53,7 +54,8 @@ describe('cli', function() {
...
@@ -53,7 +54,8 @@ describe('cli', function() {
exec
(
'node '
+
cliPath
+
' '
+
sampleFilename
+
' ../out.css'
,
{
exec
(
'node '
+
cliPath
+
' '
+
sampleFilename
+
' ../out.css'
,
{
cwd
:
__dirname
cwd
:
__dirname
},
function
()
{
},
function
(
err
)
{
assert
.
equal
(
err
,
null
);
fs
.
exists
(
resultPath
,
function
(
exists
)
{
fs
.
exists
(
resultPath
,
function
(
exists
)
{
assert
(
exists
);
assert
(
exists
);
...
...
test/included_files.scss
0 → 100644
View file @
8114285e
@import
"sample.scss"
;
@import
"image_path.scss"
;
test/sample.js
0 → 100644
View file @
8114285e
exports
.
input
=
'#navbar {
\
width: 80%;
\
height: 23px; }
\
#navbar ul {
\
list-style-type: none; }
\
#navbar li {
\
float: left;
\
a {
\
font-weight: bold; }}
\
@mixin keyAnimation($name, $attr, $value) {
\
@-webkit-keyframes #{$name} {
\
0% { #{$attr}: $value; }
\
}
\
}'
;
// Note that the bad
exports
.
badInput
=
'#navbar
\
n
\
width: 80%'
;
exports
.
expectedRender
=
'#navbar {
\
n
\
width: 80%;
\
n
\
height: 23px; }
\
n
\
\
n
\
#navbar ul {
\
n
\
list-style-type: none; }
\
n
\
\
n
\
#navbar li {
\
n
\
float: left; }
\
n
\
#navbar li a {
\
n
\
font-weight: bold; }
\
n'
;
\ No newline at end of file
test/stats_spec.js
0 → 100644
View file @
8114285e
'use strict'
;
var
path
=
require
(
'path'
);
var
assert
=
require
(
'assert'
);
var
sass
=
process
.
env
.
NODESASS_COVERAGE
?
require
(
'../sass-coverage'
)
:
require
(
'../sass'
);
var
includedFilesFile
=
path
.
resolve
(
__dirname
,
'included_files.scss'
);
var
sampleFile
=
path
.
resolve
(
__dirname
,
'sample.scss'
);
var
imagePathFile
=
path
.
resolve
(
__dirname
,
'image_path.scss'
);
var
sample
=
require
(
'./sample.js'
);
describe
(
'stats'
,
function
()
{
var
start
=
Date
.
now
();
var
stats
;
function
checkTimingStats
()
{
it
(
'should provide a start timestamp'
,
function
()
{
assert
.
ok
(
typeof
stats
.
start
===
'number'
);
assert
.
ok
(
stats
.
start
>=
start
);
});
it
(
'should provide an end timestamp'
,
function
()
{
assert
.
ok
(
typeof
stats
.
end
===
'number'
);
assert
.
ok
(
stats
.
end
>=
stats
.
start
);
});
it
(
'should provide a duration'
,
function
()
{
assert
.
ok
(
typeof
stats
.
duration
===
'number'
);
assert
.
equal
(
stats
.
end
-
stats
.
start
,
stats
.
duration
);
});
}
describe
(
'using renderSync()'
,
function
()
{
describe
(
'and file-context'
,
function
()
{
before
(
function
()
{
sass
.
renderSync
({
file
:
includedFilesFile
,
stats
:
stats
=
{}
});
});
checkTimingStats
();
it
(
'should contain the given entry file'
,
function
()
{
assert
.
equal
(
stats
.
entry
,
includedFilesFile
);
});
it
(
'should contain an array of all included files'
,
function
()
{
// the included_files aren't sorted by libsass in any way
assert
.
deepEqual
(
stats
.
includedFiles
.
sort
(),
[
includedFilesFile
,
sampleFile
,
imagePathFile
].
sort
()
);
});
it
(
'should contain an array with the entry-file if the there are no import statements'
,
function
()
{
sass
.
renderSync
({
file
:
sampleFile
,
stats
:
stats
=
{}
});
assert
.
deepEqual
(
stats
.
includedFiles
,
[
sampleFile
]);
});
});
describe
(
'and data-context'
,
function
()
{
before
(
function
()
{
sass
.
renderSync
({
data
:
sample
.
input
,
stats
:
stats
=
{}
});
});
checkTimingStats
();
it
(
'should state "data" as entry file'
,
function
()
{
assert
.
equal
(
stats
.
entry
,
'data'
);
});
it
(
'should contain an empty array as includedFiles in the data-context'
,
function
()
{
assert
.
deepEqual
(
stats
.
includedFiles
,
[]);
});
});
});
describe
(
'using render()'
,
function
()
{
describe
(
'and file-context'
,
function
()
{
before
(
function
(
done
)
{
sass
.
render
({
file
:
includedFilesFile
,
stats
:
stats
=
{},
success
:
function
()
{
done
();
},
error
:
done
});
});
checkTimingStats
();
it
(
'should contain the given entry file'
,
function
()
{
assert
.
equal
(
stats
.
entry
,
includedFilesFile
);
});
it
(
'should contain an array of all included files'
,
function
()
{
// the included_files aren't sorted by libsass in any way
assert
.
deepEqual
(
stats
.
includedFiles
.
sort
(),
[
includedFilesFile
,
sampleFile
,
imagePathFile
].
sort
()
);
});
it
(
'should contain an array with the entry-file if the there are no import statements'
,
function
(
done
)
{
sass
.
render
({
file
:
sampleFile
,
stats
:
stats
=
{},
success
:
function
()
{
assert
.
deepEqual
(
stats
.
includedFiles
,
[
sampleFile
]);
done
();
},
error
:
done
});
});
});
describe
(
'and data-context'
,
function
()
{
before
(
function
(
done
)
{
sass
.
render
({
data
:
sample
.
input
,
stats
:
stats
=
{},
success
:
function
()
{
done
();
},
error
:
done
});
});
checkTimingStats
();
it
(
'should state "data" as entry file'
,
function
()
{
assert
.
equal
(
stats
.
entry
,
'data'
);
});
it
(
'should contain an empty array as includedFiles in the data-context'
,
function
()
{
assert
.
deepEqual
(
stats
.
includedFiles
,
[]);
});
});
});
});
\ No newline at end of file
test/test.js
View file @
8114285e
...
@@ -5,53 +5,25 @@ var fs = require('fs');
...
@@ -5,53 +5,25 @@ var fs = require('fs');
var
sinon
=
require
(
'sinon'
);
var
sinon
=
require
(
'sinon'
);
var
badSampleFilename
=
'sample.scss'
;
var
badSampleFilename
=
'sample.scss'
;
var
sampleFilename
=
path
.
resolve
(
__dirname
,
'sample.scss'
);
var
sampleFilename
=
path
.
resolve
(
__dirname
,
'sample.scss'
);
var
sample
=
require
(
'./sample.js'
);
var
scssStr
=
'#navbar {
\
width: 80%;
\
height: 23px; }
\
#navbar ul {
\
list-style-type: none; }
\
#navbar li {
\
float: left;
\
a {
\
font-weight: bold; }}
\
@mixin keyAnimation($name, $attr, $value) {
\
@-webkit-keyframes #{$name} {
\
0% { #{$attr}: $value; }
\
}
\
}'
;
// Note that the bad
var
badInput
=
'#navbar
\
n
\
width: 80%'
;
var
expectedRender
=
'#navbar {
\
n
\
width: 80%;
\
n
\
height: 23px; }
\
n
\
\
n
\
#navbar ul {
\
n
\
list-style-type: none; }
\
n
\
\
n
\
#navbar li {
\
n
\
float: left; }
\
n
\
#navbar li a {
\
n
\
font-weight: bold; }
\
n'
;
describe
(
'DEPRECATED: compile scss'
,
function
()
{
describe
(
'DEPRECATED: compile scss'
,
function
()
{
it
(
'should compile with render'
,
function
(
done
)
{
it
(
'should compile with render'
,
function
(
done
)
{
sass
.
render
(
s
cssStr
,
function
(
err
)
{
sass
.
render
(
s
ample
.
input
,
function
(
err
)
{
done
(
err
);
done
(
err
);
});
});
});
});
it
(
'should compile with renderSync'
,
function
(
done
)
{
it
(
'should compile with renderSync'
,
function
(
done
)
{
done
(
assert
.
ok
(
sass
.
renderSync
(
s
cssStr
)));
done
(
assert
.
ok
(
sass
.
renderSync
(
s
ample
.
input
)));
});
});
it
(
'should match compiled string with render'
,
function
(
done
)
{
it
(
'should match compiled string with render'
,
function
(
done
)
{
sass
.
render
(
s
cssStr
,
function
(
err
,
css
)
{
sass
.
render
(
s
ample
.
input
,
function
(
err
,
css
)
{
if
(
!
err
)
{
if
(
!
err
)
{
done
(
assert
.
equal
(
css
,
expectedRender
));
done
(
assert
.
equal
(
css
,
sample
.
expectedRender
));
}
else
{
}
else
{
done
(
err
);
done
(
err
);
}
}
...
@@ -59,12 +31,12 @@ describe('DEPRECATED: compile scss', function() {
...
@@ -59,12 +31,12 @@ describe('DEPRECATED: compile scss', function() {
});
});
it
(
'should match compiled string with renderSync'
,
function
(
done
)
{
it
(
'should match compiled string with renderSync'
,
function
(
done
)
{
done
(
assert
.
equal
(
sass
.
renderSync
(
s
cssStr
),
expectedRender
));
done
(
assert
.
equal
(
sass
.
renderSync
(
s
ample
.
input
),
sample
.
expectedRender
));
});
});
it
(
'should throw an exception for bad input'
,
function
(
done
)
{
it
(
'should throw an exception for bad input'
,
function
(
done
)
{
done
(
assert
.
throws
(
function
()
{
done
(
assert
.
throws
(
function
()
{
sass
.
renderSync
(
badInput
);
sass
.
renderSync
(
sample
.
badInput
);
}));
}));
});
});
});
});
...
@@ -72,7 +44,7 @@ describe('DEPRECATED: compile scss', function() {
...
@@ -72,7 +44,7 @@ describe('DEPRECATED: compile scss', function() {
describe
(
'compile scss'
,
function
()
{
describe
(
'compile scss'
,
function
()
{
it
(
'should compile with render'
,
function
(
done
)
{
it
(
'should compile with render'
,
function
(
done
)
{
sass
.
render
({
sass
.
render
({
data
:
s
cssStr
,
data
:
s
ample
.
input
,
success
:
function
(
css
)
{
success
:
function
(
css
)
{
done
(
assert
.
ok
(
css
));
done
(
assert
.
ok
(
css
));
}
}
...
@@ -80,14 +52,14 @@ describe('compile scss', function() {
...
@@ -80,14 +52,14 @@ describe('compile scss', function() {
});
});
it
(
'should compile with renderSync'
,
function
(
done
)
{
it
(
'should compile with renderSync'
,
function
(
done
)
{
done
(
assert
.
ok
(
sass
.
renderSync
({
data
:
s
cssStr
})));
done
(
assert
.
ok
(
sass
.
renderSync
({
data
:
s
ample
.
input
})));
});
});
it
(
'should match compiled string with render'
,
function
(
done
)
{
it
(
'should match compiled string with render'
,
function
(
done
)
{
sass
.
render
({
sass
.
render
({
data
:
s
cssStr
,
data
:
s
ample
.
input
,
success
:
function
(
css
)
{
success
:
function
(
css
)
{
done
(
assert
.
equal
(
css
,
expectedRender
));
done
(
assert
.
equal
(
css
,
sample
.
expectedRender
));
},
},
error
:
function
(
error
)
{
error
:
function
(
error
)
{
done
(
error
);
done
(
error
);
...
@@ -109,12 +81,12 @@ describe('compile scss', function() {
...
@@ -109,12 +81,12 @@ describe('compile scss', function() {
});
});
it
(
'should match compiled string with renderSync'
,
function
(
done
)
{
it
(
'should match compiled string with renderSync'
,
function
(
done
)
{
done
(
assert
.
equal
(
sass
.
renderSync
({
data
:
s
cssStr
}),
expectedRender
));
done
(
assert
.
equal
(
sass
.
renderSync
({
data
:
s
ample
.
input
}),
sample
.
expectedRender
));
});
});
it
(
'should throw an exception for bad input'
,
function
(
done
)
{
it
(
'should throw an exception for bad input'
,
function
(
done
)
{
done
(
assert
.
throws
(
function
()
{
done
(
assert
.
throws
(
function
()
{
sass
.
renderSync
({
data
:
badInput
});
sass
.
renderSync
({
data
:
sample
.
badInput
});
}));
}));
});
});
});
});
...
@@ -140,7 +112,7 @@ describe('compile file with image path', function(){
...
@@ -140,7 +112,7 @@ describe('compile file with image path', function(){
file
:
path
.
resolve
(
__dirname
,
'image_path.scss'
),
file
:
path
.
resolve
(
__dirname
,
'image_path.scss'
),
imagePath
:
'/path/to/images'
,
imagePath
:
'/path/to/images'
,
success
:
function
(
css
)
{
success
:
function
(
css
)
{
done
(
assert
.
equal
(
css
,
'body {
\
n background-image: url(
\
"/path/to/images/image.png
\
"); }
\
n'
));
done
(
assert
.
equal
(
css
,
'body {
\
n background-image: url(
"/path/to/images/image.png
"); }
\
n'
));
},
},
error
:
function
(
error
)
{
error
:
function
(
error
)
{
done
(
error
);
done
(
error
);
...
@@ -154,7 +126,7 @@ describe('compile file', function() {
...
@@ -154,7 +126,7 @@ describe('compile file', function() {
sass
.
render
({
sass
.
render
({
file
:
sampleFilename
,
file
:
sampleFilename
,
success
:
function
(
css
)
{
success
:
function
(
css
)
{
done
(
assert
.
equal
(
css
,
expectedRender
));
done
(
assert
.
equal
(
css
,
sample
.
expectedRender
));
},
},
error
:
function
(
error
)
{
error
:
function
(
error
)
{
done
(
error
);
done
(
error
);
...
@@ -170,7 +142,7 @@ describe('compile file', function() {
...
@@ -170,7 +142,7 @@ describe('compile file', function() {
sass
.
render
({
sass
.
render
({
file
:
sampleFilename
,
file
:
sampleFilename
,
success
:
function
(
css
)
{
success
:
function
(
css
)
{
done
(
assert
.
equal
(
css
,
expectedRender
));
done
(
assert
.
equal
(
css
,
sample
.
expectedRender
));
},
},
error
:
function
(
error
)
{
error
:
function
(
error
)
{
done
(
error
);
done
(
error
);
...
@@ -179,7 +151,7 @@ describe('compile file', function() {
...
@@ -179,7 +151,7 @@ describe('compile file', function() {
});
});
it
(
'should match compiled string with renderSync'
,
function
(
done
)
{
it
(
'should match compiled string with renderSync'
,
function
(
done
)
{
done
(
assert
.
equal
(
sass
.
renderSync
({
file
:
sampleFilename
}),
expectedRender
));
done
(
assert
.
equal
(
sass
.
renderSync
({
file
:
sampleFilename
}),
sample
.
expectedRender
));
});
});
it
(
'should throw an exception for bad input'
,
function
(
done
)
{
it
(
'should throw an exception for bad input'
,
function
(
done
)
{
...
@@ -209,7 +181,7 @@ describe('render to file', function() {
...
@@ -209,7 +181,7 @@ describe('render to file', function() {
outFile
:
outFile
,
outFile
:
outFile
,
success
:
function
()
{
success
:
function
()
{
var
contents
=
filesWritten
[
outFile
];
var
contents
=
filesWritten
[
outFile
];
done
(
assert
.
equal
(
contents
,
expectedRender
));
done
(
assert
.
equal
(
contents
,
sample
.
expectedRender
));
},
},
error
:
function
(
error
)
{
error
:
function
(
error
)
{
done
(
error
);
done
(
error
);
...
...
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