-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE property-brace-expansion-improvement]
- Loading branch information
1 parent
938c514
commit 46afe8e
Showing
4 changed files
with
142 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import Ember from "ember-metal/core"; | ||
import expandProperties from "ember-metal/expand_properties"; | ||
|
||
var foundProperties = []; | ||
|
||
function addProperty(property) { | ||
foundProperties.push(property); | ||
} | ||
|
||
QUnit.module('Property Brace Expansion Test', { | ||
setup: function() { | ||
foundProperties = []; | ||
} | ||
}); | ||
|
||
test('Properties without expansions are unaffected', function() { | ||
expect(1); | ||
|
||
expandProperties('a', addProperty); | ||
expandProperties('a.b', addProperty); | ||
expandProperties('a.b.@each', addProperty); | ||
|
||
deepEqual(['a', 'a.b', 'a.b.@each'].sort(), foundProperties.sort()); | ||
}); | ||
|
||
test('A single expansion at the end expands properly', function() { | ||
expect(1); | ||
|
||
expandProperties('a.b.{c,d}', addProperty); | ||
|
||
deepEqual(['a.b.c', 'a.b.d'].sort(), foundProperties.sort()); | ||
}); | ||
|
||
test('A property with only a brace expansion expands correctly', function() { | ||
expect(1); | ||
|
||
expandProperties('{a,b,c}', addProperty); | ||
|
||
var expected = ['a', 'b', 'c']; | ||
deepEqual(expected.sort(), foundProperties.sort()); | ||
}); | ||
|
||
if (!Ember.FEATURES.isEnabled('property-brace-expansion-improvement')) { | ||
test('A brace expansion at the beginning doesn\'t expand' , function() { | ||
expect(1); | ||
|
||
expandProperties('{a,b,c}.d', addProperty); | ||
|
||
deepEqual(['{a,b,c}.d'], foundProperties); | ||
}); | ||
} | ||
|
||
if (Ember.FEATURES.isEnabled('property-brace-expansion-improvement')) { | ||
test('Expansions with single properties only expand once', function() { | ||
expect(1); | ||
|
||
expandProperties('a.b.{c}.d.{e}', addProperty); | ||
|
||
deepEqual(['a.b.c.d.e'], foundProperties); | ||
}); | ||
|
||
test('A single brace expansion expands correctly', function() { | ||
expect(1); | ||
|
||
expandProperties('a.{b,c,d}.e', addProperty); | ||
|
||
var expected = ['a.b.e', 'a.c.e', 'a.d.e']; | ||
deepEqual(expected.sort(), foundProperties.sort()); | ||
}); | ||
|
||
test('Multiple brace expansions work correctly', function() { | ||
expect(1); | ||
|
||
expandProperties('{a,b,c}.d.{e,f}.g', addProperty); | ||
|
||
var expected = ['a.d.e.g', 'a.d.f.g', 'b.d.e.g', 'b.d.f.g', 'c.d.e.g', 'c.d.f.g']; | ||
deepEqual(expected.sort(), foundProperties.sort()); | ||
}); | ||
|
||
test('A property with only brace expansions expands correctly', function() { | ||
expect(1); | ||
|
||
expandProperties('{a,b,c}.{d}.{e,f}', addProperty); | ||
|
||
var expected = ['a.d.e', 'a.d.f', 'b.d.e', 'b.d.f', 'c.d.e', 'c.d.f']; | ||
deepEqual(expected.sort(), foundProperties.sort()); | ||
}); | ||
} |