Skip to content

Commit

Permalink
Relax assertions that require a native Object.defineProperties enviro…
Browse files Browse the repository at this point in the history
…nments without
  • Loading branch information
scothis committed Jul 29, 2013
1 parent be9ce80 commit 08dee2f
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions test/mime/type/application/hal-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

define('rest/mime/type/application/hal-test', function (require) {

var hal, mime;
var hal, mime, supports;

hal = require('rest/mime/type/application/hal');
mime = require('rest/interceptor/mime');
Expand All @@ -25,6 +25,20 @@
return { request: request };
}

supports = {
'Object.defineProperty': (function () {
try {
var obj = {};
Object.defineProperty(obj, 'test', { enumerable: false, configurable: true, value: true });
return obj.test;
}
catch (e) {
return false;
}
}())
};


buster.testCase('rest/mime/type/application/hal', {
'should stringify json': function () {
assert.equals('{"foo":"bar"}', hal.write({ foo: 'bar' }));
Expand Down Expand Up @@ -125,11 +139,14 @@
read = hal.read(JSON.stringify(raw));
writen = hal.write(read);

refute.match(writen, '_embedded');
refute.match(writen, '_links');
refute.match(writen, 'clientFor');
refute.match(writen, 'prop');
assert.match(writen, '"foo":"bar"');

if (!supports['Object.defineProperty']) {
refute.match(writen, '_embedded');
refute.match(writen, '_links');
refute.match(writen, 'clientFor');
refute.match(writen, 'prop');
}
}
});

Expand Down

0 comments on commit 08dee2f

Please sign in to comment.