-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(config): add project configuration (#232)
- Loading branch information
Showing
8 changed files
with
186 additions
and
37 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
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
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
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,49 @@ | ||
local utils = require("flutter-tools.utils") | ||
|
||
describe("commands", function() | ||
local commands | ||
before_each(function() commands = require("flutter-tools.commands") end) | ||
after_each(function() | ||
commands = nil | ||
package.loaded["flutter-tools.commands"] = nil | ||
end) | ||
it( | ||
"should add project config options correctly", | ||
function() | ||
assert.are.same( | ||
{ "run", "--flavor", "Production" }, | ||
commands.__get_run_args({}, { flavor = "Production" }) | ||
) | ||
end | ||
) | ||
|
||
it( | ||
"should add 'dart_defines' options correctly", | ||
function() | ||
assert.are.same( | ||
{ "run", "--flavor", "Production", "--dart-define", "ENV=prod" }, | ||
commands.__get_run_args({}, { flavor = "Production", dart_define = { ENV = "prod" } }) | ||
) | ||
end | ||
) | ||
|
||
it("should add multiple dart_defines", function() | ||
local args = commands.__get_run_args({}, { | ||
flavor = "Production", | ||
dart_define = { ENV = "prod", KEY = "VALUE" }, | ||
}) | ||
local result = utils.fold(function(acc, v) | ||
acc[v] = acc[v] and acc[v] + 1 or 1 | ||
return acc | ||
end, args, {}) | ||
|
||
assert.are.same(result, { | ||
["run"] = 1, | ||
["--flavor"] = 1, | ||
["Production"] = 1, | ||
["--dart-define"] = 2, | ||
["ENV=prod"] = 1, | ||
["KEY=VALUE"] = 1, | ||
}) | ||
end) | ||
end) |