-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add callback feature to SVGFixer.fix()
- Loading branch information
1 parent
1d5a823
commit 975d658
Showing
6 changed files
with
103 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"use strict"; | ||
|
||
const { emptyDir, isEmptyDir } = require("./"); | ||
const { SVGFixer, assert, path2 } = require("./helper"); | ||
|
||
describe("test.async", () => { | ||
describe("it exports the svg(s) and", () => { | ||
it("returns a promise when no callback is provided", async () => { | ||
var source = path2.single.relative; | ||
var destination = path2.fixed.relative; | ||
emptyDir(destination); | ||
assert.isTrue(isEmptyDir(destination)); | ||
var fixer = SVGFixer(source, destination).fix(); | ||
assert.isTrue(fixer instanceof Promise); | ||
await fixer; | ||
assert.isFalse(isEmptyDir(destination)); | ||
}); | ||
it("returns an instance of SVGFixer when a callback function is provided", (done) => { | ||
var source = path2.single.relative; | ||
var destination = path2.fixed.relative; | ||
emptyDir(destination); | ||
assert.isTrue(isEmptyDir(destination)); | ||
/** | ||
* @ignore | ||
* @description - Test callback function | ||
*/ | ||
function callback (err, fixer) { | ||
assert.isFalse(fixer instanceof Promise); | ||
assert.isTrue(fixer instanceof SVGFixer); | ||
assert.isFalse(isEmptyDir(destination)); | ||
done(err); | ||
} | ||
var fixer = SVGFixer(source, destination).fix(callback); | ||
assert.isTrue(fixer instanceof SVGFixer); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters