-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3e9bd42
commit 9d5b0a3
Showing
4 changed files
with
255 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
require 'spec_helper' | ||
|
||
describe ":Inline" do | ||
describe "const unpacking" do | ||
specify "deletes a const line if nothing is left of it after inlining" do | ||
edit_file 'test.js', <<-EOF | ||
const { Controller } = Ember; | ||
export default Controller.extend({}); | ||
EOF | ||
|
||
vim.search 'const { \zsController' | ||
vim.command 'Inline' | ||
vim.write | ||
|
||
expect_file_contents current_file, <<-EOF | ||
export default Ember.Controller.extend({}); | ||
EOF | ||
end | ||
|
||
specify "deletes an const line with another const line following" do | ||
edit_file 'test.js', <<-EOF | ||
const { Controller } = Ember; | ||
const { foo } = bar; | ||
export default Controller.extend({}); | ||
EOF | ||
|
||
vim.search 'const { \zsController' | ||
vim.command 'Inline' | ||
vim.write | ||
|
||
expect_file_contents current_file, <<-EOF | ||
const { foo } = bar; | ||
export default Ember.Controller.extend({}); | ||
EOF | ||
end | ||
|
||
specify "inlines entries from the beginning" do | ||
edit_file 'test.js', <<-EOF | ||
import Ember from 'ember'; | ||
const { computed, Controller, isPresent } = Ember; | ||
export default Controller.extend({ | ||
foo: Ember.computed.equal('bar', 'baz') | ||
}); | ||
EOF | ||
|
||
vim.search 'const.*\zscomputed' | ||
vim.command 'Inline' | ||
vim.write | ||
|
||
expect_file_contents current_file, <<-EOF | ||
import Ember from 'ember'; | ||
const { Controller, isPresent } = Ember; | ||
export default Controller.extend({ | ||
foo: Ember.computed.equal('bar', 'baz') | ||
}); | ||
EOF | ||
end | ||
|
||
specify "inlines entries in the middle" do | ||
edit_file 'test.js', <<-EOF | ||
import Ember from 'ember'; | ||
const { computed, Controller, isPresent } = Ember; | ||
export default Controller.extend({ | ||
foo: Ember.computed.equal('bar', 'baz') | ||
}); | ||
EOF | ||
|
||
vim.search 'const.*\zsController' | ||
vim.command 'Inline' | ||
vim.write | ||
|
||
expect_file_contents current_file, <<-EOF | ||
import Ember from 'ember'; | ||
const { computed, isPresent } = Ember; | ||
export default Ember.Controller.extend({ | ||
foo: Ember.computed.equal('bar', 'baz') | ||
}); | ||
EOF | ||
end | ||
|
||
specify "inlines entries at the end" do | ||
edit_file 'test.js', <<-EOF | ||
import Ember from 'ember'; | ||
const { computed, Controller, isPresent } = Ember; | ||
export default Controller.extend({ | ||
foo: Ember.computed.equal('bar', 'baz') | ||
}); | ||
EOF | ||
|
||
vim.search 'const.*\zsisPresent' | ||
vim.command 'Inline' | ||
vim.write | ||
|
||
expect_file_contents current_file, <<-EOF | ||
import Ember from 'ember'; | ||
const { computed, Controller } = Ember; | ||
export default Controller.extend({ | ||
foo: Ember.computed.equal('bar', 'baz') | ||
}); | ||
EOF | ||
end | ||
end | ||
end |
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,88 @@ | ||
require 'spec_helper' | ||
|
||
describe ":Unpack" do | ||
specify "creates a const line if there is none, at the top of the file" do | ||
edit_file 'test.js', <<-EOF | ||
export default Ember.Controller.extend({}); | ||
EOF | ||
|
||
vim.search 'Ember\.Controller' | ||
vim.command 'Unpack' | ||
vim.write | ||
|
||
expect_file_contents current_file, <<-EOF | ||
const { Controller } = Ember; | ||
export default Controller.extend({}); | ||
EOF | ||
end | ||
|
||
specify "creates a const line if there is none, after the import lines" do | ||
edit_file 'test.js', <<-EOF | ||
import Ember from 'ember'; | ||
export default Ember.Controller.extend({}); | ||
EOF | ||
|
||
vim.search 'Ember\.Controller' | ||
vim.command 'Unpack' | ||
vim.write | ||
|
||
expect_file_contents current_file, <<-EOF | ||
import Ember from 'ember'; | ||
const { Controller } = Ember; | ||
export default Controller.extend({}); | ||
EOF | ||
end | ||
|
||
specify "adds entries to the const line if it exists" do | ||
edit_file 'test.js', <<-EOF | ||
import Ember from 'ember'; | ||
const { Controller } = Ember; | ||
export default Controller.extend({ | ||
foo: Ember.computed.equal('bar', 'baz') | ||
}); | ||
EOF | ||
|
||
vim.search 'Ember\.computed' | ||
vim.command 'Unpack' | ||
vim.write | ||
|
||
expect_file_contents current_file, <<-EOF | ||
import Ember from 'ember'; | ||
const { Controller, computed } = Ember; | ||
export default Controller.extend({ | ||
foo: computed.equal('bar', 'baz') | ||
}); | ||
EOF | ||
end | ||
|
||
specify "adds a new const line for nested unpacking" do | ||
edit_file 'test.js', <<-EOF | ||
import Ember from 'ember'; | ||
const { Controller } = Ember; | ||
export default Controller.extend({}); | ||
EOF | ||
|
||
vim.search 'Controller\.extend' | ||
vim.command 'Unpack' | ||
vim.write | ||
|
||
expect_file_contents current_file, <<-EOF | ||
import Ember from 'ember'; | ||
const { Controller } = Ember; | ||
const { extend } = Controller; | ||
export default extend({}); | ||
EOF | ||
end | ||
end |