Skip to content

Commit

Permalink
fixup! Date: Dynamically augment skeleton (3/3)
Browse files Browse the repository at this point in the history
  • Loading branch information
rxaviers committed Mar 16, 2017
1 parent c9440e4 commit bb1f30d
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/unit/date/expand-pattern/compare-formats.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
define([
"src/date/expand-pattern/compare-formats"
], function( compareFormats ) {

QUnit.module( "Date Expand Pattern Compare Formats" );

// "Most symbols have a small distance from each other, e.g., M ≅ L; E ≅ c; a ≅ b ≅ B;
// H ≅ k ≅ h ≅ K; ..."
QUnit.test( "should add a small distance on similar patterns", function( assert ) {
assert.ok( compareFormats( "MM", "LL" ) > compareFormats( "MM", "MM" ) );
assert.ok( compareFormats( "MM", "LLL" ) > compareFormats( "MM", "MMM" ) );
assert.ok( compareFormats( "E", "c" ) > compareFormats( "E", "E" ) );
});

// Numeric (l<3) and text fields (l>=3) are given a larger distance from each other.
QUnit.test( "should add a larger distance comparing numeric vs text fields", function( assert ) {
assert.ok( compareFormats( "MM", "MMM" ) > compareFormats( "MM", "M" ) );
assert.ok( compareFormats( "MMM", "MM" ) > compareFormats( "MMM", "MMMMM" ) );
});

QUnit.test( "should mark not equal things", function( assert ) {
assert.equal( compareFormats( "yMd", "d" ), -1 );
assert.equal( compareFormats( "MM", "d" ), -1 );
assert.equal( compareFormats( "yMMd", "MMM" ), -1 );
});

});

0 comments on commit bb1f30d

Please sign in to comment.