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
b2d46cdf
Commit
b2d46cdf
authored
Mar 10, 2015
by
Adeel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test: Add tests for extensions.
PR URL: #743.
parent
62dc218e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
17 deletions
+83
-17
api.js
test/api.js
+83
-17
No files found.
test/api.js
View file @
b2d46cdf
...
...
@@ -103,23 +103,6 @@ describe('api', function() {
});
});
it
(
'should throw error when libsass binary is missing.'
,
function
(
done
)
{
var
originalBin
=
process
.
sass
.
binaryPath
,
renamedBin
=
[
originalBin
,
'_moved'
].
join
(
''
);
assert
.
throws
(
function
()
{
fs
.
renameSync
(
originalBin
,
renamedBin
);
process
.
sass
.
getBinaryPath
(
true
);
},
function
(
err
)
{
fs
.
renameSync
(
renamedBin
,
originalBin
);
if
((
err
instanceof
Error
)
&&
/`libsass` bindings not found. Try reinstalling `node-sass`
?
/
.
test
(
err
))
{
done
();
return
true
;
}
});
});
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
();
...
...
@@ -729,4 +712,87 @@ describe('api', function() {
done
();
});
});
describe
(
'extensions'
,
function
()
{
it
(
'should use the binary path and name set in package.json.'
,
function
(
done
)
{
var
packagePath
=
require
.
resolve
(
'../package'
),
extensionsPath
=
require
.
resolve
(
'../lib/extensions'
);
delete
require
.
cache
[
extensionsPath
];
require
.
cache
[
packagePath
].
exports
.
nodeSassConfig
=
{
binaryName
:
'foo'
,
binaryPath
:
'bar'
};
require
(
extensionsPath
);
assert
.
equal
(
process
.
sass
.
binaryName
,
'foo_binding.node'
);
assert
.
equal
(
process
.
sass
.
binaryPath
,
'bar'
);
delete
require
.
cache
[
packagePath
];
delete
require
.
cache
[
extensionsPath
];
require
(
extensionsPath
);
done
();
});
it
(
'should use the binary path and name set as environment variable.'
,
function
(
done
)
{
var
extensionsPath
=
require
.
resolve
(
'../lib/extensions'
);
delete
require
.
cache
[
extensionsPath
];
process
.
env
.
SASS_BINARY_NAME
=
'foo'
;
process
.
env
.
SASS_BINARY_PATH
=
'bar'
;
require
(
extensionsPath
);
assert
.
equal
(
process
.
sass
.
binaryName
,
'foo_binding.node'
);
assert
.
equal
(
process
.
sass
.
binaryPath
,
'bar'
);
delete
process
.
env
.
SASS_BINARY_NAME
;
delete
process
.
env
.
SASS_BINARY_PATH
;
delete
require
.
cache
[
extensionsPath
];
require
(
extensionsPath
);
done
();
});
it
(
'should use the binary path and name set as process argument.'
,
function
(
done
)
{
var
extensionsPath
=
require
.
resolve
(
'../lib/extensions'
),
argv
=
process
.
argv
;
delete
require
.
cache
[
extensionsPath
];
process
.
argv
=
argv
.
concat
([
'--binary-name'
,
'foo'
,
'--binary-path'
,
'bar'
]);
require
(
extensionsPath
);
assert
.
equal
(
process
.
sass
.
binaryName
,
'foo_binding.node'
);
assert
.
equal
(
process
.
sass
.
binaryPath
,
'bar'
);
process
.
argv
=
argv
;
delete
require
.
cache
[
extensionsPath
];
require
(
extensionsPath
);
done
();
});
it
(
'should throw error when libsass binary is missing.'
,
function
(
done
)
{
var
originalBin
=
process
.
sass
.
binaryPath
,
renamedBin
=
[
originalBin
,
'_moved'
].
join
(
''
);
assert
.
throws
(
function
()
{
fs
.
renameSync
(
originalBin
,
renamedBin
);
process
.
sass
.
getBinaryPath
(
true
);
},
function
(
err
)
{
fs
.
renameSync
(
renamedBin
,
originalBin
);
if
((
err
instanceof
Error
)
&&
/`libsass` bindings not found. Try reinstalling `node-sass`
?
/
.
test
(
err
))
{
done
();
return
true
;
}
});
});
});
});
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