Created
September 28, 2015 20:46
-
-
Save alexanderosipov/14b5d0e9e6f9c8fc3c3a to your computer and use it in GitHub Desktop.
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
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