Skip to content

Commit

Permalink
Add tests for non-JSON literals on object props.
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Kaske committed Nov 30, 2017
1 parent 77b17b4 commit 7d49e80
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
13 changes: 11 additions & 2 deletions test/unit/attributes-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@
observer: 'attr1Changed'
},
shorthandNumber: Number,
shorthandBool: Boolean
shorthandBool: Boolean,
foreignTypeObjectProp: {
type: Object,
value: 'none'
}
},

propChangedCount: 0,
Expand Down Expand Up @@ -166,7 +170,12 @@
readOnly: true
},
shorthandNumber: Number,
shorthandBool: Boolean
shorthandBool: Boolean,
foreignTypeObjectProp: {
type: Object,
reflectToAttribute: true,
value: 'none'
}
},
_warn: function() {
var search = Array.prototype.join.call(arguments, '');
Expand Down
17 changes: 15 additions & 2 deletions test/unit/attributes.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
shorthand-number="88"
behavior-shorthand-bool
behavior-shorthand-number="99"
>
foreign-type-object-prop="The quick brown fox">
</x-basic>
</template>
</test-fixture>
Expand Down Expand Up @@ -81,7 +81,8 @@
shorthand-bool
shorthand-number="88"
behavior-shorthand-bool
behavior-shorthand-number="99">
behavior-shorthand-number="99"
foreign-type-object-prop="The quick brown fox">
</x-reflect>
</template>
</test-fixture>
Expand All @@ -106,6 +107,7 @@
assert.strictEqual(element.shorthandBool, undefined);
assert.strictEqual(element.behaviorShorthandNumber, undefined);
assert.strictEqual(element.behaviorShorthandBool, undefined);
assert.strictEqual(element.foreignTypeObjectProp, 'none');
}

function testAttributesMatchCustomConfiguration(element) {
Expand Down Expand Up @@ -133,6 +135,7 @@
assert.strictEqual(element.shorthandBool, true);
assert.strictEqual(element.behaviorShorthandNumber, 99);
assert.strictEqual(element.behaviorShorthandBool, true);
assert.strictEqual(element.foreignTypeObjectProp, configuredString);
}

test('basic default values', function() {
Expand Down Expand Up @@ -175,6 +178,11 @@
assert.deepEqual(element.object, configuredObject);
});

test('change object attribute to foreign type', function() {
element.setAttribute('object', 'The quick brown fox');
assert.deepEqual(element.object, 'The quick brown fox');
});

test('change array attribute', function() {
element.setAttribute('array', '[0, "foo", true, {"foo": "bar"}]');
assert.deepEqual(element.array, configuredArray);
Expand Down Expand Up @@ -237,6 +245,11 @@
assert.deepEqual(element.object, configuredObject);
});

test('change object attribute to foreign type', function() {
element.setAttribute('object', 'The quick brown fox');
assert.deepEqual(element.object, 'The quick brown fox');
});

test('change array attribute', function() {
element.setAttribute('array', '[0, "foo", true, {"foo": "bar"}]');
assert.deepEqual(element.array, configuredArray);
Expand Down

0 comments on commit 7d49e80

Please sign in to comment.