Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
chenos committed Feb 5, 2018
1 parent 7cf11d1 commit e5046f1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ModuleLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function setExtensions(...$extensions)

public function addOverride($name, $override = null)
{
if (func_num_args() == 1 && is_array($name)) {
if (is_array($name)) {
$this->overrides = array_merge($this->overrides, $name);
} elseif (func_num_args() == 2) {
$this->overrides[$name] = $override;
Expand Down
16 changes: 16 additions & 0 deletions tests/ModuleLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ public function setUp()
$this->v8 = $v8;
}

public function testAddOverride1()
{
$overrides = ['vue' => 'vue/dist/vue.js'];
$this->loader->addOverride($overrides);
$this->assertAttributeEquals($overrides, 'overrides', $this->loader);
}

public function testAddOverride2()
{
$overrides = ['vue' => 'vue/dist/vue.js'];
foreach ($overrides as $key => $value) {
$this->loader->addOverride($key, $value);
}
$this->assertAttributeEquals($overrides, 'overrides', $this->loader);
}

public function testNestRequire()
{
$this->assertOutputEquals("require('./fn')();", 'hello1hello2');
Expand Down

0 comments on commit e5046f1

Please sign in to comment.