Skip to content

Instantly share code, notes, and snippets.

@alexanderosipov
Created September 28, 2015 20:46
Show Gist options
  • Save alexanderosipov/14b5d0e9e6f9c8fc3c3a to your computer and use it in GitHub Desktop.
Save alexanderosipov/14b5d0e9e6f9c8fc3c3a to your computer and use it in GitHub Desktop.
it('remove all attributes and add #aa81', function () {
var api = util.loadApi(util.data('attr/aa8.raml'));
var method: hl.IHighLevelNode = <hl.IHighLevelNode>util.xpath(api, "resources[0]/methods[0]");
var attrs = method.attributes('protocols');
console.log("Original:\n" + api.lowLevel().unit().contents());
attrs.forEach(attr => attr.remove());
console.log("After remove:\n" + api.lowLevel().unit().contents());
['HTTP', 'HTTPS', 'HUE'].forEach(val => method.attrOrCreate('protocols').addValue(val));
console.log("After insert:\n" + api.lowLevel().unit().contents());
console.log('attributes count: ' + method.attributes('protocols').length); // 4
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment