-
Notifications
You must be signed in to change notification settings - Fork 0
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
WHenderson
committed
Jan 1, 2016
1 parent
5ee6b39
commit c01067d
Showing
5 changed files
with
139 additions
and
0 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,20 @@ | ||
var ko = require('../../index'); | ||
var assert = require('chai').assert; | ||
|
||
var base = ko.observable(); | ||
var typed = base.extend({ type: 'Undefined|String' }); | ||
var converted = typed.extend({ convert: true }); | ||
|
||
converted(''); | ||
assert.strictEqual(base(), undefined); | ||
converted(10); | ||
assert.strictEqual(base(), '10'); | ||
converted('string'); | ||
assert.strictEqual(base(), 'string'); | ||
|
||
base(undefined); | ||
assert.strictEqual(converted(), undefined); | ||
base('10'); | ||
assert.strictEqual(converted(), '10'); | ||
base('string'); | ||
assert.strictEqual(converted(), 'string'); |
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,35 @@ | ||
var ko = require('../../index'); | ||
var assert = require('chai').assert; | ||
|
||
var base = ko.observable(); | ||
var typed = base.extend({ type: 'Undefined|String' }); | ||
|
||
assert.doesNotThrow( | ||
function () { | ||
typed(); | ||
} | ||
); | ||
|
||
base(10); | ||
assert.throws( | ||
function () { | ||
typed(); | ||
}, | ||
TypeError, | ||
'Unexpected internal type. Expected Undefined|String, got Number' | ||
); | ||
|
||
assert.doesNotThrow( | ||
function () { | ||
typed(undefined); | ||
typed('string'); | ||
} | ||
); | ||
|
||
assert.throws( | ||
function () { | ||
typed(10); | ||
}, | ||
TypeError, | ||
'Unexpected external type. Expected Undefined|String, received Number' | ||
); |